code
stringlengths 1
2.01M
| repo_name
stringlengths 3
62
| path
stringlengths 1
267
| language
stringclasses 231
values | license
stringclasses 13
values | size
int64 1
2.01M
|
|---|---|---|---|---|---|
<table cellpadding="0" cellspacing="0" summary="post_attachbody" border="0" width="100%">
<!--{loop $swfattachs $swfattach}-->
<tbody id="swfattach_$swfattach[aid]">
<tr>
<td class="attachnum"><img src="images/attachicons/common_new.gif" /></td>
<td class="attachctrl">
<!--{if $swfattach['isimage']}-->
<a href="javascript:;" onclick="insertAttachimgTag('$swfattach[aid]')" title="{lang post_attachment_insert}">{lang post_attachment_insertlink}</a>
<!--{else}-->
<a href="javascript:;" onclick="insertAttachTag('$swfattach[aid]')" title="{lang post_attachment_insert}">{lang post_attachment_insertlink}</a>
<!--{/if}-->
</td>
<td class="attachname_swf" title="{lang upload_msg}">
<p>
<a href="javascript:;" onclick='parentNode.innerHTML="<input type=text name=\"swfattachnew[{$swfattach[aid]}][description]\" size=\"25\" class=\"txt\" />"'>{lang description}</a>
<span{if $swfattach['isimage']} onmouseover="showpreview(this, 'swfimgpreview_$swfattach[aid]')"{/if}>$swfattach[filetype] $swfattach[filename]</span>
</p>
<!--{if $swfattach['isimage']}-->
<div id="swfimgpreview_$swfattach[aid]" style="display:none"><img id="preview_$swfattach[aid]"{if !$swfattach['width'] || $swfattach['width'] > 180} width="180"{else} width="$swfattach[width]"{/if}{if $swfattach['thumb']} src="$attachurl/$swfattach[attachment].thumb.jpg"{else} src="$attachurl/$swfattach[attachment]"{/if} /></div>
<!--{/if}-->
</td>
<!--{if $allowsetattachperm}--><td class="attachview"><input type="text" name="swfattachnew[{$swfattach[aid]}][readperm]" value="0" size="1" class="txt" /></td><!--{/if}-->
<!--{if $maxprice}--><td class="attachpr"><input type="text" name="swfattachnew[{$swfattach[aid]}][price]" value="0" size="1" class="txt" /></td><!--{/if}-->
<td class="attachdel"><input type="checkbox" name="swfattachdel[]" id="delswfattach_$swfattach[aid]" value="$swfattach[aid]" style="display:none" /><a href="javascript:;" class="deloption" onclick="delSWFAttach($swfattach[aid])">{lang post_attachment_deletelink}</a></td>
</tr>
</tbody>
<!--{/loop}-->
</table>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/post_swfattachlist.htm
|
HTML
|
asf20
| 2,159
|
<!--{if $subslist}-->
<form method="post" action="my.php?item=subscriptions">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<table cellspacing="0" cellpadding="0" summary="{lang my_subscription_threads}" class="datatable">
<thead class="colplural">
<tr>
<td width="6%"></td>
<th>{lang subject}</th>
<td class="forum">{lang forum}</td>
<td class="nums">{lang replies}</td>
<td class="lastpost"><cite>{lang lastpost}</cite></td>
</tr>
</thead>
<tbody>
<!--{loop $subslist $subs}-->
<tr>
<td><input class="checkbox" type="checkbox" name="delete[]" value="$subs[tid]" /></td>
<th><a href="viewthread.php?tid=$subs[tid]" target="_blank">$subs[subject]</a></th>
<td class="forum"><a href="forumdisplay.php?fid=$subs[fid]" target="_blank">$subs[name]</a></td>
<td class="nums">$subs[replies]</td>
<td class="lastpost">
<cite><!--{if $subs['lastposter']}--><a href="space.php?username=$subs[lastposterenc]" target="_blank">$subs[lastposter]</a><!--{else}-->{lang anonymous}<!--{/if}--></cite>
<em><a href="redirect.php?tid=$subs[tid]&goto=lastpost#lastpost">$subs[lastpost]</a></em>
</td>
</tr>
<!--{/loop}-->
<tr>
<td><input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkall(this.form)" /> <label for="chkall">{lang delete_check}</label></td>
<th><button type="submit" class="submit" name="subsubmit" value="true">{lang submit}</button></th>
<td colspan="3"><!--{if !empty($multipage)}-->$multipage<!--{/if}--></td>
</tr>
</tbody>
</table>
</form>
<!--{else}-->
<table cellspacing="0" cellpadding="0" class="datatable">
<tr><th><p class="nodata">{lang memcp_nosubs}</p></th></tr>
</table>
<!--{/if}-->
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/my_subscriptions.htm
|
HTML
|
asf20
| 1,820
|
<style type="text/css">
@import url(forumdata/cache/style_{STYLEID}_common.css?{VERHASH});
<!--{if CURSCRIPT == 'viewthread'}-->
@import url(forumdata/cache/style_{STYLEID}_viewthread.css?{VERHASH});
<!--{/if}-->
<!--{if CURSCRIPT == 'forumdisplay' && $forum['ismoderator']}-->
{template css_topicadmin}
<!--{elseif CURSCRIPT == 'viewthread'}-->
<!--{if $forum['ismoderator']}-->
{template css_topicadmin}
<!--{/if}-->
#f_post td { padding-top: 15px; padding-bottom: 20px; vertical-align: top; }
#f_post p, .fastcheck { margin: 5px 0; }
#f_post .txtarea { margin: -1px 0 0; width: 596px; height: 120px; border-color: {INPUTBORDERDARKCOLOR} {INPUTBORDER} {INPUTBORDER} {INPUTBORDERDARKCOLOR}; border-top: none; overflow: auto; }
.defaultpost { height: auto !important; height:{$_DCACHE[custominfo][postminheight]}px; min-height:{$_DCACHE[custominfo][postminheight]}px !important; }
.signatures { max-height: {$maxsigrows}px; }
* html .signatures { height: expression(signature(this)); }
.t_msgfontfix { min-height: 100px; }
* html .t_msgfontfix { height: 100px; overflow: visible; }
<!--{if $thread[special] == 5 && $stand != ''}-->
.stand_select .postauthor { background: #EBF2F8; }
.stand_select .itemtitle, .stand_select .solidline { margin: 15px 15px 10px; }
.stand_select h2 { float: left; }
<!--{/if}-->
<!--{elseif CURSCRIPT == 'pm'}-->
#pm_content h1 { float: left; font-size: 14px; }
.postpm { float: right; color: {HIGHLIGHTLINK}; font-weight: 700; }
.pm_header { padding: 6px; border: solid {COMMONBORDER}; border-width: 1px 0; }
.pm_header #pm_search { float: right; }
.pm_list { }
.pm_list li { position: relative; *margin-top: -2px; padding: 10px 140px 10px 75px; min-height: 48px; _height: 48px; border-bottom: 1px solid {COMMONBORDER}; }
.pm_list li .avatar { position: absolute; left: 5px; top: 8px; }
.pm_list .self .avatar { left: auto; right: 75px; }
.pm_list p cite, .pm_list p .time { color: {MIDTEXT}; }
.pm_list p cite { display: block; width: 260px; height: 1.6em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm_list p cite.new { padding-left: 25px; background: url({IMGDIR}/notice_newpm.gif) no-repeat 0 3px; }
.pm_list p cite a { margin-right: 5px; }
.pm_list li .action { position: absolute; right: 10px; top: 50%; margin-top: -18px; display: block; width: 50px; height: 36px; }
.pm_list li .action a { display: block; text-decoration: underline; }
.pm_list li .action a.delete { color: {HIGHLIGHTLINK}; }
.pm_list li .topact { top: 8px; margin-top: 0; }
.sticky { display: block !important; }
.pm_list li.pm_date { padding: 5px 0 5px 75px; min-height: 0; }
#pm_list ul.onerror { padding: 20px 0 0 95px; background-position: 75px 22px; }
#pmlist .summary a { color: {HIGHLIGHTLINK}; }
.pmreply { margin: 1em 0; padding-left: 75px; }
.pmreply textarea { width: 510px; }
.pmback { width: 70px; padding-left: 15px; w\idth: 55px; background: url({IMGDIR}/arrow_left.gif) no-repeat 0 50%; }
#buddies li { float: left; width: 8em; height: 1.6em; overflow: hidden; white-space: nowrap; }
.newpm_notice { padding: 0 0 10px 75px; border-bottom: 1px solid {COMMONBORDER}; }
.newpm_notice a { color: {HIGHLIGHTLINK}; }
.quote { margin: 10px 0; padding: 10px 10px 10px 65px; }
.quote { padding-bottom: 5px; background: #F9F9F9 url({IMGDIR}/icon_quote_s.gif) no-repeat 20px 6px; }
.quote blockquote { margin: 0; padding: 0 65px 5px 0; background: url({IMGDIR}/icon_quote_e.gif) no-repeat 100% 100%; line-height: 1.6em; }
.blockall { margin-bottom: 10px; padding: 10px 0; background: {SPECIALBG}; text-align: center; color: {LIGHTTEXT}; }
.blockall a { color: {HIGHLIGHTLINK}; font-size: 1.17em; }
.blacklist li a, .blacklist li strong { float: left; }
.blacklist .remove { margin: 4px 0 0 5px; width: 12px; height: 12px; background: url({IMGDIR}/close.gif) no-repeat 100% 50px; line-height: 100px; overflow: hidden; }
.blacklist .hover .remove { background-position: 100% 0; }
.blacklist .remove:hover { background-position: 100% -12px; }
.allblocked { padding-bottom: 10px; width: 100%!important; border-bottom: 1px solid {COMMONBORDER}; }
.allblocked a { margin-left: 10px; color: {HIGHLIGHTLINK}; }
<!--{elseif CURSCRIPT == 'magic'}-->
.magicprice { color: {NOTICETEXT}; font-weight: 700; font-size: 16px; }
.magic_yes { color: #080; font-weight: 700; }
.magic_no { color: #F00; font-weight: 700; }
.magicmain { height: 180px; overflow-y: auto; }
.magicinfo { margin-bottom: 10px; width: 100%; }
.magicinfo td { padding: 3px 0; }
.magicinfo h5 { font-size: 14px; }
.mymagic { margin-bottom: 30px; }
.mymagic .inlinelist li { float: left; margin-top: 10px; width: 50%; }
.mymagic .magicimg { float:left; margin-right: 10px; width: 25%; }
.mymagic .magicdetail { float:left; width: 65%; }
.mymagic h5 a { text-decoration: underline; color: {HIGHLIGHTLINK}; }
.mymagic p { margin: 3px 0; }
.mymagic .inlinelist .clear { float: none; clear: both; margin: 0; width: 100%; }
.magicnum { margin: 10px 0; }
.magicnum p { margin-top: 5px; }
.fixedbtn { position: absolute; bottom: 15px; }
<!--{elseif CURSCRIPT == 'medal'}-->
.medallist { overflow: hidden; margin-bottom: 30px; }
.medallist li { margin-bottom: 15px; width: 24.9%; }
.medalimg { float: left; margin: 5px; width: 15%; }
.medalinfo { float: left; width: 75%; }
.medalinfo p { color: {MIDTEXT}; }
.medalexp { margin-left: 8px; color: {LIGHTTEXT}; font-weight: 400; }
.medallist .clear { overflow: hidden; float: none; clear: both; margin: 0; width: 100%; height: 1px; }
.medalp { margin-bottom: 10px; }
<!--{elseif CURSCRIPT == 'invite'}-->
.invitecode { border: none !important; background-color: transparent; font-family: "Courier New", Courier, monospace, serif; }
input.marked { background: transparent url({IMGDIR}/check_right.gif) no-repeat 100% 50%; }
.expiration .invitecode { text-decoration: line-through; color: red; }
<!--{elseif CURSCRIPT == 'search'}-->
.searchform { position: relative; margin: 0 5px 10px; padding: 30px 10px 20px 160px; border-top: 5px solid {WRAPBG}; background: {SPECIALBG}; }
.searchlabel { position: absolute; left: 0; _left: -160px; top: 30px; width: 150px; text-align: center; font-weight: 700; font-size: 26px; color: {HIGHLIGHTLINK}; line-height: 30px; }
.searchlabel strong { display: block; font-size: 14px; color: {MIDTEXT}; font-weight: 400; text-align: center; }
.searchform h3 { margin: 10px 2px; font-size: 14px; }
.searchkey { margin-bottom: 1em; zoom: 1; }
.searchkey #searchsubmit { margin: 0 16px 0 10px; }
* html #searchsubmit { height: 21px; line-height: 19px; }
*+html #searchsubmit { height: 21px; line-height: 19px; }
.searchkey a { background: url(images/common/editor.gif) 0 -181px no-repeat; padding:2px 0 2px 22px; color: {HIGHLIGHTLINK}; }
.searchlist { margin: 5px 20px; }
.searchlist h1 { font-size: 14px; }
.searchlist h1 em { font-weight: 400; }
#srchfid optgroup, #moveto optgroup { font-style: normal; font-weight: 400; font-size: 12px; }
<!--{elseif CURSCRIPT == 'faq' || CURSCRIPT == 'announcement'}-->
.faqmessage, .announcemsg { margin-bottom: 10px; font-size: 14px; padding-bottom: 20px; border-bottom: 1px solid {COMMONBORDER}; }
.faqmessage ul, .announcemsg ul { padding-left: 1.6em; }
.faq li { margin-left: 2em; }
.faq ul li { list-style-type: disc; }
.t_msgfont ul.o li, .faq ol li { list-style-type: decimal; }
.author { margin-bottom: 5px; font-size: 12px; color: {LIGHTTEXT}; }
<!--{elseif CURSCRIPT == 'memcp' || CURSCRIPT == 'credits'}-->
<!--{if CURSCRIPT == 'memcp'}-->
.avatararea { float: left; margin-right: 20px; width: 120px; }
.avatararea a { display:block; margin: 15px 0; width: 119px; height: 31px; line-height: 31px; text-align: center; background: url({IMGDIR}/bigbtn.gif) no-repeat; font-size: 14px; }
.avatararea a:hover { text-decoration: none; }
#avatarctrl { float: left; }
<!--{/if}-->
.creditstable {}
.creditstable td { padding: 10px 5px !important; }
.cre_title { width: 50px; }
.cre_opt { width: 150px; }
.cre_arrow { width: 30px; }
.cre_btn { margin-top: 10px; }
<!--{elseif CURSCRIPT == 'my' && $item == 'buddylist'}-->
.friendavatar { float: left; margin: 10px 10px 10px 0; }
.friendinfo { overflow: hidden; margin: 10px 10px 10px 0; }
* html .friendinfo { margin-left: 70px; }
.friendinfo p { color: {LIGHTTEXT} }
.friendinfo a { text-decoration: none !important; }
.friendinfo a:hover { text-decoration: underline !important; }
.friendinfo h5 a { font-size: 14px; color: {HIGHLIGHTLINK}; }
.friendctrl { margin-top :5px; }
.friendctrl a { color: {TABELTEXT}; }
.buddyname { margin-bottom: 8px; line-height: 16px; }
.online_buddy { margin-left: 8px; vertical-align: middle; }
<!--{elseif CURSCRIPT == 'modcp'}-->
<!--{if $forum['ismoderator']}-->
{template css_topicadmin}
<!--{/if}-->
.notelist { margin-top: -1px; border-top: 1px solid {COMMONBORDER}; border-bottom: 1px solid {COMMONBORDER}; zoom: 1; }
.notelist .c_header, .notelistsubmit { margin: 10px; }
.notelistbg, .notelistbg .c_header h3, .notelistbg .closenode .c_header_ctrlbtn { background-color: {INTERLEAVECOLOR}; }
.notelistmsg { overflow: hidden; margin: 0 10px 10px 33px; }
.notelistmsg .submit { margin-top: 10px; }
.notelistmsg h3 { margin: 30px 0 5px; color: {HIGHLIGHTLINK}; }
.datalist .announcetable { width: 600px; }
.datalist .announcetable, .datalist .announcetable th, .datalist .announcetable td { padding: 3px 0; border: none; }
.datalist .announcetable th { font-weight: 700; }
.anno_subject .txt { width: 270px; *width: 220px; }
.anno_type select { width: 80px; }
.anno_time .txt { width: 80px; }
.anno_msg .txtarea, .anno_msg .txt { width: 590px; }
.anno_msg .txtarea { margin-top: -1px; border-top-color: {INPUTBORDER}; }
.schresult .formtable th { padding: 5px 10px 5px 20px; width: 60px; }
.schresult .formtable td a{ color: {HIGHLIGHTLINK}; font-weight: 700; }
<!--{elseif CURSCRIPT == 'stats' || CURSCRIPT == 'member'}-->
.hasscrolltable { overflow: hidden; zoom: 1; * padding-bottom: 9px; }
.datalist .scrollfixedtable { float: left; margin-top: 1px; margin-left: 1px; width: 20%; }
.scrolltable { float:left; width: 79%; overflow-x: scroll; }
.scrolltable table { table-layout: fixed; margin: 1px 0 0; width: 1600px; }
.datalist .fixedtable { margin-bottom: 10px; width: 99%; text-align: right; }
.datalist .fixedtable a { text-decoration: underline; }
.datalist table a { text-decoration: underline; }
.datalist table a:hover { color: {HIGHLIGHTLINK}; }
<!--{elseif CURSCRIPT == 'profile'}-->
#profile .itemtitle h1 { color: {HIGHLIGHTLINK}; }
#profile p { margin: 5px 0; }
.profile_side .avatar { margin: 25px 0; text-align: center; }
.profile_side ul { margin: 5px 30px; line-height: 1.6em; overflow: hidden; }
.profile_side li { margin: 5px 0; background-position: 0 50%; background-repeat: no-repeat; text-indent: 22px; }
.profile_side li.pm { background-image: url({IMGDIR}/pmto.gif); }
.profile_side li.buddy { background-image: url({IMGDIR}/addbuddy.gif); }
.profile_side li.space { background-image: url({IMGDIR}/home.gif); }
.profile_side li.searchpost { background-image: url({IMGDIR}/fastreply.gif); }
.profile_side li.magic { background-image: url({IMGDIR}/magic.gif);}
#profile_stats li { text-indent: 0; }
#profile_stats li img { float: left; margin-right: 6px; }
#uch_feed { float: right; width: 50%; }
#uch_feed li { width: 100%; height: 1.6em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#uch_feed img { margin-bottom: -4px; }
#uch_feed a { color: {HIGHLIGHTLINK}; }
<!--{elseif CURSCRIPT == 'post'}-->
* html .content { height: auto !important; }
.nojs { position: relative; left: auto; }
* html .nojs { left: 0; }
* html .nojs .sim_upfile .sitenote { bottom: 161px; }
* html .nojs .sim_upfile .upfile_special { bottom: 301px; }
* html .nojs .sim_upfile .upfile { bottom: 356px; }
.nojs .float { margin: 0 auto; zoom: 1; }
.nojs .moreconf { position: relative; left: 0; width: auto; }
#floatwinnojs { position: static; }
.nojs .floatboxswf { width: 600px !important; }
.nojs .floatboxswf div { margin: 0 0 10px 11px; }
.nojs .floatbox1 { width: 100%; height: auto; }
#custominfoarea { right: 10px; left: auto; }
.nojs .specialinfo, .nojs .upfilelist { overflow-y: visible; height: auto !important; }
.popupmenu_popup, #e_popup_smilies_menu { *margin-top: 22px; }
* html .popupmenu_popup li { clear: both; float: left; }
* html .fontstyle_menu { overflow: hidden; width: 35px; }
* html .fontstyle_menu ul { width: 70px; }
* html .fontname_menu li { float: none; }
<!--{/if}-->
<!--{if CURSCRIPT == 'register'}-->
* html .content { overflow-y: visible !important; }
.nojs { position: relative; left: auto; }
* html .nojs { left: 20%; }
.nojs .float { margin: 0 auto; zoom: 1; }
.nojs .moreconf { position: relative; right: -15px; left: auto; width: auto; }
* html .nojs .moreconf { position: absolute; left: 0; bottom: 55px; }
*+html .nojs .moreconf { position: absolute; left: 165px; }
#floatwinnojs { position: static; }
.nojs .loginform, .nojs .regform, .nojs .floatbox, .nojs .floatbox1 { height: auto; }
.nojs .gateform { padding-bottom: 50px; }
<!--{if $secqaacheck}-->
.regform #secanswer_menu { left: 260px; top: 176px; }
* html .regform #secanswer_menu { left: 113px; }
.regform #seccodeverify_menu { left: 340px; }
* html .regform #seccodeverify_menu { left: 193px;}
<!--{else}-->
.regform #seccodeverify_menu { left: 260px; }
* html .regform #seccodeverify_menu { left: 113px; }
<!--{/if}-->
<!--{/if}-->
</style>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/css_script.htm
|
HTML
|
asf20
| 13,623
|
</div>
</div></div></div>
</div>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/footer_nofloat.htm
|
HTML
|
asf20
| 38
|
<?php
// Email Pack for Discuz! Version 3.1.0
// Translated by Crossday
// ATTENTION: Please add slashes(\) before single & double quotes( ' & " )
$language = array
(
'moderate_member_invalidate' => '否决',
'moderate_member_delete' => '删除',
'moderate_member_validate' => '通过',
'get_passwd_subject' => '取回密码说明',
'get_passwd_message' => '
$member[username],
这封信是由 $bbname 发送的。
您收到这封邮件,是因为在我们的论坛上这个邮箱地址被登记为用户邮箱,
且该用户请求使用 Email 密码重置功能所致。
----------------------------------------------------------------------
重要!
----------------------------------------------------------------------
如果您没有提交密码重置的请求或不是我们论坛的注册用户,请立即忽略
并删除这封邮件。只在您确认需要重置密码的情况下,才继续阅读下面的
内容。
----------------------------------------------------------------------
密码重置说明
----------------------------------------------------------------------
您只需在提交请求后的三天之内,通过点击下面的链接重置您的密码:
{$boardurl}member.php?action=getpasswd&uid=$member[uid]&id=$idstring
(如果上面不是链接形式,请将地址手工粘贴到浏览器地址栏再访问)
上面的页面打开后,输入新的密码后提交,之后您即可使用新的密码登录
论坛了。您可以在用户控制面板中随时修改您的密码。
本请求提交者的 IP 为 $onlineip
此致
$bbname 管理团队.
$boardurl',
'email_verify_subject' => 'Email 地址验证',
'email_verify_message' => '
$discuz_userss ,
这封信是由 $bbname 发送的。
您收到这封邮件,是因为在我们论坛的新用户注册,或用户修改 Email 使用
了您的地址。如果您并没有访问过我们的论坛,或没有进行上述操作,请忽
略这封邮件。您不需要退订或进行其他进一步的操作。
----------------------------------------------------------------------
帐号激活说明
----------------------------------------------------------------------
您是我们论坛的新用户,或在修改您的注册 Email 时使用了本地址,我们需
要对您的地址有效性进行验证以避免垃圾邮件或地址被滥用。
您只需点击下面的链接即可激活您的帐号:
{$boardurl}member.php?action=activate&uid=$discuz_uid&id=$idstring
(如果上面不是链接形式,请将地址手工粘贴到浏览器地址栏再访问)
感谢您的访问,祝您使用愉快!
此致
$bbname 管理团队.
$boardurl',
'email_notify_subject' => '《$thread[subject]》新回复通知',
'email_notify_message' => '
您好,
这封信是由 $bbname 发送的。
您收到这封邮件,是因为您订阅的以下主题在最近 24 小时内有了新的回复。
如果您并没有访问过我们的论坛,或没有进行上述操作,请忽略这封邮件。
您不需要退订或进行其他进一步的操作。
----------------------------------------------------------------------
主题信息
----------------------------------------------------------------------
URL: {$boardurl}viewthread.php?tid=$thread[tid]
标题: $thread[subject]
作者: $thread[author]
查看: $thread[views]
回复: $thread[replies]
该主题最近一次由 $thread[lastposter] 于 $thread[lastpost] 回复。
您订阅的主题可能有更多的回复,为了不影响您信箱的正常使用,我们每 24
小时至多只会发送一次新回复通知,在此期间如果有新回复,将在下次一并通
知。
此致
$bbname 管理团队.
$boardurl',
'add_member_subject' => '您被添加成为会员',
'add_member_message' => '
$newusername ,
这封信是由 $bbname 发送的。
我是 $discuz_userss ,$bbname 的管理者之一。您收到这封邮件,是因为您
刚刚被添加成为我们论坛的会员,当前 Email 即是我们为您注册的地址。
----------------------------------------------------------------------
重要!
----------------------------------------------------------------------
如果您对我们的论坛不感兴趣或无意成为会员,请忽略这封邮件。
----------------------------------------------------------------------
帐号信息
----------------------------------------------------------------------
论坛名称:$bbname
论坛地址:$boardurl
用户名:$newusername
密码:$newpassword
从现在起您可以使用您的帐号登录我们的论坛,祝您使用愉快!
此致
$bbname 管理团队.
$boardurl',
'birthday_subject' => '祝您生日快乐',
'birthday_message' => '
$member[username],
这封信是由 $bbname 发送的。
您收到这封邮件,是因为在我们的论坛上这个邮箱地址被登记为用户邮箱,
并且按照您填写的信息,今天是您的生日,很高兴能在此时为您献上一份
生日祝福,我谨代表论坛管理团队,衷心祝福您生日快乐。
如果您并非我们的会员,或今天并非您的生日,可能是有人误用了您的邮
件地址,或错误的填写了生日信息,本邮件不会多次重复发送,请忽略这
封邮件。
此致
$bbname 管理团队.
$boardurl',
'email_to_friend_subject' => '$discuz_userss 推荐给您: $thread[subject]',
'email_to_friend_message' => '
这封信是由 $bbname 的 $discuz_userss 发送的。
您收到这封邮件,是因为在 $discuz_userss 通过 $bbname 的“推荐给朋友”
功能推荐了如下的内容给您,如果您对此不感兴趣,请忽略这封邮件。您不
需要退订或进行其他进一步的操作。
----------------------------------------------------------------------
信件原文开始
----------------------------------------------------------------------
$message
----------------------------------------------------------------------
信件原文结束
----------------------------------------------------------------------
请注意这封信仅仅是由用户使用 “推荐给朋友”发送的,不是论坛官方邮件,
论坛管理团队不会对这类邮件负责。
欢迎您访问 $bbname
$boardurl',
'email_to_invite_subject' => '您的朋友 $discuz_userss 发送 $bbname 论坛注册邀请码给您',
'email_to_invite_message' => '
$sendtoname,
这封信是由 $bbname 的 $discuz_userss 发送的。
您收到这封邮件,是因为在 $discuz_userss 通过我们论坛的“发送邀请码给朋友”
功能推荐了如下的内容给您,如果您对此不感兴趣,请忽略这封邮件。您不
需要退订或进行其他进一步的操作。
----------------------------------------------------------------------
信件原文开始
----------------------------------------------------------------------
$message
----------------------------------------------------------------------
信件原文结束
----------------------------------------------------------------------
请注意这封信仅仅是由用户使用 “发送邀请码给朋友”发送的,不是论坛官方邮件,
论坛管理团队不会对这类邮件负责。
欢迎您访问 $bbname
$boardurl',
'moderate_member_subject' => '用户审核结果通知',
'moderate_member_message' => '
$member[username] ,
这封信是由 $bbname 发送的。
您收到这封邮件,是因为在我们的论坛上这个邮箱地址被新用户注册时所
使用,且管理员设置了需对新用户进行人工审核,本邮件将通知您提交的
申请的审核结果。
----------------------------------------------------------------------
注册信息与审核结果
----------------------------------------------------------------------
用户名: $member[username]
注册时间: $member[regdate]
提交时间: $member[submitdate]
提交次数: $member[submittimes]
注册原因: $member[message]
审核结果: $language[$member[operation]]
审核时间: $member[moddate]
审核管理员: $discuz_userss
管理员留言: $member[remark]
----------------------------------------------------------------------
审核结果说明
----------------------------------------------------------------------
通过: 您的注册已通过审核,您已成为我们论坛的正式用户。
否决: 您的注册信息不完整,或未满足我们对新用户的某些要求,您可以
根据管理员留言,完善您的注册信息,然后再提交。
删除:您的注册由于与我们的要求偏差较大,或我们的论坛新注册人数已
超过预期,申请被彻底否决。您的帐号已从数据库中删除,将无法
再使用其登录或提交再次审核,请您谅解。
此致
$bbname 管理团队.
$boardurl'
);
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/emails.lang.php
|
PHP
|
asf20
| 9,098
|
<h2>{lang user_center}</h2>
<div class="sideinner">
<ul class="tabs">
<!--{if $regverify == 1 && $groupid == 8}-->
<li><a href="member.php?action=emailverify">{lang memcp_email_reverify}</a></li>
<!--{/if}-->
<!--{if $regverify == 2 && $groupid == 8}-->
<li><a href="memcp.php?action=validating">{lang memcp_validating}</a></li>
<li><a href="memcp.php?action=profile&typeid=2">{lang memcp_profile}</a></li>
<!--{else}-->
<li><a href="memcp.php?action=profile&typeid=2">{lang memcp_profile}</a></li>
<li><a href="pm.php">{lang pm}</a></li>
<li><a href="my.php?item=buddylist&$extrafid">{lang my_buddylist}</a></li>
<!--{if $regstatus > 1}--><li><a href="invite.php">{lang invite}</a></li><!--{/if}-->
<!--{if $ucappopen['UCHOME']}-->
<li><a href="{$uchomeurl}/space.php?uid=$discuz_uid" target="_blank">{lang space_my}</a></li>
<!--{elseif $ucappopen['XSPACE']}-->
<li><a href="{$xspaceurl}/?uid-$discuz_uid" target="_blank">{lang space_my}</a></li>
<!--{/if}-->
<!--{/if}-->
</ul>
</div>
<!--{if $groupid != 8}-->
<hr class="shadowline" />
<div class="sideinner">
<ul class="tabs">
<li><a href="my.php?item=threads$extrafid">{lang my_posts}</a></li>
<li><a href="my.php?item=favorites&type=thread$extrafid">{lang my_favorite}</a></li>
<li><a href="my.php?item=subscriptions$extrafid">{lang my_subscriptions}</a></li>
</ul>
</div>
<hr class="shadowline" />
<div class="sideinner">
<ul class="tabs">
<li><a href="memcp.php?action=credits">{lang credits}</a></li>
<li><a href="memcp.php?action=usergroups">{lang permission_group_search}</a></li>
<li><a href="task.php">{lang task}</a></li>
<!--{if $medalstatus}--><li><a href="medal.php">{lang medals_list}</a></li><!--{/if}-->
<!--{if $magicstatus}--><li><a href="magic.php">{lang magics_title}</a></li><!--{/if}-->
</ul>
</div>
<!--{/if}-->
<hr class="shadowline" />
<div class="sideinner">
<ul class="tabs">
<li><a href="memcp.php?action=profile&typeid=5">{lang memcp_profile_person}</a></li>
<li><a href="memcp.php?action=profile&typeid=1">{lang memcp_profile_security}</a></li>
</ul>
</div>
<hr class="shadowline" />
<div class="sideinner">
<ul class="tabs">
<li>{lang credits}: $credits</li>
<!--{loop $extcredits $id $credit}-->
<li>
<!--{if $BASESCRIPT == 'invite.php' && $id == $creditstransextra[4] ||
$BASESCRIPT == 'memcp.php' && $id == $creditstrans}-->
$credit[title]: <span style="font-weight: bold;">$GLOBALS['extcredits'.$id]</span> $credit[unit]
<!--{else}-->
$credit[title]: $GLOBALS['extcredits'.$id] $credit[unit]
<!--{/if}-->
</li>
<!--{/loop}-->
</ul>
</div>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/personal_navbar.htm
|
HTML
|
asf20
| 2,739
|
<div class="itemtitle s_clear">
<form method="post" action="member.php?action=list" class="right">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<input type="text" size="15" name="srchmem" class="txt" />
<button type="submit">{lang search}</button>
<!--{if $regstatus > 1}--> <button onclick="window.location='invite.php'; return false;">{lang my_buddylist_invite}</button><!--{/if}-->
</form>
<h1>{lang my_buddylist}</h1>
</div>
<div class="datalist">
<table cellspacing="0" cellpadding="0" class="datatable" style="table-layout:fixed;margin-top:10px;">
<!--{if $buddylist}-->
<tr>
<!--{eval $i=0;}-->
<!--{loop $buddylist $buddy}-->
<!--{eval $i++;}-->
<td valign="top">
<div class="friendavatar"><a href="space.php?uid=$buddy[friendid]" target="_blank">$buddy[avatar]</a></div>
<div class="friendinfo">
<h5 class="buddyname">
<a href="space.php?uid=$buddy[friendid]" target="_blank">$buddy[username]</a>
<!--{if !$buddy[online]}--><img src="{IMGDIR}/online_buddy.gif" title="{lang online}" class="online_buddy" /><!--{/if}-->
<!--{if $buddy['msn'][1]}-->
<a target='_blank' href='http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee={$buddy[msn][1]}@apps.messenger.live.com&mkt=zh-cn' title="{lang msn_chat}"><img class='online_buddy' src='http://messenger.services.live.com/users/{$buddy[msn][1]}@apps.messenger.live.com/presenceimage?mkt=zh-cn' width='16' height='16' /></a>
<!--{/if}-->
</h5>
<p>
<span id="commenthide_$buddy[friendid]">$buddy[comment]</span> <span id="commentedit_$buddy[friendid]">[<a href="javascript:;" onclick="editcomment($buddy[friendid])"><!--{if $buddy[comment]}-->+{lang my_buddylist_comment_edit}<!--{else}-->+{lang my_buddylist_comment_add}<!--{/if}--></a>]</span>
<span id="commentbox_$buddy[friendid]" style="display:none"><input name="comment_$buddy[friendid]" value="$buddy[comment]" id="comment_$buddy[friendid]" class="txt" tabindex="1" onBlur="updatecomment($buddy[friendid])"/ size="30"></span>
</p>
<p class="friendctrl">
<a href="pm.php?action=new&uid=$buddy[friendid]" onclick="floatwin('open_sendpm', this.href, 600, 410);return false;" title="{lang send_pm}">{lang send_pm}</a> |
<!--{if $uchomeurl}--><a href="$uchomeurl/space.php?uid=$buddy[friendid]" target="_blank">{lang my_buddylist_space}</a><!--{else}--><a href="space.php?uid=$buddy[friendid]" target="_blank">{lang memcp_profile}</a><!--{/if}--> |
<a href="search.php?srchuid=$buddy[friendid]&srchfid=all&srchfrom=0&searchsubmit=yes" target="_blank"><!--{if $buddy[gender] == 2}-->{lang she}<!--{else}-->{lang he}<!--{/if}-->{lang my_buddylist_post}</a> |
<a href="my.php?item=buddylist&action=delete&friendid=$buddy[friendid]&buddysubmit=yes">{lang delete}</a>
</p>
</div>
</td>
<!--{if $i%2==0}--></tr><tr><!--{/if}-->
<!--{/loop}-->
</tr>
<!--{else}-->
<tr><th><p class="nodata">{lang my_buddylist_none}</p></th></tr>
<!--{/if}-->
</table>
</div>
$multipage
<script type="text/javascript" reload="1">
function changediv(buddyid) {
display('commenthide_' + buddyid);
display('commentbox_' + buddyid);
display('commentedit_' + buddyid);
}
function editcomment(buddyid) {
changediv(buddyid);
$('comment_' + buddyid).focus();
}
function updatecomment(buddyid) {
changediv(buddyid);
var comment = is_ie && document.charset == 'utf-8' ? encodeURIComponent($('comment_'+ buddyid).value) : $('comment_'+ buddyid).value;
$('commenthide_' + buddyid).innerHTML = preg_replace(['&', '<', '>', '"'], ['&', '<', '>', '"'], comment);
ajaxget('my.php?item=buddylist&action=edit&friendid=' + buddyid + '&buddysubmit=yes&comment=' + comment, 'commnethide_' + buddyid, 'commnethide_' + buddyid);
}
function preg_replace(search, replace, str) {
var len = search.length;
for(var i = 0; i < len; i++) {
re = new RegExp(search[i], "ig");
str = str.replace(re, typeof replace == 'string' ? replace : (replace[i] ? replace[i] : replace[0]));
}
return str;
}
</script>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/my_buddylist.htm
|
HTML
|
asf20
| 4,230
|
{template header}
<!--{if empty($infloat)}-->
{subtemplate header_nofloat}
<!--{/if}-->
<div style="display: none">
<ul id="fs_group">$grouplist</ul>
<ul id="fs_forum_common">$commonlist</ul>
<!--{loop $forumlist $forumid $forum}-->
<ul id="fs_forum_$forumid">$forum</ul>
<!--{/loop}-->
<!--{loop $subforumlist $forumid $forum}-->
<ul id="fs_subforum_$forumid">$forum</ul>
<!--{/loop}-->
</div>
<div class="float" style="width: 600px;">
<div class="floatbox floatbox1">
<h3 class="float_ctrl">
<em>{lang nav}</em>
<span>
<!--{if !empty($infloat)}--><a href="javascript:;" class="float_close" onclick="floatwin('close_nav')" title="{lang close}">{lang close}</a><!--{/if}-->
</span>
</h3>
<div class="postbox">
<p class="s_clear">
<button class="right" id="postbtn" onclick="floatwin('close_nav');floatwin('open_newthread', 'post.php?action=newthread&fid=' + selectfid, 600, 410, '600,0');" disabled="disabled">{lang send_posts}</button>
<button class="right" id="enterbtn" onclick="locationforums(currentblock, currentfid)" disabled="disabled">{lang nav_forum}</button>
<span class="switchnav">$bbname<span id="switchnav"></span></span>
</p>
<ul class="postboardlist s_clear">
<li id="block_group"></li>
<li id="block_forum"></li>
<li id="block_subforum"></li>
</ul>
</div>
</div>
</div>
<script type="text/javascript" reload="1">
var s = '<p><a id="commonforum" href="javascript:;" onclick="switchforums(this, 1, \'common\')" class="hassubboard lightlink">{lang nav_forum_frequently}</a></p>';
var lis = $('fs_group').getElementsByTagName('LI');
for(i = 0;i < lis.length;i++) {
var gid = lis[i].getAttribute('fid');
if($('fs_forum_' + gid)) {
s += '<p><a href="javascript:;" ondblclick="locationforums(1, ' + gid + ')" onclick="switchforums(this, 1, ' + gid + ')" class="hassubboard">' + lis[i].innerHTML + '</a></p>';
}
}
$('block_group').innerHTML = s;
var lastswitchobj = null;
var selectfid = 0;
var switchforum = switchsubforum = '';
switchforums($('commonforum'), 1, 'common');
function switchforums(obj, block, fid) {
if(lastswitchobj != obj) {
if(lastswitchobj) {
lastswitchobj.parentNode.className = '';
}
obj.parentNode.className = 'pbl_selected';
}
var s = '';
if(fid != 'common') {
$('enterbtn').removeAttribute("disabled");
currentblock = block;
currentfid = fid;
} else {
$('enterbtn').setAttribute("disabled", "disabled");
}
if(block == 1) {
var lis = $('fs_forum_' + fid).getElementsByTagName('LI');
for(i = 0;i < lis.length;i++) {
fid = lis[i].getAttribute('fid');
if(fid != '') {
s += '<p><a href="javascript:;" ondblclick="locationforums(2, ' + fid + '\)" onclick="switchforums(this, 2, ' + fid + ')"' + ($('fs_subforum_' + fid) ? ' class="hassubboard"' : '') + '>' + lis[i].innerHTML + '</a></p>';
}
}
$('block_forum').innerHTML = s;
$('block_subforum').innerHTML = '';
switchforum = switchsubforum = '';
selectfid = 0;
$('postbtn').setAttribute("disabled", "disabled");
} else if(block == 2) {
selectfid = fid;
if($('fs_subforum_' + fid)) {
var lis = $('fs_subforum_' + fid).getElementsByTagName('LI');
for(i = 0;i < lis.length;i++) {
fid = lis[i].getAttribute('fid');
s += '<p><a href="javascript:;" ondblclick="locationforums(3, ' + fid + ')" onclick="switchforums(this, 3, ' + fid + ')">' + lis[i].innerHTML + '</a></p>';
}
$('block_subforum').innerHTML = s;
} else {
$('block_subforum').innerHTML = '';
}
switchforum = obj.innerHTML;
switchsubforum = '';
$('postbtn').removeAttribute("disabled");
} else {
selectfid = fid;
switchsubforum = obj.innerHTML;
$('postbtn').removeAttribute("disabled");
}
lastswitchobj = obj;
$('switchnav').innerHTML = switchforum ? ' > ' + switchforum + (switchsubforum ? ' > ' + switchsubforum : '') : '';
}
function locationforums(block, fid) {
location.href = block == 1 ? '$indexname?gid=' + fid : 'forumdisplay.php?fid=' + fid;
}
</script>
<!--{if empty($infloat)}-->
{subtemplate footer_nofloat}
<!--{/if}-->
{template footer}
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/post_forumselect.htm
|
HTML
|
asf20
| 4,192
|
<table cellspacing="0" cellpadding="0" class="datatable">
<thead class="colplural">
<tr>
<th> </th>
<td class="forum">{lang forum}</td>
<td class="nums">
<select onchange="window.location=this.value">
<option value="">{lang status}</option>
<option value="recyclebin"<!--{if $filter == 'recyclebin'}--> selected="selected"<!--{/if}-->>{lang forum_recyclebin}</option>
<option value="aduit"<!--{if $filter == 'aduit'}--> selected="selected"<!--{/if}-->>{lang my_threads_aduit}</option>
<option value="close"<!--{if $filter == 'close'}--> selected="selected"<!--{/if}-->>{lang my_threads_close}</option>
<option value="common"<!--{if $filter == 'common'}--> selected="selected"<!--{/if}-->>{lang my_threads_common}</option>
</option>
</td>
<td class="lastpost"><cite><!--{if $type == 'orig'}-->{lang lastpost}<!--{else}-->{lang debate_dateline}<!--{/if}--></cite></td>
</tr>
</thead>
<!--{if $debatelist}-->
<tbody>
<!--{loop $debatelist $key $debate}-->
<tr>
<th><a href="viewthread.php?tid=$debate[tid]" target="_blank">$debate[subject]</a></th>
<td class="forum"><a href="forumdisplay.php?fid=$debate[fid]" target="_blank">$debate[forumname]</a></td>
<td class="nums"><!--{if $debate[displayorder] == '-1'}-->{lang forum_recyclebin}<!--{elseif $debate[displayorder] == '-2'}-->{lang my_threads_aduit}<!--{elseif $debate[closed] == '1'}-->{lang my_threads_close}<!--{else}-->{lang my_threads_common}<!--{/if}--></td>
<td class="lastpost">
<!--{if $type == 'orig'}-->
<cite><!--{if $debate['lastposter']}--><a href="space.php?username=$debate[lastposterenc]" target="_blank">$debate[lastposter]</a><!--{else}-->{lang anonymous}<!--{/if}--></cite>
<em><a href="redirect.php?tid=$debate[tid]&goto=lastpost#lastpost" target="_blank">$debate[lastpost]</a></em>
<!--{else}-->
<cite>$debate[dateline]</cite>
<!--{/if}-->
</td>
</tr>
<!--{/loop}-->
</tbody>
<!--{else}-->
<tr><th colspan="4"><p class="nodata">{lang data_nonexistence}</p></th></tr>
<!--{/if}-->
</table>
<!--{if !empty($multipage)}--><div class="pages_btns">$multipage</div><!--{/if}-->
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/my_debate.htm
|
HTML
|
asf20
| 2,230
|
<?php
// Message Pack for Discuz! WAP Version 1.0.0
// Created by Crossday
$lang = array
(
'username' => '用户名',
'password' => '密码',
'submit' => '提交',
'page' => '页',
'replies' => '回',
'views' => '点',
'reply' => '回复',
'delete' => '删除',
'anonymous' => '匿名',
'forum' => '版块',
'from' => '来自:',
'type' => '分类:',
'subject' => '标题:',
'message' => '内容:',
'home_page' => '首页',
'last_page' => '上页',
'next_page' => '下页',
'end_page' => '尾页',
'turn_page' => '翻页',
'next_thread' => '下一主题',
'last_thread' => '上一主题',
'end' => '结束',
'unread' => '未读',
'sub_forums' => '子版块',
'email' => '电子邮件',
'more' => '更多',
'search' => '搜索',
'digest' => '精华',
'reload' => '刷新',
'author' => '作者:',
'dateline' => '时间:',
'return' => '返回',
'keywords' => '关键词',
'not_loggedin' => '请登录后使用本功能',
'wap_disabled' => 'WAP 功能未启用',
'board_closed' => '论坛目前临时关闭',
'undefined_action' => '未定义操作',
'home_online' => '在线人数:',
'home_members' => '会员',
'home_newpm' => '条新短消息',
'home_forums' => '论坛版块',
'home_tools' => '工具箱',
'home_newthreads' => '查看新帖',
'login' => '登录',
'login_username' => '用户名/UID',
'login_succeed' => '{$discuz_user}成功登录',
'login_strike' => '累计5次密码错误,15分钟内不能登录',
'login_invalid' => '用户名或密码有误,您共有5次尝试机会',
'logout' => '退出',
'logout_succeed' => '成功退出登录',
'security_question' => '安全提问',
'security_answer' => '回答',
'security_question_0' => '无安全提问',
'security_question_1' => '母亲的名字',
'security_question_2' => '爷爷的名字',
'security_question_3' => '父亲出生的城市',
'security_question_4' => '您其中一位老师的名字',
'security_question_5' => '您个人计算机的型号',
'security_question_6' => '您最喜欢的餐馆名称',
'security_question_7' => '驾驶执照的最后四位数字',
'register' => '注册',
'register_username' => '用户名',
'register_disable' => '此论坛禁止通过WAP注册',
'register_reason' => '注册原因',
'register_ctrl' => '对不起,您的 IP 地址在 $regctrl 小时内只能注册一个帐号,请返回。',
'register_flood_ctrl' => '对不起,同一 IP 地址在 24 小时内只能进行 $regfloodctrl 次注册尝试,请返回。',
'register_manual_verify' => '非常感谢您的注册,管理员设置了人工验证新注册用户,请等待审核通过,现在将转入控制面板首页。',
'register_succeed' => '非常感谢您的注册,现在将以会员身份登录论坛。',
'activation_disable' => '此论坛禁止通过WAP激活',
'register_activation_message' => '对不起,您输入的用户名 \"$username\" 已经存在,请登录论坛激活此帐号<br /><a href=\"index.php?action=login\">登录论坛</a>',
'profile_username_duplicate' => '该用户名已经被注册,请返回重新填写。',
'profile_email_duplicate' => '该 Email 地址已经被注册,请返回重新填写。',
'profile_username_illegal' => '用户名包含敏感字符,请返回重新填写。',
'profile_username_protect' => '用户名包含被系统屏蔽的字符,请返回重新填写。',
'profile_email_illegal' => 'Email 地址无效,请返回重新填写。',
'profile_email_domain_illegal' => 'Email 包含不可使用的邮箱域名,请返回重新填写。',
'fav_add_succeed' => '已成功添加到收藏夹中,请返回。',
'fav_existence' => '您过去已经收藏过这个主题或者版块,请返回。',
'goto_last_nonexistence' => '没有比这个主题更早的主题了',
'goto_next_nonexistence' => '没有比这个主题更晚的主题了',
'forum_thread_sticky' => '[顶]',
'forum_thread_digest' => '[精]',
'forum_nopermission' => '无权访问本版块',
'forum_nonexistence' => '指定版块不存在',
'forum_list' => '帖子列表',
'forum_sublist' => '子版块列表',
'my' => '我的',
'my_uid' => 'UID:',
'my_username' => '用户名:',
'my_gender' => '性别:',
'my_bday' => '生日:',
'my_location' => '来自:',
'my_bio' => '自我介绍:',
'my_phone' => '我的手机',
'my_favorites' => '我的收藏',
'my_addfav' => '设为我的收藏',
'my_nonexistence' => '该用户不存在',
'my_male' => '男',
'my_female' => '女',
'my_secrecy' => '保密',
'my_threads' => '我的主题',
'my_replies' => '我的回复',
'my_fav_thread' => '我收藏的主题',
'my_fav_forum' => '我收藏的版块',
'thread_nopermission' => '无权查看本主题',
'thread_nonexistence' => '指定主题不存在',
'thread_replylist' => '回复列表',
'thread_reply' => '回复主题:',
'thread_quickreply' => '快速回复',
'post_reply' => '回复本帖',
'post_new' => '发新话题',
'post_sm_isnull' => '未填写标题或内容',
'post_subject_toolong' => '标题超过80字节',
'post_message_toolong' => '内容超过{$maxpostsize}字节限制',
'post_message_tooshort' => '内容少于{$minpostsize}字节限制',
'post_type_isnull' => '未选择主题分类',
'post_flood_ctrl' => '两次发表少于{$floodctrl}秒',
'post_mod_succeed' => '成功提交人工审核',
'post_mod_forward' => '回到当前论坛',
'post_thread_closed' => '本主题已关闭',
'post_thread_closed_by_dateline' => '本主题发布于$forum[autoclose]天前<br />已被自动关闭',
'post_thread_closed_by_lastpost' => '本主题最后回复于$forum[autoclose]天前<br />已被自动关闭',
'post_newbie_span' => '注册{$newbiespan}小时后才可发帖',
'post_hide_nopermission' => '无权使用[hide]代码',
'post_newthread_nopermission' => '无权在本论坛发新话题',
'post_newthread_succeed' => '主题发表成功<br /><a href=\"index.php?action=forum&fid=$fid\">返回论坛</a>',
'post_newthread_forward' => '查看主题',
'post_newreply_nopermission' => '无权在本论坛发表回复',
'post_newreply_succeed' => '主题回复成功<br /><a href=\"index.php?action=forum&fid=$fid\">返回论坛</a>',
'post_newreply_forward' => '查看回复',
'profile_username_toolang' => '对不起,您的用户名超过 15 个字符,请返回输入一个较短的用户名。',
'profile_username_tooshort' => '对不起,您输入的用户名小于3个字符, 请返回输入一个较长的用户名。',
'profile_passwd_notmatch' => '两次输入的密码不一致,请返回检查后重试。',
'profile_passwd_illegal' => '密码空或包含非法字符,请返回重新填写。',
'profile_email_verify' => '确认 Email 已经发送,请用邮件中提供的方法激活您的帐号。如果您没有收到我们发送的系统邮件,请点击控制面板首页中的“重新验证 Email 有效性”,或尝试更换另外一个地址。注意:在完成激活之前,根据管理员设置,您将只能以等验证会员的身份访问论坛,您可能不能进行发帖等操作。激活成功后,上述限制将自动取消。',
'pm' => '短消息',
'pm_home' => '短消息首页',
'pm_list' => '短消息列表',
'pm_unread' => '未读消息',
'pm_all' => '全部消息',
'pm_send' => '发送短消息',
'pm_to' => '收信人',
'pm_delete_all' => '删除已读短信',
'pm_flood_ctrl' => '两次发表少于{$floodctrl}秒',
'pm_delete_confirm' => '确认删除所有已读短信',
'pm_sm_isnull' => '未填写标题或内容',
'pm_nonexistence' => '短消息不存在',
'pm_send_nonexistence' => '收信人不存在',
'pm_send_ignore' => '收件人拒收短消息',
'pm_send_succeed' => '短消息成功发送',
'pm_delete_succeed' => '短消息成功删除',
'return_thread' => '返回主题',
'return_forum' => '返回版块',
'stats' => '论坛统计',
'stats_threads' => '主题数',
'stats_posts' => '帖子数',
'stats_members' => '会员数',
'search' => '论坛搜索',
'search_result' => '搜索结果',
'search_invalid' => '您没有指定要搜索的关键字或用户名,请返回重新填写。',
'search_ctrl' => '对不起,您在 $searchctrl 秒内只能进行一次搜索,请返回。',
'search_id_invalid' => '您指定的搜索不存在或已过期,请返回。',
'search_group_nopermission' => '您所在的用户组没有搜索权限,请返回',
'goto' => 'WAP跳转',
'wap_submit_invalid' => '验证信息不正确',
'post_hide_reply_hidden' => '本内容隐藏',
'register_invite' => '论坛开启邀请码注册,请通过WWW方式注册',
);
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/wap.lang.php
|
PHP
|
asf20
| 8,845
|
{template header}
<!--{if empty($infloat)}-->
{subtemplate header_nofloat}
<!--{/if}-->
<div class="float">
<div class="floatbox">
<h3 class="float_ctrl">
<em id="return_$handlekey">{lang pay}</em>
<span>
<!--{if !empty($infloat)}--><a href="javascript:;" class="float_close" onclick="floatwin('close_$handlekey')" title="{lang close}">{lang close}</a><!--{/if}-->
</span>
</h3>
<form id="payform" method="post" action="misc.php?action=pay&paysubmit=yes&infloat=yes" onsubmit="ajaxpost('payform', 'return_$handlekey', 'return_$handlekey', 'onerror');return false;">
<input type="hidden" name="formhash" value="{FORMHASH}" />
<!--{if !empty($infloat)}--><input type="hidden" name="handlekey" value="$handlekey" /><!--{/if}-->
<table class="list" cellspacing="0" cellpadding="0">
<tr>
<th>{lang author}:</th>
<td><a href="space.php?uid=$thread[authorid]" target="_blank">$thread[author]</a></td>
</tr>
<tr>
<th valign="top">{lang price}({$extcredits[$creditstransextra[1]][title]}):</th>
<td>$thread[price] {$extcredits[$creditstransextra[1]][unit]}</td>
</tr>
<tr>
<th valign="top">{lang pay_author_income}({$extcredits[$creditstransextra[1]][title]}):</th>
<td>$thread[netprice] {$extcredits[$creditstransextra[1]][unit]}</td>
</tr>
<tr>
<th valign="top">{lang pay_balance}({$extcredits[$creditstransextra[1]][title]}):</th>
<td>$balance {$extcredits[$creditstransextra[1]][unit]}</td>
</tr>
<tr class="btns">
<th> </th>
<td>
<input type="hidden" name="tid" value="$tid" />
<button class="submit" type="submit" name="paysubmit" value="true">{lang submit}</button>
</td>
</tr>
</table>
</form>
</div>
</div>
<!--{if !empty($infloat)}-->
<script type="text/javascript" reload="1">
function submithandle_$handlekey(locationhref) {
ajaxget('viewthread.php?tid=$tid&viewpid=$pid', 'post_$pid');
floatwinreset = 1;
floatwin('close_$handlekey');
}
</script>
<!--{/if}-->
<!--{if empty($infloat)}-->
{subtemplate footer_nofloat}
<!--{/if}-->
{template footer}
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/pay.htm
|
HTML
|
asf20
| 2,100
|
<!--{if $action == 'list' && $catlist && $forumlist}-->
<!--{loop $catlist $catid $cat}-->
document.write('<div class="mainbox list">'+
' <h3><a href="javascript:;">');
<!--{if $cat[logo]}-->document.write('<img src="$cat[logo]" style="float: left; height: 30px; margin-right: 10px" alt="" border="0" />');<!--{/if}-->
document.write('$cat[name]</a></h3>'+
' <table cellspacing="0" cellpadding="0">');
<!--{loop $forumlist[$catid] $forum}--><!--{eval $cid = $forum[cid];}-->
document.write(' <tbody>'+
' <tr>'+
' <th class="new">'+
' <a href="campaign.php?action=view&cid=$cid">');
<!--{if $forum[logo]}-->document.write('<img src="$forum[logo]" style="margin-right: 10px" align="left" alt="" border="0" />');<!--{/if}-->
document.write('</a>'+
' <h2><a href="campaign.php?action=view&cid=$cid">$forum[name]</a></h2>');
<!--{if $forum[description]}-->document.write('<p>$forum[description]</p>');<!--{/if}-->
document.write(' </th>'+
' <td class="forumnums">{if $forum[threads]}<em>$forum[threads]</em>{else}--{/if} / {if $forum[posts]}$forum[posts]{else}--{/if}</td>'+
' <td class="forumlast">{if $forum[lastpost]}<p><a href="campaign.php?action=view&cid=$cid&tid=$forum[lp][tid]">{echo cutstr($forum[lp][subject], 40)}</a></p><cite>{lang forum_lastpost_by} <a href="campaign.php?action=view&cid=$cid&tid=$forum[lp][tid]">$forum['lp']['author']</a> - $forum[lp][dateline]</cite>{else}--{/if}</td>'+
' </tr>'+
' </tbody>');
<!--{/loop}-->
document.write(' </table>'+
'</div>');
<!--{/loop}-->
<!--{elseif $action == 'view'}-->
{subtemplate header}
<center><iframe id="iframe" width="100%" align="center" height="1024" frameborder="0" scrolling="no" src="$iframeurl"></iframe><br /><br /></center>
<script type="text/javascript">
function resetheight() {
var ih = getcookie('ih4_$cid');
if(ih && $('iframe').style.height != ih) {
if(is_ie) {
$('iframe').style.height = ih;
} else {
$('iframe').height = ih;
}
}
}
setInterval(resetheight, 500);
</script>
<!--{if $update}-->
<script type="text/javascript" src="api/advcache.php?type=4&cid=$cid"></script>
<!--{/if}-->
{subtemplate footer}
<!--{/if}-->
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/campaign.htm
|
HTML
|
asf20
| 2,278
|
<script type="text/javascript" src="include/js/video.js?{VERHASH}"></script>
<!--{if $videocount > 1}-->
<div class="tradectrl">
<em>{lang video_num}: $videocount</em>
<!--{if $forum['ismoderator'] || $thread[authorid] == $discuz_uid}-->
<a href="post.php?infloat=yes&action=edit&fid=$fid&tid=$tid&pid=$post[pid]" onclick="floatwin('open_edit', this.href, 600, 410, '600,0');doane(event);return false;">{lang video_edit_add}</a>
<!--{/if}-->
</div>
<!--{/if}-->
<div class="videobox">
<!--{if $videocount >= 1}-->
<div class="box videolist">
<ul class="tradethumblist">
<!--{loop $videolist $video}-->
<li <!--{if $video[vid] == $vid}--> class="onplay"<!--{/if}-->>
<!--{if $vid == $video[vid]}-->
<div class="treadbox">
$videoshow
<div class="videoaddr">{lang video_playurl}<input type="text" id="playurl" value="{$boardurl}viewthread.php?tid=$tid<!--{if !$videosource}-->&vid=$vid<!--{/if}-->" size="52" onclick="this.select();setcopy(this.value, '{lang playurl_copied}');"> <a href="javascript:;" onclick="$('playurl').select('');setcopy($('playurl').value, '{lang playurl_copied}');">[{lang copy}]</a></div>
</div>
<!--{else}-->
<div class="treadbox">
<dl>
<dt class="thumblist"><a href="viewthread.php?tid=$tid&vid=$video[vid]&autoplay=1"><img src="$video[vthumb]" width="96" height="80"></a></dt>
<dd>
<em class="infoview"><a href="viewthread.php?tid=$tid&vid=$video[vid]&autoplay=1">{lang open}</a></em>
<h2 class="videoname">$video[vtitle]</h2>
<p>{lang video_time}: $video[vtime]</p>
<p>{lang video_views}: $video[vview]<!--{if $video[vid] == $vid}--><em>{lang video_play}</em><!--{/if}--></p>
</dd>
</dl>
</div>
<!--{/if}-->
</li>
<!--{/loop}-->
</ul>
</div>
<!--{/if}-->
</div>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/viewthread_video.htm
|
HTML
|
asf20
| 1,860
|
{template header}
<b>$member[useip]</b> $member[iplocation]
<!--{if $allowviewip}-->
<br /><a href="admincp.php?action=members&operation=ipban&ip=$member[useip]&frames=yes" target="_blank" class="lightlink">{lang admin_ban_this_ip}</a>
<!--{/if}-->
{template footer}
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/topicadmin_getip.htm
|
HTML
|
asf20
| 274
|
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=$charset" />
<title>$bbname</title>
<style type="text/css">
body { background-color: #FFF; color: #000; font-family: Verdana, Tahoma; font-size: 12px; margin: 20px; padding: 0px; }
#largetext { font-size: 18px; font-weight: bold; margin-bottom: 10px; padding-top: 3px; width: auto; }
#userinfo { font-size: 12px; color: #888; text-align: right; width: auto; }
#copyright { margin-top: 30px; font-size: 11px; text-align: center; }
.wrapper { }
.pm { color: #000; padding: 10px; margin-top:10px; border: 1px solid #888; }
.content { color: #888; }
.msgborder { margin: 2em; margin-top: 3px; padding: 10px; border: 1px solid #888; word-break: break-all; }
.quote { margin: 10px 0; padding: 10px 10px 10px 5px; border: 1px solid #CCC; }
.blockcode { margin: 10px 0; padding: 10px 10px 10px 25px; border: 1px solid #CCC; }
</style>
</head>
<body>
<div id="wrapper">
<div id="largetext">{lang pm_archive}</div>
<div id="userinfo"><a href="{$boardurl}space.php?uid=$discuz_uid" target="_blank">$discuz_userss @ $timenow[time]</a></div>
<br />
<!--{loop $pmlist $pm}-->
<div class="pm">
<strong><!--{if $pm[msgfromid] != $discuz_uid}-->$pm[msgfrom]<!--{else}-->$discuz_userss<!--{/if}--></strong> $pm[dateline]:<br />
<br />
<div class="content">$pm[message]</div>
</div>
<!--{/loop}-->
</div>
<div id='copyright'>
Powered by <strong><a href="http://www.discuz.net" target="_blank">Discuz!</a> $version</strong></a>
© 2001-2006 <a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>
</div>
</body>
</html>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/pm_archive_html.htm
|
HTML
|
asf20
| 1,661
|
{subtemplate header}
<div id="nav"><a href="$indexname">$bbname</a> » {lang magics_index}</div>
<div id="wrap" class="wrap with_side s_clear">
<div class="main">
<div class="content">
<h1>{lang magics_index}</h1>
<!--{if !$magicstatus && $adminid == 1}-->
<div class="channelinfo">{lang magics_tips}</div>
<!--{/if}-->
<div id="list_magics_mine_c" class="c_header">
<h3 onclick="toggle_collapse('list_magics_mine', 1, 1);">{lang magics_user}</h3>
<div class="c_header_action">
<p class="c_header_ctrlbtn" onclick="toggle_collapse('list_magics_mine', 1, 1);">[ {lang open} ]</p>
</div>
</div>
<div id="list_magics_mine" class="mymagic">
<!--{if $magicsdiscount || $maxmagicsweight}-->
<!--{if $magicsdiscount}-->
<p>{lang magics_discount}: $magicsdiscount {lang discount}</p>
<!--{/if}-->
<!--{if $maxmagicsweight}-->
<p>{lang magics_capacity}: $totalweight/$maxmagicsweight <a href="magic.php?action=log&operation=uselog" class="lightlink">{lang magics_view_logs}</a></p>
<!--{/if}-->
<!--{/if}-->
<ul class="inlinelist s_clear">
<!--{if $mymagiclist}-->
<!--{eval $i=0;}-->
<!--{loop $mymagiclist $key $mymagic}-->
<li>
<div class="magicimg"><img src="images/magics/$mymagic[pic]" alt="$mymagic[name]" /></div>
<div class="magicdetail">
<h5>$mymagic[name]</h5>
<p>$mymagic[description]</p>
<p>{lang magics_num}: $mymagic[num] {lang magics_user_totalnum}: $mymagic[weight]</p>
<p>
<a href="magic.php?action=index&operation=use&magicid=$mymagic[magicid]" onclick="floatwin('open_magics', this.href, 250, 215);return false;"><strong>{lang magics_operation_use}</strong></a> |
<!--{if $allowmagics > 1}-->
<a href="magic.php?action=index&operation=give&magicid=$mymagic[magicid]" onclick="floatwin('open_magics', this.href, 250, 165);return false;">{lang magics_operation_present}</a> |
<!--{/if}-->
<a href="magic.php?action=index&operation=drop&magicid=$mymagic[magicid]" onclick="floatwin('open_magics', this.href, 250, 165);return false;">{lang magics_operation_drop}</a> |
<!--{if $magicmarket && $allowmagics > 1}-->
<a href="magic.php?action=index&operation=sell&magicid=$mymagic[magicid]" onclick="floatwin('open_magics', this.href, 250, 165);return false;">{lang magics_operation_sell}</a>
<!--{/if}-->
</p>
</div>
</li>
<!--{if $i%2}--><li class="clear"></li><!--{/if}-->
<!--{eval $i++;}-->
<!--{/loop}-->
<!--{if !empty($mymultipage)}--><li class="clear"><div class="pages_btns">$mymultipage</div></li><!--{/if}-->
<!--{else}-->
<li class="clear">{lang data_nonexistence}</li>
<!--{/if}-->
</ul>
</div>
<div class="datalist">
<div id="list_magics_shop_c" class="c_header">
<h3 onclick="toggle_collapse('list_magics_shop', 1, 1);">{lang magics_shop}</h3>
<div class="c_header_action">
<p class="c_header_ctrlbtn" onclick="toggle_collapse('list_magics_shop', 1, 1);">[ {lang open} ]</p>
</div>
</div>
<div id="list_magics_shop">
<table summary="{lang magics_shop}" cellspacing="0" cellpadding="0" class="datatable">
<!--{if $magiclist}-->
<tr class="colplural">
<th></th>
<th></th>
<th>{lang magics_price} ($extcredits[$creditstransextra[3]][title])</th>
<th>
<select onchange="window.location=this.value">
<option value="magic.php?action=index"<!--{if empty($typeid)}--> selected="selected"<!--{/if}-->>{lang types}</option>
<option value="magic.php?action=index&typeid=1"<!--{if $typeid==1}--> selected="selected"<!--{/if}-->>{lang magics_type_1}</option>
<option value="magic.php?action=index&typeid=2"<!--{if $typeid==2}--> selected="selected"<!--{/if}-->>{lang magics_type_2}</option>
<option value="magic.php?action=index&typeid=3"<!--{if $typeid==3}--> selected="selected"<!--{/if}-->>{lang magics_type_3}</option>
</select>
</th>
<th>{lang magics_shop_num}</th>
<th>{lang magics_weight}</th>
<th>{lang magics_shop_salevolume}</th>
<th></th>
</tr>
<!--{loop $magiclist $key $magic}-->
<tr class="{echo swapclass('colplural')}">
<td width="9%"><h4>$magic[name]</h4></td>
<td>$magic[description]</td>
<td width="12%"><strong>$magic[price]</strong></td>
<td width="6%">$magic[type]</td>
<td width="6%">$magic[num]</td>
<td width="6%">$magic[weight]</td>
<td width="6%"><!--{if $magic[salevolume]}-->$magic[salevolume]<!--{else}-->0<!--{/if}--></td>
<td width="8%"><a href="magic.php?action=index&operation=buy&magicid=$magic[magicid]" onclick="floatwin('open_magics', this.href, 250, 365);return false;">{lang magics_operation_buy}</a></td>
</tr>
<!--{/loop}-->
<!--{else}-->
<tr><td>{lang magics_shop_nonexistence}</td></tr>
<!--{/if}-->
</table>
<!--{if !empty($multipage)}--><div class="pages_btns s_clear">$multipage</div><!--{/if}-->
</div>
<div class="c_header">
<h3 class="noarrow"><a href="magic.php?action=market">{lang magics_market}</a></h3>
</div>
</div>
</div>
</div>
<div class="side">
{subtemplate personal_navbar}
</div>
</div>
{subtemplate footer}
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/magic_index.htm
|
HTML
|
asf20
| 5,658
|
#modlayer { position: absolute; right: 0; padding: 12px; width: 275px; background-color: #FFF; border: 4px solid #7FCAE2; }
#modlayer a { color: #09C; }
#modlayer label { float: right; margin-top: 5px; }
#modcount { padding: 0 2px; font-size: 24px; font-weight: 400; color: #F60; }
#modlayer .collapse { position: absolute; right: 0; top: 5px; padding: 0 5px; }
#modlayer.collapsed { margin-right: -23px; padding: 0; width: 27px; height: 35px; border: none; background: #F60; overflow: hidden; }
#modlayer.collapsed #modcount { display: block; position: absolute; left: 0; top: 0; z-index: 999; width: 27px; height: 35px; border-color: #09C; background-color: #09C; color: #FFF; font-size: 12px; text-align: center; line-height: 35px; cursor: pointer; }
.listtopicadmin { height: 200px; border-top: 1px solid #C5DAEB; }
.listtopicadmin li { *overflow:hidden; *margin-bottom: -2px; height: 28px; line-height: 18px; border-top: 1px solid #FFF; border-bottom: 1px solid #C5DAEB; zoom: 1; }
.listtopicadmin .currentopt { height: auto; }
.detailopt { visibility: hidden; overflow: hidden; white-space: nowrap; }
.currentopt .detailopt { visibility: visible; }
.detailopt p .txt { width: 100px; }
.detailopt span .txt { width: 18px; border-right: none; }
.detailopt a { float: left; text-indent: -999px; margin-right: 3px; width: 22px; height: 20px; text-align: center; }
.detailopt_bold, .detailopt_italic, .detailopt_underline { border: 1px solid #F1F5FA; outline: none; }
.detailopt .current { border: 1px solid #999; background-color: #FFF; }
.listtopicadmin table { width: 100%; }
.listtopicadmin td { vertical-align: top; }
.listtopicadmin .labeltxt { display: block; cursor: pointer; width: 100%; background: url({IMGDIR}/arrow_down.gif) no-repeat 100% 8px; }
.currentopt .labeltxt { float: left; cursor: default; width: 45px; background: none; color: #09C; }
.listtopicadmin .checkbox { margin-top: 3px; *margin-top: -2px; }
.listtopicadmin img { vertical-align: middle; }
.tah_fixiesel { overflow: hidden; white-space: nowrap; width: 217px; *border-right: 1px solid {INPUTBORDER}; }
.tah_fixiesel select { width: 160px; *width: expression(this.offsetWidth > 180 ? 'auto':'180'); }
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/css_topicadmin.htm
|
HTML
|
asf20
| 2,259
|
<table cellspacing="0" cellpadding="0" summary="{lang my_polls}" class="datatable">
<thead class="colplural">
<tr>
<th> </th>
<td class="forum">{lang forum}</td>
<td class="nums">
<select onchange="window.location='my.php?item=polls&filter=' + this.value + '$fidadd'">
<option value="">{lang status}</option>
<option value="recyclebin"<!--{if $filter == 'recyclebin'}--> selected="selected"<!--{/if}-->>{lang forum_recyclebin}</option>
<option value="aduit"<!--{if $filter == 'aduit'}--> selected="selected"<!--{/if}-->>{lang my_threads_aduit}</option>
<option value="close"<!--{if $filter == 'close'}--> selected="selected"<!--{/if}-->>{lang my_threads_close}</option>
<option value="common"<!--{if $filter == 'common'}--> selected="selected"<!--{/if}-->>{lang my_threads_common}</option>
</option>
</td>
<td class="lastpost"><cite><!--{if $type == 'poll'}-->{lang lastpost}<!--{else}-->{lang poll_dateline}<!--{/if}--></cite></td>
</tr>
</thead>
<!--{if $polllist}-->
<tbody>
<!--{loop $polllist $key $poll}-->
<tr>
<th><a href="viewthread.php?tid=$poll[tid]" target="_blank">$poll[subject]</a></th>
<td class="forum"><a href="forumdisplay.php?fid=$poll[fid]" target="_blank">$poll[forumname]</a></td>
<td class="nums"><!--{if $poll[displayorder] == '-1'}-->{lang forum_recyclebin}<!--{elseif $poll[displayorder] == '-2'}-->{lang my_threads_aduit}<!--{elseif $poll[closed] == '1'}-->{lang my_threads_close}<!--{else}-->{lang my_threads_common}<!--{/if}--></td>
<td class="lastpost">
<!--{if $type == 'poll'}-->
<cite><!--{if $poll['lastposter']}--><a href="space.php?username=$poll[lastposterenc]" target="_blank">$poll[lastposter]</a><!--{else}-->{lang anonymous}<!--{/if}--></cite>
<em><a href="redirect.php?tid=$poll[tid]&goto=lastpost#lastpost" target="_blank">$poll[lastpost]</a></em>
<!--{else}-->
<cite>$poll[dateline]</cite>
<!--{/if}-->
</td>
</tr>
<!--{/loop}-->
</tbody>
<!--{else}-->
<tr><th colspan="4"><p class="nodata">{lang data_nonexistence}</p></th></tr>
<!--{/if}-->
</table>
<!--{if !empty($multipage)}--><div class="pages_btns">$multipage</div><!--{/if}-->
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/default/my_polls.htm
|
HTML
|
asf20
| 2,264
|
#header .wrap { padding: 0; height: 244px; background: url({STYLEIMGDIR}/header.gif) no-repeat 0 100%; }
#header h2 { width: 630px; height: 230px; background: url({STYLEIMGDIR}/xmas.gif) no-repeat 100% 100%; }
#ad_headerbanner { position: absolute; right: 0; top: 35px; }
#umenu { top: 5px; padding-right: 10px; background: url({STYLEIMGDIR}/umenu.gif) no-repeat 100% 0; line-height: 30px; }
#umenu a.noborder { float: left; margin-left: -10px; padding-left: 10px; display: inline; background: url({STYLEIMGDIR}/umenu.gif) no-repeat 0 -30px; }
* html #umenu a.noborder { margin-left: 0; background-position: 0 100%; }
#umenu a { margin: 0 2px; }
#umenu .pipe { margin: 0 2px; color: #FAABA4; }
#menu { right: 15px; bottom: 4px; padding-right: 11px; height: 36px; background: #DC4F57 url({STYLEIMGDIR}/menu.gif) no-repeat 100% -36px; }
#menu li { margin: 0; padding-left: 1px; background: url({STYLEIMGDIR}/menu.gif) no-repeat 0 -72px; }
#menu a { height: 36px; border: none; line-height: 36px; }
#menu li a:hover, #menu li.current a { height: 36px; background-color: transparent; color: #A11A18; }
#menu a#mn_index { margin-left: -1px; padding-left: 25px; background: url({STYLEIMGDIR}/menu.gif) no-repeat 0 0; }
#style_switch { bottom: -22px; right: 15px; }
#nav { height: 31px; background: url({STYLEIMGDIR}/nav.gif) no-repeat 0 0; line-height: 31px; text-indent: 40px; }
.shadowline { border-top-color: #F7C2C2; }
#wrap, #ad_text { w\idth: 960px; border: solid #DC4F57; border-width: 0 4px; }
#ad_text { margin-bottom: 0; background: #FFF; }
#wrap { border-bottom-width: 4px; }
.content { background: url({STYLEIMGDIR}/content_snow.gif) repeat-x 0 0; }
.side { background: url({STYLEIMGDIR}/side_snow.gif) no-repeat 0 -31px; }
.special .side { background: url({STYLEIMGDIR}/content_snow.gif) repeat-x 0 0; }
#sidebar_img.collapsed_no { margin: 0; padding: 6px 30px 6px 0; width: 180px; w\idth: 150px; background: url({STYLEIMGDIR}/side_snow.gif) no-repeat 0 0; text-align: right; }
#sidebar_img.collapsed_no:hover { background-position: 0 0 !important; }
.list { border-top-width: 1px; }
.list h3 { border-top: 1px solid {WRAPBG}; background: {SPECIALBG}; }
.list th { background-image: url({STYLEIMGDIR}/forum.gif); }
.list th.new { background-image: url({STYLEIMGDIR}/forum_new.gif); }
.postbtn, .replybtn { background-image: url({STYLEIMGDIR}/post.gif); }
.replybtn { background-position: 0 -30px; }
#rightinfo { padding-left: 45px; background: url({STYLEIMGDIR}/footer.gif) no-repeat 0 50%; }
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/xmas/css_append.htm
|
HTML
|
asf20
| 2,573
|
html { background: #55616A url({STYLEIMGDIR}/wrapbg.gif) repeat 0 270px; }
#header, #header .wrap { padding: 0; height: 99px; }
#header h2, #ad_headerbanner { margin-top:24px; }
#footer, #footer a { color: #D0D5D8; }
#menu { bottom: 2px; }
#menu li { padding-left: 5px; background: #957353 url({STYLEIMGDIR}/menu.gif) no-repeat 0 0; }
#menu li a { padding-left: 9px; border: none; background: #55616A url({STYLEIMGDIR}/menu.gif) no-repeat 100% 0; }
#menu li.current { background-position: 0 -25px; }
#menu li.current a { background-position: 100% -25px; color: #FFF; }
#menu li a.dropmenu { background: #55616A url({STYLEIMGDIR}/menu.gif) no-repeat 100% -50px; }
#menu li.current a.dropmenu { background: #55616A url({STYLEIMGDIR}/menu.gif) no-repeat 100% -100px; }
#menu li a:hover { color: #D0D5D8; }
#nav { background-image: url({STYLEIMGDIR}/nav.gif); text-indent: 30px; }
.postbtn, .replybtn { width: 62px; height: 32px; background-image: url({STYLEIMGDIR}/post.gif); line-height: 32px; }
.replybtn { background-image: url({STYLEIMGDIR}/reply.gif); }
.replybtn a { color: #5F2F2C; }
#wrap { background: #DAD6C5 url({STYLEIMGDIR}/content.jpg) repeat-y 0 0; }
#wrap.with_side { background-position: 100% 0; }
.list, .mainbox .adcontent, .mainbox table .threadad td.postauthor, .colplural, .colplural th, .colplural td { background: url({STYLEIMGDIR}/title.gif) repeat-x 0 0; }
.list th { background-image: url({STYLEIMGDIR}/forum.gif); }
.list th.new { background-image: url({STYLEIMGDIR}/forum_new.gif); }
.shadowline { border-top-color: #C1B79E; border-bottom-color: #DAD6C5; }
.mainbox table td.postauthor, .forumcontrol table .modaction { background: #DAD6C5 url({STYLEIMGDIR}/author.jpg) repeat-y 100% 0; }
.forumcontrol table { background: transparent !important; }
.forumcontrol table.narrow td { padding-top: 10px; }
.signatures { background-image: url({STYLEIMGDIR}/sign.gif) !important; }
.content { background: none!important; }
.blockcode { border: none !important; background: transparent url({STYLEIMGDIR}/code.jpg) repeat-y 5px 0 !important; }
.blockcode ol li:hover { background: transparent !important; }
.quote { background: #C7C3B1 url({STYLEIMGDIR}/quote1.gif) no-repeat 10px 6px !important; }
.quote blockquote { background: url({STYLEIMGDIR}/quote2.gif) no-repeat 100% 100% !important; }
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/jeans/css_append.htm
|
HTML
|
asf20
| 2,338
|
.shadowline { border-top-color: #DDD; }
.sidebox h4 {color: #066;}
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/colors/css_append.htm
|
HTML
|
asf20
| 66
|
html { background: #C1A57D url({STYLEIMGDIR}/htmlbg.gif); }
#header { margin-bottom: 0; }
#header .wrap { padding: 0; height: 128px; }
#menu { right: 20px; height: 30px; }
#menu li { height: 30px; background: #F8F8F5 url({STYLEIMGDIR}/menu.gif) no-repeat 0 0; opacity: 0.95; filter: alpha(opacity=95); }
#menu a { border: none; height: 30px; background: url({STYLEIMGDIR}/menu.gif) no-repeat 100% -40px !important; line-height: 35px; }
#menu a.dropmenu { background-position: 100% -80px !important; }
#menu li.current { opacity: 1; filter: alpha(opacity=100); }
#menu li.current a { color: #099; font-weight: 700; }
#style_switch { padding: 14px 15px 0 0; background: url({STYLEIMGDIR}/corner_t_r.gif) no-repeat 100% 0; }
#nav { margin: 0 auto; border-bottom: 1px solid #E8ECE6; background: #F8F8F5 url({STYLEIMGDIR}/icon_nav.gif) no-repeat 0 0; text-indent: 45px; }
.shadowline { border-top-color: #D2DACE; }
.list th { background-image: url({STYLEIMGDIR}/forum.gif); }
.list th.new { background-image: url({STYLEIMGDIR}/forum_new.gif); }
.postbtn { background-image:url({STYLEIMGDIR}/post.gif); }
.replybtn { background-image:url({STYLEIMGDIR}/reply.gif); }
#footer { padding: 0 0 55px 0; background: url({STYLEIMGDIR}/footer.gif) no-repeat 50% 100%; }
#footer .wrap { background: #FFF; }
#rightinfo { padding: 10px 15px; background: url({STYLEIMGDIR}/corner_b_l.gif) no-repeat 0 100%; }
#footlink { padding: 10px 15px; background: url({STYLEIMGDIR}/corner_b_r.gif) no-repeat 100% 100%; }
#ad_headerbanner { margin-top: 25px; }
.ad_footerbanner { width: {WRAPWIDTH}; background: {WRAPBG}; }
.ad_text, .ad_footerbanner { margin: 0 auto; }
#wrap, .ad_text { border-bottom: 1px solid #E8ECE6; }
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/templates/greenwall/css_append.htm
|
HTML
|
asf20
| 1,714
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: leftmenu.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumlist = $collapse = $gid = array();
$newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000;
$sql = !empty($accessmasks) ?
"SELECT f.fid, f.fup, f.type, f.name, ff.viewperm, a.allowview FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid
LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid
WHERE f.status>'0' ORDER BY f.type, f.displayorder"
: "SELECT f.fid, f.fup, f.type, f.name, ff.viewperm FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING(fid)
WHERE f.status>'0' ORDER BY f.type, f.displayorder";
$query = $db->query($sql);
$forumdata = $forumlist = $haschild = array();
while($forumdata = $db->fetch_array($query)) {
if(!$forumdata['viewperm'] || ($forumdata['viewperm'] && forumperm($forumdata['viewperm'])) || !empty($forumdata['allowview']) || (isset($forumdata['users']) && strstr($forumdata['users'], "\t$discuz_uid\t"))) {
$forumdata['name'] = addslashes($forumdata['name']);
$forumdata['type'] != 'group' && $haschild[$forumdata['fup']] = true;
$forumlist[] = $forumdata;
}
}
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}sessions");
$onlinenum = $db->result($query , 0);
include template('leftmenu');
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/leftmenu.php
|
PHP
|
asf20
| 1,549
|
<?
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: my.php 10920 2007-10-19 00:53:10Z monkey $
*/
define('NOROBOT', TRUE);
define('CURSCRIPT', 'video');
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./api/video.php';
if($action == 'player') {
$ivid = $ivid ? $ivid : $vid;
$tid = $db->result_first("SELECT tid FROM {$tablepre}videos WHERE vid='$ivid'");
$tid = $tid ? intval($tid) : '';
dheader("Location: {$boardurl}viewthread.php?tid=$tid&vid=$ivid");
} elseif($action == 'updatevideoinfo') {
$db->query("UPDATE {$tablepre}videos SET vview=vview+'1' WHERE vid='$vid'");
showmessage('ok');
} elseif($action == 'flv') {
$client = new VideoClient_Util($appid, $siteid, $sitekey);
$flvurl = $client->createReferPlayer(array('ivid' => $ivid, 'm' => 'play', 'site' => $boardurl));
dheader("Location: $flvurl");
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/video.php
|
PHP
|
asf20
| 1,007
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: relatekw.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
error_reporting(0);
set_magic_quotes_runtime(0);
define('DISCUZ_ROOT', './');
define('IN_DISCUZ', TRUE);
define('NOROBOT', TRUE);
require_once './forumdata/cache/cache_settings.php';
if(!$_DCACHE['settings']['tagstatus']) {
exit;
}
require_once './config.inc.php';
require_once './include/global.func.php';
if($tid = @intval($_GET['tid'])) {
require_once './include/db_'.$database.'.class.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
$db->select_db($dbname);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
if($db->result_first("SELECT count(*) FROM {$tablepre}threadtags WHERE tid='$tid'")) {
exit;
}
$query = $db->query("SELECT subject, message FROM {$tablepre}posts WHERE tid='$tid' AND first='1'");
$data = $db->fetch_array($query);
$subject = $data['subject'];
$message = cutstr($data['message'], 500, '');
} else {
$subject = $_GET['subjectenc'];
$message = $_GET['messageenc'];
}
$subjectenc = rawurlencode(strip_tags($subject));
$messageenc = rawurlencode(strip_tags(preg_replace("/\[.+?\]/U", '', $message)));
$data = @implode('', file("http://keyword.discuz.com/related_kw.html?ics=$charset&ocs=$charset&title=$subjectenc&content=$messageenc"));
if($data) {
if(PHP_VERSION > '5' && $charset != 'utf-8') {
require_once DISCUZ_ROOT.'./include/chinese.class.php';
$chs = new Chinese('utf-8', $charset);
}
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $index);
xml_parser_free($parser);
$kws = array();
foreach($values as $valuearray) {
if($valuearray['tag'] == 'kw' || $valuearray['tag'] == 'ekw') {
$kws[] = !empty($chs) ? $chs->convert(trim($valuearray['value'])) : trim($valuearray['value']);
}
}
$return = '';
if($kws) {
foreach($kws as $kw) {
$kw = htmlspecialchars($kw);
$return .= $kw.' ';
}
$return = htmlspecialchars($return);
}
if(!$tid) {
$inajax = 1;
include template('relatekw');
} else {
if($_DCACHE['settings']['tagstatus'] && $kws) {
require_once DISCUZ_ROOT.'/forumdata/cache/cache_censor.php';
$tagcount = 0;
foreach($kws as $tagname) {
$tagname = trim(empty($_DCACHE['censor']['filter']) ? $tagname : preg_replace($_DCACHE['censor']['filter']['find'], $_DCACHE['censor']['filter']['replace'], $tagname));
if(preg_match('/^([\x7f-\xff_-]|\w|\s){3,20}$/', $tagname)) {
$query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='$tagname'");
if($db->num_rows($query)) {
if(!$tagstatus = $db->result($query, 0)) {
$db->query("UPDATE {$tablepre}tags SET total=total+1 WHERE tagname='$tagname'", 'UNBUFFERED');
}
} else {
$db->query("INSERT INTO {$tablepre}tags (tagname, closed, total)
VALUES ('$tagname', 0, 1)", 'UNBUFFERED');
$tagstatus = 0;
}
if(!$tagstatus) {
$db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('$tagname', $tid)", 'UNBUFFERED');
}
$tagcount++;
if($tagcount > 4) {
break;
}
}
}
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/relatekw.php
|
PHP
|
asf20
| 3,437
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: trade.php 16795 2008-11-20 08:21:44Z monkey $
*/
define('NOROBOT', TRUE);
define('CURSCRIPT', 'trade');
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/trade.func.php';
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
$page = max(1, intval($page));
if(!empty($orderid)) {
include_once language('misc');
$tradelog = daddslashes($db->fetch_first("SELECT * FROM {$tablepre}tradelog WHERE orderid='$orderid'"), 1);
if(empty($tradelog) || $discuz_uid != $tradelog['sellerid'] && $discuz_uid != $tradelog['buyerid']) {
showmessage('undefined_action', NULL, 'HALTED');
}
$trade_message = '';
$currentcredit = $creditstrans ? $_DSESSION['extcredits'.$creditstrans] : 0;
$discountprice = $tradelog['baseprice'] * $tradelog['number'];
if(!empty($pay) && !$tradelog['offline'] && $tradelog['status'] == 0 && $tradelog['buyerid'] == $discuz_uid) {
$trade = $db->fetch_first("SELECT * FROM {$tablepre}trades WHERE tid='$tradelog[tid]' AND pid='$tradelog[pid]'");
if($discuz_uid && $currentcredit < $discountcredit && $tradelog['discount']) {
showmessage('trade_credits_no_enough');
}
$pay = array();
$pay['commision'] = 0;
$transport = $tradelog['transport'];
$transportfee = 0;
trade_setprice(array('fee' => $fee, 'trade' => $trade, 'transport' => $transport), $price, $pay, $transportfee);
$payurl = trade_payurl($pay, $trade, $tradelog);
showmessage('trade_directtopay', $payurl);
}
if(submitcheck('offlinesubmit') && in_array($offlinestatus, trade_offline($tradelog, 0))) {
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_login($discuz_user, $password);
list($tmp['uid']) = daddslashes($ucresult);
if($tmp['uid'] <= 0) {
showmessage('trade_password_error', 'trade.php?orderid='.$orderid);
}
if($offlinestatus == STATUS_SELLER_SEND) {
$trade = $db->fetch_first("SELECT amount FROM {$tablepre}trades WHERE tid='$tradelog[tid]' AND pid='$tradelog[pid]'");
$user = $tradelog['buyer'];
$itemsubject = $tradelog['subject'];
sendpm($tradelog['sellerid'], 'trade_seller_send_subject', 'trade_seller_send_message', 0);
} elseif($offlinestatus == STATUS_WAIT_BUYER) {
$user = $tradelog['seller'];
$itemsubject = $tradelog['subject'];
sendpm($tradelog['buyerid'], 'trade_buyer_confirm_subject', 'trade_buyer_confirm_message', 0);
} elseif($offlinestatus == STATUS_TRADE_SUCCESS) {
$db->query("UPDATE {$tablepre}trades SET lastbuyer='$tradelog[buyer]', lastupdate='$timestamp', totalitems=totalitems+'$tradelog[number]', tradesum=tradesum+'$tradelog[price]' WHERE tid='$tradelog[tid]' AND pid='$tradelog[pid]'", 'UNBUFFERED');
$itemsubject = $tradelog['subject'];
sendpm($tradelog['sellerid'], 'trade_success_subject', 'trade_success_message', 0);
sendpm($tradelog['buyerid'], 'trade_success_subject', 'trade_success_message', 0);
} elseif($offlinestatus == STATUS_REFUND_CLOSE) {
$db->query("UPDATE {$tablepre}trades SET amount=amount+'$tradelog[number]' WHERE tid='$tradelog[tid]' AND pid='$tradelog[pid]'", 'UNBUFFERED');
$itemsubject = $tradelog['subject'];
sendpm($tradelog['sellerid'], 'trade_fefund_success_subject', 'trade_fefund_success_message', 0);
sendpm($tradelog['buyerid'], 'trade_fefund_success_subject', 'trade_fefund_success_message', 0);
}
$message = trim($message);
if($message) {
$message = daddslashes($tradelog['message']."\t\t\t".$discuz_uid."\t".$discuz_user."\t".$timestamp."\t".nl2br(strip_tags(substr($message, 0, 200))), 1);
} else {
$message = daddslashes($tradelog['message'], 1);
}
$db->query("UPDATE {$tablepre}tradelog SET status='$offlinestatus', lastupdate='$timestamp', message='$message' WHERE orderid='$orderid'");
showmessage('trade_orderstatus_updated', 'trade.php?orderid='.$orderid);
}
if(submitcheck('tradesubmit')) {
if($tradelog['status'] == 0) {
$update = array();
if($tradelog['sellerid'] == $discuz_uid) {
$tradelog['baseprice'] = floatval($newprice);
$tradelog['transportfee'] = intval($newfee);
$update = array(
"baseprice='$tradelog[baseprice]'",
"transportfee='$tradelog[transportfee]'"
);
}
if($tradelog['buyerid'] == $discuz_uid) {
$newnumber = intval($newnumber);
if($newnumber <= 0) {
showmessage('trade_input_no');
}
$trade = $db->fetch_first("SELECT amount FROM {$tablepre}trades WHERE tid='$tradelog[tid]' AND pid='$tradelog[pid]'");
if($newnumber > $trade['amount'] + $tradelog['number']) {
showmessage('trade_lack');
}
$amount = $trade['amount'] + $tradelog['number'] - $newnumber;
$db->query("UPDATE {$tablepre}trades SET amount='$amount' WHERE tid='$tradelog[tid]' AND pid='$tradelog[pid]'", 'UNBUFFERED');
$tradelog['number'] = $newnumber;
$update = array(
"number='$tradelog[number]'",
"discount=0",
"buyername='".dhtmlspecialchars($newbuyername)."'",
"buyercontact='".dhtmlspecialchars($newbuyercontact)."'",
"buyerzip='".dhtmlspecialchars($newbuyerzip)."'",
"buyerphone='".dhtmlspecialchars($newbuyerphone)."'",
"buyermobile='".dhtmlspecialchars($newbuyermobile)."'"
);
}
if($update) {
if($tradelog['discount']) {
$tradelog['baseprice'] = $tradelog['baseprice'] - $tax;
$price = $tradelog['baseprice'] * $tradelog['number'];
} else {
$price = $tradelog['baseprice'] * $tradelog['number'];
}
$update[] = "price='".($price + ($tradelog['transport'] == 2 ? $tradelog['transportfee'] : 0))."'";
$db->query("UPDATE {$tablepre}tradelog SET ".implode(',', $update)." WHERE orderid='$orderid'");
$tradelog = $db->fetch_first("SELECT * FROM {$tablepre}tradelog WHERE orderid='$orderid'");
}
}
}
$tradelog['lastupdate'] = dgmdate("$dateformat $timeformat", $tradelog['lastupdate'] + $timeoffset * 3600);
$tradelog['statusview'] = trade_getstatus($tradelog['status']);
$messagelist = array();
if($tradelog['offline']) {
$offlinenext = trade_offline($tradelog);
$message = explode("\t\t\t", $tradelog['message']);
foreach($message as $row) {
$row = explode("\t", $row);
$row[2] = dgmdate("$dateformat $timeformat", $row[2] + $timeoffset * 3600);
$row[0] && $messagelist[] = $row;
}
} else {
$loginurl = trade_getorderurl($tradelog['tradeno']);
}
include template('trade_view');
} else {
if(empty($pid)) {
$pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND first='1' LIMIT 1");
}
if($db->result_first("SELECT closed FROM {$tablepre}threads WHERE tid='$tid'")) {
showmessage('trade_closed', 'viewthread.php?tid='.$tid.'&page='.$page);
}
$trade = $db->fetch_first("SELECT * FROM {$tablepre}trades WHERE tid='$tid' AND pid='$pid'");
if(empty($trade)) {
showmessage('undefined_action', NULL, 'HALTED');
}
$fromcode = false;
if($trade['closed']) {
showmessage('trade_closed', 'viewthread.php?tid='.$tid.'&page='.$page);
}
if($trade['price'] <= 0) {
showmessage('trade_invalid', 'viewthread.php?tid='.$tid.'&page='.$page);
}
if($action != 'trade' && !submitcheck('tradesubmit')) {
$lastbuyerinfo = dhtmlspecialchars($db->fetch_first("SELECT buyername,buyercontact,buyerzip,buyerphone,buyermobile FROM {$tablepre}tradelog WHERE buyerid='$discuz_uid' AND status!=0 AND buyername!='' ORDER BY lastupdate DESC LIMIT 1"));
$extra = rawurlencode($extra);
include template('trade');
} else {
if($trade['sellerid'] == $discuz_uid) {
showmessage('trade_by_myself');
} elseif($number <= 0) {
showmessage('trade_input_no');
} elseif(!$fromcode && $number > $trade['amount']) {
showmessage('trade_lack');
}
$pay['number'] = $number;
$pay['price'] = $trade['price'];
$price = $pay['price'] * $pay['number'];
$buyercredits = 0;
$pay['commision'] = 0;
$orderid = $pay['orderid'] = gmdate('YmdHis', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600).random(18);
$transportfee = 0;
trade_setprice(array('fee' => $fee, 'trade' => $trade, 'transport' => $transport), $price, $pay, $transportfee);
$buyerid = $discuz_uid ? $discuz_uid : 0;
$discuz_user = $discuz_user ? $discuz_user : $guestuser;
$trade = daddslashes($trade, 1);
$buyermsg = dhtmlspecialchars($buyermsg);
$buyerzip = dhtmlspecialchars($buyerzip);
$buyerphone = dhtmlspecialchars($buyerphone);
$buyermobile = dhtmlspecialchars($buyermobile);
$buyername = dhtmlspecialchars($buyername);
$buyercontact = dhtmlspecialchars($buyercontact);
$offline = !empty($offline) ? 1 : 0;
$db->query("INSERT INTO {$tablepre}tradelog
(tid, pid, orderid, subject, price, quality, itemtype, number, tax, locus, sellerid, seller, selleraccount, buyerid, buyer, buyercontact, buyercredits, buyermsg, lastupdate, offline, buyerzip, buyerphone, buyermobile, buyername, transport, transportfee, baseprice, discount) VALUES
('$trade[tid]', '$trade[pid]', '$orderid', '$trade[subject]', '$price', '$trade[quality]', '$trade[itemtype]', '$number', '$tax',
'$trade[locus]', '$trade[sellerid]', '$trade[seller]', '$trade[account]', '$discuz_uid', '$discuz_user', '$buyercontact', 0, '$buyermsg', '$timestamp', '$offline', '$buyerzip', '$buyerphone', '$buyermobile', '$buyername', '$transport', '$transportfee', '$trade[price]', 0)");
$db->query("UPDATE {$tablepre}trades SET amount=amount-'$number' WHERE tid='$trade[tid]' AND pid='$trade[pid]'", 'UNBUFFERED');
showmessage('trade_order_created', 'trade.php?orderid='.$orderid);
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/trade.php
|
PHP
|
asf20
| 9,795
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: attachment.php 17440 2008-12-22 04:41:46Z monkey $
*/
define('CURSCRIPT', 'attachment');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
if($attachexpire) {
$k = $_GET['k'];
$t = $_GET['t'];
if(empty($k) || empty($t) || $k != md5($aid.md5($authkey).$t) || $timestamp - $t > $attachexpire * 3600) {
$aid = intval($aid);
if($attach = $db->fetch_first("SELECT pid, tid FROM {$tablepre}attachments WHERE aid='$aid'")) {
$key = md5($aid.md5($authkey).$timestamp);
$sidauth = rawurlencode(authcode($sid, 'ENCODE', $authkey));
showmessage('attachment_expired');
} else {
showmessage('attachment_nonexistence');
}
}
}
$discuz_action = 14;
// read local file's function: 1=fread 2=readfile 3=fpassthru 4=fpassthru+multiple
$readmod = 2;
$refererhost = parse_url($_SERVER['HTTP_REFERER']);
if($attachrefcheck && $_SERVER['HTTP_REFERER'] && !($refererhost['host'] == $_SERVER['HTTP_HOST'])) {
//dheader("Location: {$boardurl}images/common/invalidreferer.gif");
showmessage('attachment_referer_invalid', NULL, 'HALTED');
}
periodscheck('attachbanperiods');
$attachexists = FALSE;
if(!empty($aid) && is_numeric($aid)) {
if(($attach = $db->fetch_first("SELECT a.*, p.invisible FROM {$tablepre}attachments a LEFT JOIN {$tablepre}posts p ON a.pid=p.pid WHERE aid='$aid'")) && $attach['invisible'] == 0) {
$thread = $db->fetch_first("SELECT tid, fid, price, special FROM {$tablepre}threads WHERE tid='$attach[tid]' AND displayorder>='0'");
$thread && $attachexists = TRUE;
}
}
!$attachexists && showmessage('attachment_nonexistence');
$allowgetattach = !empty($forum['allowgetattach']) || ($allowgetattach && !$forum['getattachperm']) || forumperm($forum['getattachperm']);
if($allowgetattach && ($attach['readperm'] && $attach['readperm'] > $readaccess) && $adminid <= 0 && !($discuz_uid && $discuz_uid == $attach['uid'])) {
showmessage('attachment_forum_nopermission', NULL, 'NOPERM');
}
$ispaid = FALSE;
if(!$thread['special'] && $thread['price'] > 0 && (!$discuz_uid || ($discuz_uid && $discuz_uid != $attach['uid'] && $adminid <=0))) {
$ispaid = $discuz_uid ? $db->result_first("SELECT uid FROM {$tablepre}paymentlog WHERE uid='$discuz_uid' AND tid='$attach[tid]'") : FALSE;
!$ispaid && showmessage('attachment_payto', 'viewthread.php?tid='.$attach['tid']);
}
$ismoderator = in_array($adminid, array(1, 2)) ? 1 : ($adminid == 3 ? $db->result_first("SELECT uid FROM {$tablepre}moderators m INNER JOIN {$tablepre}threads t ON t.tid='$attach[tid]' AND t.fid=m.fid WHERE m.uid='$discuz_uid'") : 0);
$exemptvalue = $ismoderator ? 64 : 8;
if($attach['price'] && (!$discuz_uid || ($discuz_uid != $attach['uid'] && !($exempt & $exemptvalue)))) {
$payrequired = $discuz_uid ? !$db->result_first("SELECT uid FROM {$tablepre}attachpaymentlog WHERE uid='$discuz_uid' AND aid='$attach[aid]'") : 1;
$payrequired && showmessage('attachement_payto_attach', 'misc.php?action=attachpay&aid='.$attach['aid']);
}
$isimage = $attach['isimage'];
$ftp['hideurl'] = $ftp['hideurl'] || ($isimage && !empty($noupdate) && $attachimgpost && strtolower(substr($ftp['attachurl'], 0, 3)) == 'ftp');
if(empty($nothumb) && $attach['isimage'] && $attach['thumb']) {
$db->close(); ob_end_clean();
dheader('Content-Disposition: inline; filename='.$attach['filename'].'.thumb.jpg');
dheader('Content-Type: image/pjpeg');
if($attach['remote']) {
$ftp['hideurl'] ? getremotefile($attach['attachment'].'.thumb.jpg') : dheader('location:'.$ftp['attachurl'].'/'.$attach['attachment'].'.thumb.jpg');
} else {
getlocalfile($attachdir.'/'.$attach['attachment'].'.thumb.jpg');
}
exit();
}
$filename = $attachdir.'/'.$attach['attachment'];
if(!$attach['remote'] && !is_readable($filename)) {
showmessage('attachment_nonexistence');
}
$forum = $db->fetch_first("SELECT f.viewperm, f.getattachperm, f.getattachcredits, a.allowgetattach FROM {$tablepre}forumfields f
LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid
WHERE f.fid='$thread[fid]'");
if(!$ispaid && !$forum['allowgetattach']) {
if(!$forum['getattachperm'] && !$allowgetattach) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif(($forum['getattachperm'] && !forumperm($forum['getattachperm'])) || ($forum['viewperm'] && !forumperm($forum['viewperm']))) {
showmessage('attachment_forum_nopermission', NULL, 'NOPERM');
}
}
$range = 0;
if($readmod == 4 && !empty($_SERVER['HTTP_RANGE'])) {
list($range) = explode('-',(str_replace('bytes=', '', $_SERVER['HTTP_RANGE'])));
}
$exemptvalue = $ismoderator ? 32 : 4;
if(!$isimage && !($exempt & $exemptvalue)) {
$getattachcredits = $forum['getattachcredits'] ? unserialize($forum['getattachcredits']) : $creditspolicy['getattach'];
if($getattachcredits) {
$k = $_GET['ck'];
$t = $_GET['t'];
if(empty($k) || empty($t) || $k != substr(md5($aid.$t.md5($authkey)), 0, 8) || $timestamp - $t > 3600) {
dheader('location: misc.php?action=attachcredit&aid='.$attach['aid'].'&formhash='.FORMHASH);
exit();
}
}
}
if(empty($noupdate)) {
if($delayviewcount == 2 || $delayviewcount == 3) {
$logfile = './forumdata/cache/cache_attachviews.log';
if(substr($timestamp, -1) == '0') {
require_once DISCUZ_ROOT.'./include/misc.func.php';
updateviews('attachments', 'aid', 'downloads', $logfile);
}
if(@$fp = fopen(DISCUZ_ROOT.$logfile, 'a')) {
fwrite($fp, "$aid\n");
fclose($fp);
} elseif($adminid == 1) {
showmessage('view_log_invalid');
}
} else {
$db->query("UPDATE {$tablepre}attachments SET downloads=downloads+'1' WHERE aid='$aid'", 'UNBUFFERED');
}
}
$db->close(); ob_end_clean();
//dheader('Cache-control: max-age=31536000');
//dheader('Expires: '.gmdate('D, d M Y H:i:s', $timestamp + 31536000).' GMT');
if($attach['remote'] && !$ftp['hideurl']) {
dheader('location:'.$ftp['attachurl'].'/'.$attach['attachment']);
}
$filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize'];
$attach['filename'] = '"'.(strtolower($charset) == 'utf-8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($attach['filename']) : $attach['filename']).'"';
dheader('Date: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT');
dheader('Content-Encoding: none');
if($isimage && !empty($noupdate)) {
dheader('Content-Disposition: inline; filename='.$attach['filename']);
} else {
dheader('Content-Disposition: attachment; filename='.$attach['filename']);
}
dheader('Content-Type: '.$attach['filetype']);
dheader('Content-Length: '.$filesize);
if($readmod == 4) {
dheader('Accept-Ranges: bytes');
if(!empty($_SERVER['HTTP_RANGE'])) {
$rangesize = ($filesize - $range) > 0 ? ($filesize - $range) : 0;
dheader('Content-Length: '.$rangesize);
dheader('HTTP/1.1 206 Partial Content');
dheader('Content-Range: bytes='.$range.'-'.($filesize-1).'/'.($filesize));
}
}
$attach['remote'] ? getremotefile($attach['attachment']) : getlocalfile($filename, $readmod, $range);
function getremotefile($file) {
global $authkey, $ftp, $attachdir;
@set_time_limit(0);
if(!@readfile($ftp['attachurl'].'/'.$file)) {
require_once DISCUZ_ROOT.'./include/ftp.func.php';
if(!($ftp['connid'] = dftp_connect($ftp['host'], $ftp['username'], authcode($ftp['password'], 'DECODE', md5($authkey)), $ftp['attachdir'], $ftp['port'], $ftp['ssl']))) {
return FALSE;
}
$tmpfile = @tempnam($attachdir, '');
if(dftp_get($ftp['connid'], $tmpfile, $file, FTP_BINARY)) {
@readfile($tmpfile);
@unlink($tmpfile);
} else {
@unlink($tmpfile);
return FALSE;
}
}
return TRUE;
}
function getlocalfile($filename, $readmod = 2, $range = 0) {
if($readmod == 1 || $readmod == 3 || $readmod == 4) {
if($fp = @fopen($filename, 'rb')) {
@fseek($fp, $range);
if(function_exists('fpassthru') && ($readmod == 3 || $readmod == 4)) {
@fpassthru($fp);
} else {
echo @fread($fp, filesize($filename));
}
}
@fclose($fp);
} else {
@readfile($filename);
}
@flush(); @ob_flush();
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/attachment.php
|
PHP
|
asf20
| 8,324
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: invite.php 16708 2008-11-17 01:34:55Z tiger $
*/
define('CURSCRIPT', 'invite');
require_once './include/common.inc.php';
if($regstatus <= 1) {
showmessage('invite_close');
} elseif(!$discuz_uid) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
$action = !empty($action) ? $action : 'index';
$tpp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
if($action == 'index') {
$myinvitenum = intval($db->result_first("SELECT COUNT(*) FROM {$tablepre}invites WHERE uid='$discuz_uid' AND dateline>'$timestamp'-86400 AND dateline<'$timestamp'"));
if(!submitcheck('buysubmit')) {
$invitenum = intval($db->result_first("SELECT COUNT(*) FROM {$tablepre}invites WHERE uid='$discuz_uid' AND status IN ('1', '3')"));
$multipage = multi($invitenum, $tpp, $page, "invite.php");
$invitelist = $inviteuserlist = array();
$query = $db->query("SELECT dateline, expiration, invitecode, status
FROM {$tablepre}invites
WHERE uid='$discuz_uid' AND status IN ('1', '3') ORDER BY dateline DESC LIMIT $start_limit,$tpp");
while($invite = $db->fetch_array($query)) {
$invite['expiration'] = round(($invite['expiration'] - $timestamp) / 86400);
$invitelist[] = $invite;
}
$query = $db->query("SELECT i.dateline, i.expiration, i.invitecode, m.username, m.uid
FROM {$tablepre}invites i, {$tablepre}members m
WHERE i.uid='$discuz_uid' AND i.status='2' AND i.reguid=m.uid ORDER BY i.regdateline DESC LIMIT 0, 10");
while($inviteuser = $db->fetch_array($query)) {
$inviteuser['avatar'] = discuz_uc_avatar($inviteuser['uid'], 'small');
$inviteuserlist[] = $inviteuser;
}
include template('invite_index');
} else {
if(!$allowinvite) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
if($maxinvitenum && $myinvitenum == $maxinvitenum) {
showmessage('invite_num_range_invalid');
}
$amount = intval($amount);
$buyinvitecredit = $amount ? $amount * $inviteprice : 0;
if(!$amount || $amount < 0) {
showmessage('invite_num_invalid');
} elseif(${'extcredits'.$creditstransextra[4]} < $buyinvitecredit && $buyinvitecredit) {
showmessage('invite_credits_no_enough');
} elseif(($maxinvitenum && $myinvitenum + $amount > $maxinvitenum) || $amount > 50) {
showmessage('invite_num_buy_range_invalid');
} elseif($buyinvitecredit && !$creditstransextra[4]) {
showmessage('credits_transaction_disabled');
} else {
for($i=1; $i<=$amount; $i++) {
$invitecode = substr(md5($discuz_uid.$timestamp.random(6)), 0, 10).random(6);
$expiration = $timestamp + $maxinviteday * 86400;
$db->query("INSERT INTO {$tablepre}invites (uid, dateline, expiration, inviteip, invitecode) VALUES ('$discuz_uid', '$timestamp', '$expiration', '$onlineip', '$invitecode')", 'UNBUFFERED');
}
if($buyinvitecredit && $creditstransextra[4]) {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[4]=extcredits$creditstransextra[4]-'$buyinvitecredit' WHERE uid='$discuz_uid'");
}
showmessage('invite_buy_succeed');
}
}
} elseif($action == 'sendinvite') {
if(!$allowmailinvite) {
showmessage('group_nopermission', 'invite.php');
}
if(!submitcheck('sendsubmit')) {
$fromuid = $creditspolicy['promotion_register'] ? '&fromuid='.$discuz_uid : '';
$threadurl = "{$boardurl}$regname?invitecode=$invitecode$fromuid";
$email = $db->result_first("SELECT email FROM {$tablepre}members WHERE uid='$discuz_uid'");
include template('invite_send');
} else {
if(empty($fromname) || empty($fromemail) || empty($sendtoname) || empty($sendtoemail)) {
showmessage('email_friend_invalid');
}
if(!$invitenum = $db->result_first("SELECT invitecode FROM {$tablepre}invites WHERE uid='$discuz_uid' AND status='1' AND invitecode='$invitecode'")) {
showmessage('invite_invalid');
} else {
$db->query("UPDATE {$tablepre}invites SET status='3' WHERE uid='$discuz_uid' AND invitecode='$invitecode'");
sendmail("$sendtoname <$sendtoemail>", 'email_to_invite_subject', 'email_to_invite_message', "$fromname <$fromemail>");
showmessage('email_invite_succeed', 'invite.php');
}
}
} elseif($action == 'markinvite') {
$changestatus = $do == 'undo' ? 1 : 3;
if(!empty($invitecode)) {
$db->query("UPDATE {$tablepre}invites SET status='$changestatus' WHERE uid='$discuz_uid' AND invitecode='$invitecode'");
}
$invite = $db->fetch_first("SELECT invitecode, dateline, expiration FROM {$tablepre}invites WHERE uid='$discuz_uid' AND invitecode='$invitecode'");
$invite['expiration'] = round(($invite['expiration'] - $timestamp) / 86400);
include template('invite_index');
} else {
showmessage('undefined_action');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/invite.php
|
PHP
|
asf20
| 4,899
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: memcp.php 17355 2008-12-16 02:33:00Z monkey $
*/
define('CURSCRIPT', 'memcp');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
$discuz_action = 7;
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'HALTED');
}
$action = !empty($action) ? $action : '';
$operation = !empty($operation) ? $operation : '';
$maxbiosize = $maxbiosize ? $maxbiosize : 200;
if($regverify == 2 && $groupid == 8 && ($action != 'profile' || $action == 'validating')) {
$validating = array();
if($regverify == 2 && $groupid == 8) {
if($validating = $db->fetch_first("SELECT * FROM {$tablepre}validating WHERE uid='$discuz_uid'")) {
$validating['moddate'] = $validating['moddate'] ? dgmdate("$dateformat $timeformat", $validating['moddate'] + $timeoffset * 3600) : 0;
$validating['adminenc'] = rawurlencode($validating['admin']);
}
}
include template('memcp_validating');
dexit();
}
if(!$action || $action == 'profile') {
$typeid = empty($typeid) || !in_array($typeid, array(1, 2, 3, 4, 5, 6)) ? 2 : $typeid;
require_once DISCUZ_ROOT.'./forumdata/cache/cache_profilefields.php';
$member = $db->fetch_first("SELECT * FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
WHERE m.uid='$discuz_uid'");
$seccodecheck = ($seccodestatus & 8) && (!$seccodedata['minposts'] || $posts < $seccodedata['minposts']);
$secqaacheck = false;
$member['msn']= explode("\t", $member['msn']);
if(!submitcheck('editsubmit', 0, $seccodecheck)) {
if($typeid == 1) {
if($seccodecheck) {
$seccode = random(6, 1) + $seccode{0} * 1000000;
}
} elseif($typeid == 2) {
require_once DISCUZ_ROOT.'./include/editor.func.php';
require_once DISCUZ_ROOT.'/uc_client/client.php';
$gendercheck = array($member['gender'] => 'selected="selected"');
$uc_avatarflash = uc_avatar($discuz_uid, '', 0);
$member['bio'] = preg_replace("/<imme>(.+)<\/imme>/is", '[imme]', $member['bio']);
$member['sightml'] = preg_replace("/<imme>(.+)<\/imme>/is", '[imme]', $member['sightml']);
$member['bio'] = html2bbcode($member['bio']);
$member['signature'] = html2bbcode($member['sightml']);
} elseif($typeid == 5) {
$invisiblechecked = $member['invisible'] ? 'checked="checked"' : '';
$emailchecked = $member['showemail'] ? 'checked="checked"' : '';
$newschecked = $member['newsletter'] ? 'checked="checked"' : '';
$tppchecked = array($member['tpp'] => 'checked="checked"');
$pppchecked = array($member['ppp'] => 'checked="checked"');
$toselect = array(strval((float)$member['timeoffset']) => 'selected="selected"');
$pscheck = array(intval($member['pmsound']) => 'checked="checked"');
$emcheck = array($member['editormode'] => 'checked="checked"');
$tfcheck = array($member['timeformat'] => 'checked="checked"');
$dfcheck = array($member['dateformat'] => 'checked="checked"');
$styleselect = '';
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles WHERE available='1'");
while($style = $db->fetch_array($query)) {
$styleselect .= "<option value=\"$style[styleid]\" ".
($style['styleid'] == $member['styleid'] ? 'selected="selected"' : NULL).
">$style[name]</option>\n";
}
$customshow = str_pad(base_convert($member['customshow'], 10, 3), 4, '0', STR_PAD_LEFT);
$dateconvertchecked = array($customshow{0} => 'checked="checked"');
$sschecked = array($customshow{1} => 'checked="checked"');
$sachecked = array($customshow{2} => 'checked="checked"');
$sichecked = array($customshow{3} => 'checked="checked"');
$creditnoticechecked = array(empty($_COOKIE['discuz_creditnoticedisable']) => 'checked="checked"');
$dateformatlist = array();
if(!empty($userdateformat) && ($count = count($userdateformat))) {
for($num =1; $num <= $count; $num ++) {
$dateformatlist[$num] = str_replace(array('n', 'j', 'y', 'Y'), array('mm', 'dd', 'yy', 'yyyy'), $userdateformat[$num-1]);
}
}
$feedchecks = array();
$customaddfeed = intval($member['customaddfeed']);
if($customaddfeed > 0) {
$customaddfeed = sprintf('%03b', $customaddfeed);
for($i = 1; $i <= 3; $i++) {
$feedchecks[$i] = $customaddfeed[3 - $i] ? 'checked="checked"' : '';
}
}
$defaultcheck = $customaddfeed == 0 ? 'checked="checked"' : '';
$customcheck = $feedchecks || $customaddfeed < 0 ? 'checked="checked"' : '';
$showfeedcheck = $customaddfeed == 0 ? 'none' : '';
}
include template('memcp_profile');
} else {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$membersql = $memberfieldsql = $authstradd1 = $authstradd2 = $newpasswdadd = '';
if($typeid == 1) {
$emailnew = dhtmlspecialchars($emailnew);
if($questionidnew === '') {
$secquesnew = $discuz_secques;
$questionidnew = $answernew = '';
} else {
$secquesnew = $questionidnew > 0 ? random(8) : '';
}
if(($adminid == 1 || $adminid == 2 || $adminid == 3) && !$secquesnew && $admincp['forcesecques']) {
showmessage('profile_admin_security_invalid');
}
if(!empty($newpassword) && $newpassword != $newpassword2) {
showmessage('profile_passwd_notmatch');
}
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_edit($discuz_user, $oldpassword, $newpassword, $emailnew, 0, $questionidnew, $answernew);
if($ucresult == -1) {
showmessage('profile_passwd_wrong', NULL, 'HALTED');
} elseif($ucresult == -4) {
showmessage('profile_email_illegal');
} elseif($ucresult == -5) {
showmessage('profile_email_domain_illegal');
} elseif($ucresult == -6) {
showmessage('profile_email_duplicate');
}
if(!empty($newpassword)) {
$newpasswdadd = ", password='".md5(random(10))."'";
}
if($regverify == 1 && $adminid == 0 && $emailnew != $email && (($grouptype == 'member' && $adminid == 0) || $groupid == 8)) {
$idstring = random(6);
$groupid = 8;
require_once DISCUZ_ROOT.'./forumdata/cache/usergroup_8.php';
$authstradd1 = ", groupid='8'";
$authstradd2 = "authstr='$timestamp\t2\t$idstring'";
sendmail("$discuz_userss <$emailnew>", 'email_verify_subject', 'email_verify_message');
}
$membersql = "secques='$secquesnew', email='$emailnew' $newpasswdadd $authstradd1";
$memberfieldsql = $authstradd2;
} elseif($typeid == 2) {
$censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($censoruser = trim($censoruser)), '/')).')$/i';
if($censoruser && (@preg_match($censorexp, $nicknamenew) || @preg_match($censorexp, $cstatusnew))) {
showmessage('profile_nickname_cstatus_illegal');
}
if($msnnew && !isemail($msnnew)) {
showmessage('profile_alipay_msn');
}
if($alipaynew && !isemail($alipaynew)) {
showmessage('profile_alipay_illegal');
}
$sitenew = !preg_match("/^http:\/\/$/i", $sitenew) ? (dhtmlspecialchars(trim(preg_match("/^https?:\/\/.+/i", $sitenew) ? $sitenew : ($sitenew ? 'http://'.$sitenew : '')))) : '';
$icqnew = preg_match ("/^([0-9]+)$/", $icqnew) && strlen($icqnew) >= 5 && strlen($icqnew) <= 12 ? $icqnew : '';
$qqnew = preg_match ("/^([0-9]+)$/", $qqnew) && strlen($qqnew) >= 5 && strlen($qqnew) <= 12 ? $qqnew : '';
$bdaynew = datecheck($bdaynew) ? $bdaynew : '0000-00-00';
$yahoonew = dhtmlspecialchars($yahoonew);
$msnnew = dhtmlspecialchars($msnnew);
$msnnew = "$msnnew\t{$member[msn][1]}";
$taobaonew = dhtmlspecialchars($taobaonew);
$alipaynew = dhtmlspecialchars($alipaynew);
$nicknamenew = $allownickname ? cutstr(censor(dhtmlspecialchars($nicknamenew)), 30) : '';
$cstatusadd = $allowcstatus ? ', customstatus=\''.cutstr(censor(dhtmlspecialchars($cstatusnew)), 30).'\'' : '';
$gendernew = empty($gendernew) ? 0 : intval($gendernew);
$locationnew = cutstr(censor(dhtmlspecialchars($locationnew)), 30);
if($maxsigsize) {
if(strlen($signaturenew) > $maxsigsize) {
showmessage('profile_sig_toolong');
}
} else {
$signaturenew = '';
}
$signaturenew = censor($signaturenew);
$sigstatusnew = $signaturenew ? 1 : 0;
$bionew = censor(dhtmlspecialchars($bionew));
$sightmlnew = discuzcode(stripslashes($signaturenew), 1, 0, 0, 0, $allowsigbbcode, $allowsigimgcode, 0, 0, 1);
$biohtmlnew = discuzcode(stripslashes($bionew), 1, 0, 0, 0, $allowbiobbcode, $allowbioimgcode, 0, 0, 1);
if($member['msn'][1]) {
if(strpos(strtolower($sightmlnew), '[imme]') !== FALSE) {
$sightmlnew = str_replace('[imme]', "<imme><a target='_blank' href='http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=".$member['msn'][1]."@apps.messenger.live.com&mkt=zh-cn' title='MSN'><img style='vertical-align:middle' src='http://messenger.services.live.com/users/".$member['msn'][1]."@apps.messenger.live.com/presenceimage?mkt=zh-cn' width='16' height='16' /></a></imme>", $sightmlnew);
}
if(strpos(strtolower($biohtmlnew), '[imme]') !== FALSE) {
$biohtmlnew = str_replace('[imme]', "<imme><a target='_blank' href='http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=".$member['msn'][1]."@apps.messenger.live.com&mkt=zh-cn' title='MSN'><img style='vertical-align:middle' src='http://messenger.services.live.com/users/".$member['msn'][1]."@apps.messenger.live.com/presenceimage?mkt=zh-cn' width='16' height='16' /></a></imme>", $biohtmlnew);
}
}
$sightmlnew = addslashes($sightmlnew);
$biohtmlnew = addslashes($biohtmlnew);
$membersql = "gender='$gendernew', bday='$bdaynew', sigstatus='$sigstatusnew'";
$memberfieldsql = "nickname='$nicknamenew', site='$sitenew', location='$locationnew', icq='$icqnew', qq='$qqnew', yahoo='$yahoonew', msn='$msnnew', taobao='$taobaonew', alipay='$alipaynew', bio='$biohtmlnew', sightml='$sightmlnew' $cstatusadd";
if($_DCACHE['fields_required'] || $_DCACHE['fields_optional']) {
$fieldadd = array();
foreach(array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']) as $field) {
$field_key = 'field_'.$field['fieldid'];
$field_val = trim(${'field_'.$field['fieldid'].'new'});
if($field['required'] && $field_val == '' && !($field['unchangeable'] && $member[$field_key])) {
showmessage('profile_required_info_invalid');
} elseif($field['selective'] && $field_val != '' && !isset($field['choices'][$field_val])) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif(!$field['unchangeable'] || !$member[$field_key]) {
$fieldadd[] = "$field_key='".dhtmlspecialchars($field_val)."'";
}
}
if(!empty($fieldadd)) {
$memberfieldsql .= ', '.implode(', ', $fieldadd);
}
}
} else {
$tppnew = in_array($tppnew, array(10, 20, 30)) ? $tppnew : 0;
$pppnew = in_array($pppnew, array(5, 10, 15)) ? $pppnew : 0;
$editormodenew = in_array($editormodenew, array(0, 1, 2)) ? $editormodenew : 2;
$ssnew = in_array($ssnew, array(0, 1)) ? $ssnew : 2;
$sanew = in_array($sanew, array(0, 1)) ? $sanew : 2;
$sinew = in_array($sinew, array(0, 1)) ? $sinew : 2;
$dateconvertnew = $dateconvertnew ? 1 : 0;
$customshownew = base_convert($dateconvertnew.$ssnew.$sanew.$sinew, 3, 10);
$dateformatnew = ($dateformatnew = intval($dateformatnew)) && !empty($userdateformat[$dateformatnew -1]) ? $dateformatnew : 0;
$invisiblenew = $allowinvisible && $invisiblenew ? 1 : 0;
$showemailnew = empty($showemailnew) ? 0 : 1;
$styleid = empty($styleidnew) ? $styleid : $styleidnew;
if($customaddfeednew) {
$customaddfeednew = $addfeed[1] || $addfeed[2] ||$addfeed[3] ? bindec(intval($addfeed[3]).intval($addfeed[2]).intval($addfeed[1])) : '-1';
}
if($creditnoticenew) {
dsetcookie('discuz_creditnoticedisable', '', -31536000, '');
}
$membersql = "styleid='$styleidnew', showemail='$showemailnew', timeoffset='$timeoffsetnew', tpp='$tppnew', ppp='$pppnew', editormode='$editormodenew', customshow='$customshownew', newsletter='$newsletternew', invisible='$invisiblenew', timeformat='$timeformatnew', dateformat='$dateformatnew', pmsound='$pmsoundnew', customaddfeed='$customaddfeednew'";
}
if($membersql) {
$db->query("UPDATE {$tablepre}members SET $membersql WHERE uid='$discuz_uid'");
}
$query = $db->query("SELECT uid FROM {$tablepre}memberfields WHERE uid='$discuz_uid'");
if(!$db->num_rows($query)) {
$db->query("REPLACE INTO {$tablepre}memberfields (uid) VALUES ('$discuz_uid')");
}
if($memberfieldsql) {
$db->query("UPDATE {$tablepre}memberfields SET $memberfieldsql WHERE uid='$discuz_uid'");
}
if($type == 1 && !empty($authstradd1) && !empty($authstradd2)) {
showmessage('profile_email_verify');
} else {
showmessage('profile_succeed', 'memcp.php?action=profile&typeid='.$typeid);
}
}
} elseif($action == 'credits') {
$taxpercent = sprintf('%1.2f', $creditstax * 100).'%';
if($creditspolicy['promotion_visit'] || $creditspolicy['promotion_register']) {
$promotion_visit = $promotion_register = $space = '';
foreach(array('promotion_visit', 'promotion_register') as $val) {
if(!empty($creditspolicy[$val]) && is_array($creditspolicy[$val])) {
foreach($creditspolicy[$val] as $id => $policy) {
$$val .= $space.$extcredits[$id]['title'].' +'.$policy;
$space = ' ';
}
}
}
}
if(submitcheck('transfersubmit')) {
if($transferstatus) {
if(!submitcheck('confirm')) {
$to = $db->result_first("SELECT username FROM {$tablepre}members WHERE username='$to'");
include template('memcp_credits_action');
} else {
$amount = intval($amount);
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_login($discuz_user, $password);
list($tmp['uid']) = daddslashes($ucresult);
if($tmp['uid'] <= 0) {
showmessage('credits_password_invalid');
} elseif($amount <= 0) {
showmessage('credits_transaction_amount_invalid');
} elseif(${'extcredits'.$creditstrans} - $amount < ($minbalance = $transfermincredits)) {
showmessage('credits_balance_insufficient');
} elseif(!($netamount = floor($amount * (1 - $creditstax)))) {
showmessage('credits_net_amount_iszero');
}
$member = $db->fetch_first("SELECT uid, username FROM {$tablepre}members WHERE username='$to'");
if(!$member) {
showmessage('credits_transfer_send_nonexistence');
} elseif($member['uid'] == $discuz_uid) {
showmessage('credits_transfer_self');
}
$creditsarray[$creditstrans] = -$amount;
updatecredits($discuz_uid, $creditsarray);
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+'$netamount' WHERE uid='$member[uid]'");
$db->query("INSERT INTO {$tablepre}creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation)
VALUES ('$discuz_uid', '".addslashes($member['username'])."', '$creditstrans', '$creditstrans', '$amount', '0', '$timestamp', 'TFR'),
('$member[uid]', '$discuz_user', '$creditstrans', '$creditstrans', '0', '$netamount', '$timestamp', 'RCV')");
if(!empty($transfermessage)) {
$transfermessage = stripslashes($transfermessage);
$transfertime = gmdate($GLOBALS['_DCACHE']['settings']['dateformat'].' '.$GLOBALS['_DCACHE']['settings']['timeformat'], $timestamp + $timeoffset * 3600);
sendpm($member['uid'], 'transfer_subject', 'transfer_message', 0);
}
showmessage('credits_transaction_succeed', '', 1);
}
} else {
showmessage('action_closed', NULL, 'HALTED');
}
} elseif(submitcheck('exchangesubmit')) {
if(($exchangestatus || $outextcredits) && $outextcredits[$tocredits] || $extcredits[$fromcredits]['ratio'] && $extcredits[$tocredits]['ratio']) {
if(!submitcheck('confirm')) {
$outexange = strexists($tocredits, '|');
if($outexange) {
$netamount = floor($exchangeamount * $outextcredits[$tocredits]['ratiosrc'][${'fromcredits_'.$outi}] / $outextcredits[$tocredits]['ratiodesc'][${'fromcredits_'.$outi}]);
$fromcredits = ${'fromcredits_'.$outi};
} else {
if($extcredits[$tocredits]['ratio'] < $extcredits[$fromcredits]['ratio']) {
$netamount = ceil($exchangeamount * $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * (1 + $creditstax));
} else {
$netamount = floor($exchangeamount * $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * (1 + $creditstax));
}
}
include template('memcp_credits_action');
} else {
if(!$outexange && !$extcredits[$tocredits]['ratio']) {
showmessage('credits_exchange_invalid');
}
$amount = intval($amount);
if($outexange) {
$netamount = floor($amount * $outextcredits[$tocredits]['ratiosrc'][$fromcredits] / $outextcredits[$tocredits]['ratiodesc'][$fromcredits]);
} else {
if($extcredits[$tocredits]['ratio'] < $extcredits[$fromcredits]['ratio']) {
$netamount = ceil($amount * $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * (1 + $creditstax));
} else {
$netamount = floor($amount * $extcredits[$tocredits]['ratio'] / $extcredits[$fromcredits]['ratio'] * (1 + $creditstax));
}
}
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucresult = uc_user_login($discuz_user, $password);
list($tmp['uid']) = daddslashes($ucresult);
if($tmp['uid'] <= 0) {
showmessage('credits_password_invalid');
} elseif($fromcredits == $tocredits) {
showmessage('credits_exchange_invalid');
} elseif($amount <= 0) {
showmessage('credits_transaction_amount_invalid');
} elseif(${'extcredits'.$fromcredits} - $netamount < ($minbalance = $exchangemincredits)) {
showmessage('credits_balance_insufficient');
} elseif(!$outexange && !$netamount) {
showmessage('credits_net_amount_iszero');
}
if(!$outexange && !$extcredits[$fromcredits]['allowexchangeout']) {
showmessage('extcredits_disallowexchangeout');
}
if(!$outexange && !$extcredits[$tocredits]['allowexchangein']) {
showmessage('extcredits_disallowexchangein');
}
if(!$outexange) {
$creditsarray[$fromcredits] = -$netamount;
$creditsarray[$tocredits] = $amount;
updatecredits($discuz_uid, $creditsarray);
} else {
if(!array_key_exists($fromcredits, $outextcredits[$tocredits]['creditsrc'])) {
showmessage('extcredits_dataerror', NULL, 'HALTED');
}
list($toappid, $tocredits) = explode('|', $tocredits);
$ucresult = uc_credit_exchange_request($discuz_uid, $fromcredits, $tocredits, $toappid, $amount);
if(!$ucresult) {
showmessage('extcredits_dataerror', NULL, 'HALTED');
}
$creditsarray[$fromcredits] = -$netamount;
updatecredits($discuz_uid, $creditsarray);
$netamount = $amount;
$amount = $tocredits = 0;
}
$db->query("INSERT INTO {$tablepre}creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation)
VALUES ('$discuz_uid', '$discuz_user', '$fromcredits', '$tocredits', '$netamount', '$amount', '$timestamp', 'EXC')");
showmessage('credits_transaction_succeed', '', 1);
}
} else {
showmessage('action_closed', NULL, 'HALTED');
}
} elseif(submitcheck('addfundssubmit')) {
if($ec_ratio) {
if(!submitcheck('confirm')) {
$price = round(($addfundamount / $ec_ratio * 100) / 100, 1);
include template('memcp_credits_action');
} else {
include language('misc');
$amount = intval($amount);
if(!$amount || ($ec_mincredits && $amount < $ec_mincredits) || ($ec_maxcredits && $amount > $ec_maxcredits)) {
showmessage('credits_addfunds_amount_invalid');
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}orders WHERE uid='$discuz_uid' AND submitdate>='$timestamp'-180 LIMIT 1")) {
showmessage('credits_addfunds_ctrl');
}
if($ec_maxcreditspermonth) {
$query = $db->query("SELECT SUM(amount) FROM {$tablepre}orders WHERE uid='$discuz_uid' AND submitdate>='$timestamp'-2592000 AND status IN (2, 3)");
if(($db->result($query, 0)) + $amount > $ec_maxcreditspermonth) {
showmessage('credits_addfunds_toomuch');
}
}
$price = round(($amount / $ec_ratio * 100) / 100, 1);
$orderid = '';
//$apitype = 'tenpay';
require_once DISCUZ_ROOT.'./include/trade.func.php';
$requesturl = credit_payurl($price, $orderid);
$query = $db->query("SELECT orderid FROM {$tablepre}orders WHERE orderid='$orderid'");
if($db->num_rows($query)) {
showmessage('credits_addfunds_order_invalid');
}
$db->query("INSERT INTO {$tablepre}orders (orderid, status, uid, amount, price, submitdate)
VALUES ('$orderid', '1', '$discuz_uid', '$amount', '$price', '$timestamp')");
showmessage('credits_addfunds_succeed', '', 1);
}
} else {
showmessage('action_closed', NULL, 'HALTED');
}
} else {
$extcredits_exchange = array();
if(!empty($extcredits)) {
foreach($extcredits as $key => $value) {
if($value['allowexchangein'] || $value['allowexchangeout']) {
$extcredits_exchange['extcredits'.$key] = array('title' => $value['title'], 'unit' => $value['unit']);
}
}
}
include template('memcp_credits');
}
} elseif($action == 'creditslog') {
if($operation == 'paymentlog') {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}paymentlog WHERE uid='$discuz_uid'");
$multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=paymentlog");
$totalamount = $db->result($query, 1);
$loglist = array();
$query = $db->query("SELECT p.*, f.fid, f.name, t.subject, t.author, t.dateline AS tdateline FROM {$tablepre}paymentlog p
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
WHERE p.uid='$discuz_uid' ORDER BY p.dateline DESC
LIMIT $start_limit, $tpp");
while($log = $db->fetch_array($query)) {
$log['authorenc'] = rawurlencode($log['authorenc']);
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['tdateline'] = dgmdate("$dateformat $timeformat", $log['tdateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('memcp_credits_log');
} elseif($operation == 'incomelog') {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}paymentlog WHERE authorid='$discuz_uid'");
$multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=incomelog");
$loglist = array();
$query = $db->query("SELECT p.*, m.username, f.fid, f.name, t.subject, t.dateline AS tdateline FROM {$tablepre}paymentlog p
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
LEFT JOIN {$tablepre}members m ON m.uid=p.uid
WHERE p.authorid='$discuz_uid' ORDER BY p.dateline DESC
LIMIT $start_limit, $tpp");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['tdateline'] = dgmdate("$dateformat $timeformat", $log['tdateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('memcp_credits_log');
} elseif($operation == 'attachpaymentlog') {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}attachpaymentlog WHERE uid='$discuz_uid'");
$multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=attachpaymentlog");
$loglist = array();
$query = $db->query("SELECT ap.*, a.filename, a.pid, a.dateline as adateline, t.subject, t.tid, m.username FROM {$tablepre}attachpaymentlog ap
LEFT JOIN {$tablepre}attachments a ON a.aid=ap.aid
LEFT JOIN {$tablepre}threads t ON t.tid=a.tid
LEFT JOIN {$tablepre}members m ON m.uid=ap.authorid
WHERE ap.uid='$discuz_uid' ORDER BY ap.dateline DESC
LIMIT $start_limit, $tpp");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['adateline'] = dgmdate("$dateformat $timeformat", $log['adateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('memcp_credits_log');
} elseif($operation == 'attachincomelog') {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}attachpaymentlog WHERE authorid='$discuz_uid'");
$multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=attachincomelog");
$totalamount = $db->result($query, 1);
$loglist = array();
$query = $db->query("SELECT ap.*, a.filename, a.pid, a.dateline as adateline, t.subject, t.tid, m.username FROM {$tablepre}attachpaymentlog ap
LEFT JOIN {$tablepre}attachments a ON a.aid=ap.aid
LEFT JOIN {$tablepre}threads t ON t.tid=a.tid
LEFT JOIN {$tablepre}members m ON m.uid=ap.uid
WHERE ap.authorid='$discuz_uid' ORDER BY ap.dateline DESC
LIMIT $start_limit, $tpp");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['adateline'] = dgmdate("$dateformat $timeformat", $log['adateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('memcp_credits_log');
} elseif($operation == 'rewardpaylog') {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}rewardlog WHERE authorid='$discuz_uid'");
$multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=incomelog");
$loglist = array();
$query = $db->query("SELECT
r.*, m.uid, m.username
, f.fid, f.name, t.subject, t.price
FROM
{$tablepre}rewardlog r
LEFT JOIN {$tablepre}threads t ON t.tid=r.tid
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
LEFT JOIN {$tablepre}members m ON m.uid=r.answererid
WHERE r.authorid='$discuz_uid' ORDER BY r.dateline DESC
LIMIT $start_limit, $tpp");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['price'] = abs($log['price']);
$loglist[] = $log;
}
include template('memcp_credits_log');
} elseif($operation == 'rewardincomelog') {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}rewardlog WHERE answererid='$discuz_uid'");
$multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=incomelog");
$loglist = array();
$query = $db->query("SELECT r.*, m.uid, m.username, f.fid, f.name, t.subject, t.price FROM {$tablepre}rewardlog r
LEFT JOIN {$tablepre}threads t ON t.tid=r.tid
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
LEFT JOIN {$tablepre}members m ON m.uid=r.authorid
WHERE r.answererid='$discuz_uid' and r.authorid>0 ORDER BY r.dateline DESC
LIMIT $start_limit, $tpp");
while($log = $db->fetch_array($query)) {
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$log['price'] = abs($log['price']);
$loglist[] = $log;
}
include template('memcp_credits_log');
} else {
$operation = 'creditslog';
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}creditslog WHERE uid='$discuz_uid'");
$multipage = multi($db->result($query, 0), $tpp, $page, "memcp.php?action=creditslog&operation=creditslog");
$loglist = array();
$query = $db->query("SELECT * FROM {$tablepre}creditslog WHERE uid='$discuz_uid' ORDER BY dateline DESC LIMIT $start_limit, $tpp");
while($log = $db->fetch_array($query)) {
$log['fromtoenc'] = rawurlencode($log['fromto']);
$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('memcp_credits_log');
}
} elseif($action == 'usergroups') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
// if(!$allowmultigroups) {
// showmessage('group_nopermission', NULL, 'NOPERM');
// }
$switchmaingroup = $grouppublic || $grouptype == 'member' ? 1 : 0;
$extgroupidarray = $extgroupids ? explode("\t", $extgroupids) : array();
foreach($extgroupidarray as $key => $val) {
$val = intval($val);
if($val < 1) {
unset($extgroupidarray[$key]);
} else {
$extgroupidarray[$key] = intval($val);
}
}
if(implode("\t", $extgroupidarray) != $extgroupids) {
$extgroupids = implode("\t", $extgroupidarray);
$groupexpiryadd= empty($extgroupids) ? ", groupexpiry=''" : '';
$db->query("UPDATE {$tablepre}members SET extgroupids='$extgroupids' $groupexpiryadd WHERE uid='$discuz_uid'");
}
if(empty($type)) {
$groupterms = unserialize($db->result_first("SELECT groupterms FROM {$tablepre}memberfields WHERE uid='$discuz_uid'"));
$maingroup = $extgroups = $publicgroups = $grouplist = array();
$query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE (type='special' AND system<>'private' AND radminid='0') OR (type='member' AND '$credits'>=creditshigher AND '$credits'<creditslower) OR groupid IN ('$groupid'".($extgroupids ? ', '.str_replace("\t", ',', $extgroupids) : '').") ORDER BY type, system");
while($group = $db->fetch_array($query)) {
if(!$group['allowmultigroups']) {
$group['grouptitle'] = '<u>'.$group['grouptitle'].'</u>';
}
$group['mainselected'] = $group['groupid'] == $groupid ? 'checked="checked"' : '';
$group['maindisabled'] = $switchmaingroup && (($group['system'] != 'private' && ($group['system'] == "0\t0" || $group['groupid'] == $groupid || in_array($group['groupid'], $extgroupidarray))) || $group['type'] == 'member') ? '' : 'disabled';
$group['allowsetmain'] = $switchmaingroup && (($group['system'] != 'private' && ($group['system'] == "0\t0" || $group['groupid'] == $groupid || in_array($group['groupid'], $extgroupidarray))) || $group['type'] == 'member') ? true : false;
$group['dailyprice'] = $group['minspan'] = 0;
if($group['system'] != 'private') {
list($group['dailyprice'], $group['minspan']) = explode("\t", $group['system']);
}
if($group['groupid'] == $groupid && !empty($groupterms['main'])) {
$group['expiry'] = gmdate($dateformat, $groupterms['main']['time'] + $timeoffset * 3600);
} elseif(isset($groupterms['ext'][$group['groupid']])) {
$group['expiry'] = gmdate($dateformat, $groupterms['ext'][$group['groupid']] + $timeoffset * 3600);
} else {
$group['expiry'] = '-';
}
if($group['groupid'] == $groupid) {
$maingroup = $group;
$group['owned'] = true;
} elseif(in_array($group['groupid'], $extgroupidarray)) {
$extgroups[] = $group;
$group['owned'] = true;
} else {
$group['owned'] = false;
}
if($group['system'] != 'private') {
$publicgroups[$group['groupid']] = $group;
}
}
$query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE type!='system' ORDER BY type, creditshigher");
while ($group = $db->fetch_array($query)) {
$grouplist[$group['type']][] = $group;
}
include template('memcp_usergroups');
} else {
if($type == 'main' && $switchmaingroup) {
$edit = intval($edit);
$group = $db->fetch_first("SELECT groupid, type, system, grouptitle, allowmultigroups FROM {$tablepre}usergroups WHERE groupid='$edit' AND (".($extgroupids ? 'groupid IN ('.str_replace("\t", ',', $extgroupids).') OR ' : '')."(type='special' AND system='0\t0' AND radminid='0') OR (type='member' AND '$credits'>=creditshigher AND '$credits'<creditslower))");
if(!$group) {
showmessage('undefined_action', NULL, 'HALTED');
}
if(!submitcheck('groupsubmit')) {
include template('memcp_usergroups_misc');
dexit();
}
$extgroupidsnew = $groupid;
foreach(explode("\t", $extgroupids) as $extgroupid) {
if($extgroupid && $extgroupid != $edit) {
$extgroupidsnew .= "\t".$extgroupid;
}
}
$adminidnew = in_array($adminid, array(1, 2, 3)) ? $adminid : ($group['type'] == 'special' ? -1 : 0);
$db->query("UPDATE {$tablepre}members SET groupid='$edit', adminid='$adminidnew', extgroupids='$extgroupidsnew' WHERE uid='$discuz_uid'");
showmessage('usergroups_update_succeed', 'memcp.php?action=usergroups');
} elseif($type == 'extended') {
$group = $db->fetch_first("SELECT groupid, type, system, grouptitle FROM {$tablepre}usergroups WHERE groupid='$edit' AND (".($extgroupids ? 'groupid IN ('.str_replace("\t", ',', $extgroupids).') OR ' : '')."(type='special' AND system<>'private' AND radminid='0'))");
if(!$group) {
showmessage('undefined_action', NULL, 'HALTED');
}
$join = !in_array($group['groupid'], explode("\t", $extgroupids));
$group['dailyprice'] = $group['minspan'] = 0;
if($group['system'] != 'private') {
list($group['dailyprice'], $group['minspan']) = explode("\t", $group['system']);
if($group['dailyprice'] > -1 && $group['minspan'] == 0) {
$group['minspan'] = 1;
}
}
if(!isset($extcredits[$creditstrans])) {
showmessage('credits_transaction_disabled');
}
if(!submitcheck('groupsubmit')) {
$usermoney = ${'extcredits'.$creditstrans};
$usermaxdays = $group['dailyprice'] > 0 ? round($usermoney / $group['dailyprice']) : 0;
$group['minamount'] = $group['dailyprice'] * $group['minspan'];
include template('memcp_usergroups_misc');
} else {
$groupterms = unserialize($db->result_first("SELECT groupterms FROM {$tablepre}memberfields WHERE uid='$discuz_uid'"));
if($join) {
$extgroupidsarray = array();
foreach(array_unique(array_merge(explode("\t", $extgroupids), array($edit))) as $extgroupid) {
if($extgroupid) {
$extgroupidsarray[] = $extgroupid;
}
}
$extgroupidsnew = implode("\t", $extgroupidsarray);
if($group['dailyprice']) {
if(($days = intval($days)) < $group['minspan']) {
showmessage('usergroups_span_invalid');
}
if(${'extcredits'.$creditstrans} - ($amount = $days * $group['dailyprice']) < ($minbalance = 0)) {
showmessage('credits_balance_insufficient');
}
$groupexpirynew = $timestamp + $days * 86400;
$groupterms['ext'][$edit] = $groupexpirynew;
$groupexpirynew = groupexpiry($groupterms);
$db->query("UPDATE {$tablepre}members SET groupexpiry='$groupexpirynew', extgroupids='$extgroupidsnew', extcredits$creditstrans=extcredits$creditstrans-'$amount' WHERE uid='$discuz_uid'");
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".addslashes(serialize($groupterms))."' WHERE uid='$discuz_uid'");
$db->query("INSERT INTO {$tablepre}creditslog (uid, fromto, sendcredits, receivecredits, send, receive, dateline, operation)
VALUES ('$discuz_uid', '$discuz_user', '$creditstrans', '0', '$amount', '0', '$timestamp', 'UGP')");
} else {
$db->query("UPDATE {$tablepre}members SET extgroupids='$extgroupidsnew' WHERE uid='$discuz_uid'");
}
showmessage('usergroups_join_succeed', 'memcp.php?action=usergroups');
} else {
if($edit != $groupid) {
if(isset($groupterms['ext'][$edit])) {
unset($groupterms['ext'][$edit]);
}
$groupexpirynew = groupexpiry($groupterms);
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".addslashes(serialize($groupterms))."' WHERE uid='$discuz_uid'");
} else {
$groupexpirynew = 'groupexpiry';
}
$extgroupidsarray = array();
foreach(explode("\t", $extgroupids) as $extgroupid) {
if($extgroupid && $extgroupid != $edit) {
$extgroupidsarray[] = $extgroupid;
}
}
$extgroupidsnew = implode("\t", array_unique($extgroupidsarray));
$db->query("UPDATE {$tablepre}members SET groupexpiry='$groupexpirynew', extgroupids='$extgroupidsnew' WHERE uid='$discuz_uid'");
showmessage('usergroups_exit_succeed', 'memcp.php?action=usergroups');
}
}
} else {
showmessage('usergroups_nonexistence');
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/memcp.php
|
PHP
|
asf20
| 37,081
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: faq.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
define('CURSCRIPT', 'faq');
require_once './include/common.inc.php';
$discuz_action = 51;
$keyword = isset($keyword) ? dhtmlspecialchars($keyword) : '';
$faqparent = $faqsub = array();
$query = $db->query("SELECT id, fpid, title FROM {$tablepre}faqs ORDER BY displayorder");
while($faq = $db->fetch_array($query)) {
if(empty($faq['fpid'])) {
$faqparent[$faq['id']] = $faq;
} else {
$faqsub[$faq['fpid']][] = $faq;
}
}
if($action == 'faq') {
$id = intval($id);
if($ffaq = $db->fetch_first("SELECT title FROM {$tablepre}faqs WHERE fpid='$id'")) {
$navigation = "» $ffaq[title]";
$faqlist = array();
$messageid = empty($messageid) ? 0 : $messageid;
$query = $db->query("SELECT id,title,message FROM {$tablepre}faqs WHERE fpid='$id' ORDER BY displayorder");
while($faq = $db->fetch_array($query)) {
if(!$messageid) {
$messageid = $faq['id'];
}
$faqlist[] = $faq;
}
} else {
showmessage("faq_content_empty", 'faq.php');
}
} elseif($action == 'search') {
if(submitcheck('searchsubmit')) {
$keyword = isset($keyword) ? trim($keyword) : '';
if($keyword) {
$sqlsrch = '';
$searchtype = in_array($searchtype, array('all', 'title', 'message')) ? $searchtype : 'all';
switch($searchtype) {
case 'all':
$sqlsrch = "WHERE title LIKE '%$keyword%' OR message LIKE '%$keyword%'";
break;
case 'title':
$sqlsrch = "WHERE title LIKE '%$keyword%'";
break;
case 'message':
$sqlsrch = "WHERE message LIKE '%$keyword%'";
break;
}
$keyword = stripslashes($keyword);
$faqlist = array();
$query = $db->query("SELECT fpid, title, message FROM {$tablepre}faqs $sqlsrch ORDER BY displayorder");
while($faq = $db->fetch_array($query)) {
if(!empty($faq['fpid'])) {
$faq['title'] = preg_replace("/(?<=[\s\"\]>()]|[\x7f-\xff]|^)(".preg_quote($keyword, '/').")(([.,:;-?!()\s\"<\[]|[\x7f-\xff]|$))/siU", "<u><b><font color=\"#FF0000\">\\1</font></b></u>\\2", stripslashes($faq['title']));
$faq['message'] = preg_replace("/(?<=[\s\"\]>()]|[\x7f-\xff]|^)(".preg_quote($keyword, '/').")(([.,:;-?!()\s\"<\[]|[\x7f-\xff]|$))/siU", "<u><b><font color=\"#FF0000\">\\1</font></b></u>\\2", stripslashes($faq['message']));
$faqlist[] = $faq;
}
}
} else {
showmessage('faq_keywords_empty', 'faq.php');
}
}
} elseif($action == 'credits') {
if(empty($extcredits)) {
showmessage('credits_disabled');
}
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumlist = forumselect(FALSE, 0, $fid);
$policyarray = array();
foreach($creditspolicy as $operation => $policy) {
!$forum && $policyarray[$operation] = $policy;
if(in_array($operation, array('post', 'reply', 'digest', 'postattach', 'getattach'))) {
if($forum) {
$policyarray[$operation] = $forum[$operation.'credits'] ? $forum[$operation.'credits'] : $creditspolicy[$operation];
}
}
}
$creditsarray = array();
for($i = 1; $i <= 8; $i++) {
if(isset($extcredits[$i])) {
foreach($policyarray as $operation => $policy) {
$addcredits = in_array($operation, array('getattach', 'forum_getattach', 'sendpm', 'search')) ? -$policy[$i] : $policy[$i];
if($operation != 'lowerlimit') {
$creditsarray[$operation][$i] = empty($policy[$i]) ? 0 : (is_numeric($policy[$i]) ? '<b>'.($addcredits > 0 ? '+'.$addcredits : $addcredits).'</b> '.$extcredits[$i]['unit'] : $policy[$i]);
} else {
$creditsarray[$operation][$i] = '<b>'.intval($addcredits).'</b> '.$extcredits[$i]['unit'];
}
}
}
}
if(!$forum) {
$query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE type='member' ORDER BY type");
while($group = $db->fetch_array($query)) {
$extgroups[] = $group;
}
}
include template('credits');
exit;
}
include template('faq');
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/faq.php
|
PHP
|
asf20
| 4,056
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: seccode.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
define('CURSCRIPT', 'seccode');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
$refererhost = parse_url($_SERVER['HTTP_REFERER']);
$refererhost['host'] .= !empty($refererhost['port']) ? (':'.$refererhost['port']) : '';
if($seccodedata['type'] < 2 && ($refererhost['host'] != $_SERVER['HTTP_HOST'] || !$seccodestatus) || $seccodedata['type'] == 2 && !extension_loaded('ming') && $_POST['fromFlash'] != 1 || $seccodedata['type'] == 3 && $_GET['fromFlash'] != 1) {
exit('Access Denied');
}
if($seclevel) {
if($update && $seccodedata['type'] != 3) {
$seccode = random(6, 1) + $seccode{0} * 1000000;
updatesession();
}
} else {
$key = $seccodedata['type'] != 3 ? '' : $_DCACHE['settings']['authkey'].date('Ymd');
list($seccode, $expiration, $seccodeuid) = explode("\t", authcode($_DCOOKIE['secc'], 'DECODE', $key));
if($seccodeuid != $discuz_uid || $timestamp - $expiration > 600) {
exit('Access Denied');
}
}
if(!$nocacheheaders) {
@dheader("Expires: -1");
@dheader("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@dheader("Pragma: no-cache");
}
include_once './include/seccode.class.php';
$code = new seccode();
$code->code = $seccode;
$code->type = $seccodedata['type'];
$code->width = $seccodedata['width'];
$code->height = $seccodedata['height'];
$code->background = $seccodedata['background'];
$code->adulterate = $seccodedata['adulterate'];
$code->ttf = $seccodedata['ttf'];
$code->angle = $seccodedata['angle'];
$code->color = $seccodedata['color'];
$code->size = $seccodedata['size'];
$code->shadow = $seccodedata['shadow'];
$code->animator = $seccodedata['animator'];
$code->fontpath = DISCUZ_ROOT.'./images/fonts/';
$code->datapath = DISCUZ_ROOT.'./images/seccode/';
$code->includepath = DISCUZ_ROOT.'./include/';
$code->display();
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/seccode.php
|
PHP
|
asf20
| 2,041
|
<script>
varname = location.search.substr(1);
var varnames = varname.split('|');
varname = varnames[0];
var varnamev = !varnames[1] ? varnames[0] + '_v' : varnames[1];
function getcolor(event) {
var hex = [0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'];
if(event.clientX > 164 || event.clientY > 164) {
return;
}
var hsv = new Object();
var h = 164;
var y = event.clientY;
hsv.h = 360 * event.clientX / 164;
if (y > h/2) {
hsv.s = 1.0;
hsv.v = 2 * (h - y) / h;
}
else {
hsv.v = 1.0;
hsv.s = y / (h/2);
}
var rgb = hsvToRgb(hsv);
var red = Math.round(255 * rgb.r);
var green = Math.round(255 * rgb.g);
var blue = Math.round(255 * rgb.b);
hexstr = '#' + hex[(red - (red % 16)) / 16].toString() + hex[red % 16].toString()
+ hex[(green - (green % 16)) / 16].toString() + hex[green % 16].toString()
+ hex[(blue - (blue % 16)) / 16].toString() + hex[blue % 16].toString()
document.getElementById('box').style.backgroundColor = hexstr;
document.getElementById('colorhex').value = hexstr;
}
function hsvToRgb(hsv) {
var rgb = new Object();
var i, f, p, q, t;
if(hsv.s == 0) {
// achromatic (grey)
rgb.r = rgb.g = rgb.b = hsv.v;
return rgb;
}
hsv.h /= 60;
i = Math.floor( hsv.h );
f = hsv.h - i;
p = hsv.v * ( 1 - hsv.s );
q = hsv.v * ( 1 - hsv.s * f );
t = hsv.v * ( 1 - hsv.s * ( 1 - f ) );
switch( i ) {
case 0:
rgb.r = hsv.v;
rgb.g = t;
rgb.b = p;
break;
case 1:
rgb.r = q;
rgb.g = hsv.v;
rgb.b = p;
break;
case 2:
rgb.r = p;
rgb.g = hsv.v;
rgb.b = t;
break;
case 3:
rgb.r = p;
rgb.g = q;
rgb.b = hsv.v;
break;
case 4:
rgb.r = t;
rgb.g = p;
rgb.b = hsv.v;
break;
default:
rgb.r = hsv.v;
rgb.g = p;
rgb.b = q;
break;
}
return rgb;
}
function setvalue(obj) {
parent.$(varnamev).value = obj.value;
if(parent.$(varnamev).onchange) {
var change = parent.$(varnamev).onchange.toString();
if(change) {
var start = change.indexOf('{');
var end = change.lastIndexOf('}');
var s = change.substring(start + 1, end);
s = s.replace(/this\.value/ig, "'" + obj.value + "'");
s = s.replace(/imgdirurl/ig, "parent.imgdirurl");
s = s.replace(/\$\(/ig, "parent.$(");
//alert(s)
eval(s)
}
}
parent.$(varname).style.background = obj.value;
document.getElementById('box').style.background = obj.value;
}
function updatecolorpreview() {
}
</script>
<style>
body {
margin: 0px;
background-color: #FFFFFF;
}
table{ border:1px solid #333; }
</style>
<body onmousedown="getcolor(event);setvalue(document.getElementById('colorhex'))" scrolling="no">
<table cellspacing="0" cellpadding="0">
<tr><td colspan="2"><img src="color.jpg" style="cursor: crosshair ;width: 164px; height: 164px"></td></tr>
<tr height="20"><td width="20" id="box"></td>
<td width="144">
<input id="colorhex" style="padding: 2px;font: 12px Arial, Tahoma;cursor: pointer;width: 100%;border: 0px" onkeyup="setvalue(this)" onclick="setvalue(this)">
</td></tr>
</table>
<script>
var obj = parent.$(varnamev);
document.getElementById('colorhex').value = obj.value;
try {
document.getElementById('box').style.background = cvalue;
} catch(e) {}
</script>
</body>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/images/admincp/getcolor.htm
|
HTML
|
asf20
| 3,309
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: frame.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
define('NOROBOT', TRUE);
include './include/common.inc.php';
$_GET['referer'] = urldecode($_GET['referer']);
$_SERVER['HTTP_REFERER'] = $_GET['referer'] ? $_GET['referer'] : $_SERVER['HTTP_REFERER'];
$_SERVER['HTTP_REFERER'] = !empty($_SERVER['HTTP_REFERER']) && substr($_SERVER['HTTP_REFERER'], 0, strlen($boardurl)) == $boardurl ? $_SERVER['HTTP_REFERER'] : (!empty($_GET['referer']) && substr($_GET['referer'], 0, strlen($boardurl)) == $boardurl ? $_GET['referer'] : $indexname);
if(empty($_SERVER['HTTP_REFERER'])) {
dheader("Location:$indexname");
}
if(!$_DCACHE['settings']['frameon']) {
showmessage('frame_off');
}
$_SERVER['HTTP_REFERER'] = preg_replace("/[&?]frameon=(yes|no)/i", '', $_SERVER['HTTP_REFERER']);
$newurl = $_SERVER['HTTP_REFERER'].(strpos($_SERVER['HTTP_REFERER'], '?') !== FALSE ? '&' : '?').'frameon=no';
if($_GET['frameon'] == 'no') {
dsetcookie('frameon', 'no', 31536000);
dheader("Location:$newurl");
} else {
dsetcookie('frameon', 'yes', 31536000);
$_DCOOKIE['frameon'] = 'yes';
include template('frame');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/frame.php
|
PHP
|
asf20
| 1,263
|
<?php
/*
[Discuz!] (C)2001-2006 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: config5.inc.php,v $
$Revision: 1.9 $
$Date: 2007/01/26 01:11:32 $
*/
// [CH] 以下变量请根据空间商提供的账号参数修改,如有疑问,请联系服务器提供商
$dbhost = 'localhost'; // 数据库服务器
$dbuser = '51shangcheng'; // 数据库用户名
$dbpw = '18946981'; // 数据库密码
$dbname = '51shangcheng'; // 数据库名
$pconnect = 0; // 数据库持久连接 0=关闭, 1=打开
// [CH] Mysql 辅助服务器设置,只有当您拥有多个 Mysql 服务器且协同工作时请进行设置
$multiserver = array(); // 服务器变量初始化,请勿修改或删除
// [CH] 如您对 cookie 作用范围有特殊要求, 或论坛登录不正常, 请修改下面变量, 否则请保持默认
$cookiepre = 'Put_'; // cookie 前缀
$cookiedomain = ''; // cookie 作用域
$cookiepath = '/'; // cookie 作用路径
// [CH] 论坛投入使用后不能修改的变量
$tablepre = 'cdb_'; // 表名前缀, 同一数据库安装多个论坛请修改此处
// [CH] 小心修改以下变量, 否则可能导致论坛无法正常使用
$database = 'mysql'; // 论坛数据库类型,请勿修改
$dbcharset = ''; // MySQL 字符集, 可选 'gbk', 'big5', 'utf8', 'latin1', 留空为按照论坛字符集设定
$charset = 'utf-8'; // 论坛页面默认字符集, 可选 'gbk', 'big5', 'utf-8'
$headercharset = 0; // 强制论坛页面使用默认字符集,可避免部分服务器空间页面出现乱码,一般无需开启。 0=关闭 1= 开启
$tplrefresh = 1; // 论坛风格模板自动刷新开关 0=关闭, 1=打开。
// [CH] 论坛安全设置, 调整以下设置,可以增强论坛的安全性能和防御性能
$adminemail = 'admin@51shangcheng.cn'; // 系统管理员 Email
$forumfounders = '1'; // 论坛创始人 UID, 可以支持多个创始人,之间使用 “,” 分隔。[出于安全考虑,请务必设置一名管理员为创始人]
// 论坛创始人可对其他管理员进行设置。如果不设置论坛创始人,则论坛管理员之间权利平等。
$dbreport = 0; // 论坛出现数据库错误时,是否通过 email 发送错误报告给系统管理员
$errorreport = 1; // 是否屏蔽程序错误信息, 0=屏蔽所有错误(安全) 1=报告给管理员和版主(安全) 2=报告给任何人
$attackevasive = 0; // 论坛防御级别,可防止大量的非正常请求造成的拒绝服务攻击
// 防护大量非正常请求造成的拒绝服务攻击,
// 0=关闭, 1=cookie 刷新限制, 2=限制代理访问, 4=二次请求, 8=回答问题(第一次访问时需要回答问题)
// 组合为: 1|2, 1|4, 2|8, 1|2|4...
$urlxssdefend = 1; // 论坛访问页面防御开关,可避免用户通过非法的url地址对本站用户造成危害,建议打开。1=打开 0关闭
$admincp = array();
$admincp['forcesecques'] = 0; // 管理人员必须设置安全提问才能进入系统设置, 0=否, 1=是[安全]
$admincp['checkip'] = 1; // 后台管理操作是否验证管理员的 IP, 1=是[安全], 0=否。仅在管理员无法登陆后台时设置 0。
$admincp['tpledit'] = 0; // 是否允许在线编辑论坛模板 1=是 0=否[安全]
$admincp['runquery'] = 1; // 是否允许后台运行 SQL 语句 1=是 0=否[安全]
$admincp['dbimport'] = 1; // 是否允许后台恢复论坛数据 1=是 0=否[安全]
// ============================================================================
define('UC_CONNECT', 'mysql');
define('UC_DBHOST', 'localhost');
define('UC_DBUSER', '51shangcheng');
define('UC_DBPW', '18946981');
define('UC_DBNAME', '51shangcheng');
define('UC_DBCHARSET', 'utf8');
define('UC_DBTABLEPRE', '`51shangcheng`.cdb_uc_');
define('UC_DBCONNECT', '0');
define('UC_KEY', '7dL5d68bhb27H178xefbj1n9a6P2j8s53390sbDaLcgbp3u3Q2O5Cfw9gd0af0de');
define('UC_API', 'http://www.51shangcheng.cn/uc_server');
define('UC_CHARSET', 'utf-8');
define('UC_IP', '127.0.0.1');
define('UC_APPID', '1');
define('UC_PPP', '20');
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/config.inc.php
|
PHP
|
asf20
| 4,228
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: register.php 17381 2008-12-17 02:35:08Z tiger $
*/
define('CURSCRIPT', 'register');
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_profilefields.php';
require_once DISCUZ_ROOT.'./uc_client/client.php';
$discuz_action = 5;
if($discuz_uid) {
showmessage('login_succeed', $indexname);
} elseif (!$regstatus || !$ucactivation) {
if($action == 'activation' || $activationauth) {
if(!$ucactivation) {
showmessage('register_disable_activation');
}
} elseif(!$regstatus) {
showmessage('register_disable');
}
}
$inviteconfig = array();
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN ('bbrules', 'bbrulestxt', 'welcomemsg', 'welcomemsgtitle', 'welcomemsgtxt', 'inviteconfig')");
while($setting = $db->fetch_array($query)) {
$$setting['variable'] = $setting['value'];
}
$invitecode = $regstatus > 1 && $invitecode ? dhtmlspecialchars($invitecode) : '';
if($regstatus > 1) {
$inviterewardcredit = $inviteaddcredit = $invitedaddcredit = '';
@extract(unserialize($inviteconfig));
}
$groupinfo = $db->fetch_first("SELECT groupid, allownickname, allowcstatus, allowcusbbcode, allowsigbbcode, allowsigimgcode, maxsigsize FROM {$tablepre}usergroups WHERE ".($regverify ? "groupid='8'" : "creditshigher<=".intval($initcredits)." AND ".intval($initcredits)."<creditslower LIMIT 1"));
$seccodecheck = $seccodestatus & 1;
$secqaacheck = $secqaa['status'][1];
$fromuid = !empty($_DCOOKIE['promotion']) && $creditspolicy['promotion_register'] ? intval($_DCOOKIE['promotion']) : 0;
$action = isset($action) ? $action : '';
$username = isset($username) ? $username : '';
$bbrulehash = $bbrules ? substr(md5(FORMHASH), 0, 8) : '';
if(!submitcheck('regsubmit', 0, $seccodecheck, $secqaacheck)) {
if($action == 'activation') {
$auth = explode("\t", authcode($auth, 'DECODE'));
if(FORMHASH != $auth[1]) {
showmessage('register_activation_invalid', 'logging.php?action=login');
}
$username = $auth[0];
$activationauth = authcode("$auth[0]\t".FORMHASH, 'ENCODE');
}
$referer = isset($referer) ? dhtmlspecialchars($referer) : dreferer();
$fromuser = !empty($fromuser) ? dhtmlspecialchars($fromuser) : '';
if($fromuid) {
$query = $db->query("SELECT username FROM {$tablepre}members WHERE uid='$fromuid'");
if($db->num_rows($query)) {
$fromuser = dhtmlspecialchars($db->result($query, 0));
} else {
dsetcookie('promotion');
}
}
$bbrulestxt = nl2br("\n$bbrulestxt\n\n");
if($action == 'activation') {
$auth = dhtmlspecialchars($auth);
}
if($seccodecheck) {
$seccode = random(6, 1);
}
if($secqaa['status'][1]) {
$seccode = random(1, 1) * 1000000 + substr($seccode, -6);
}
$username = dhtmlspecialchars($username);
include template('register');
} else {
if($bbrules && $bbrulehash != $_POST['agreebbrule']) {
showmessage('register_rules_agree');
}
$activation = array();
if(isset($activationauth)) {
$activationauth = explode("\t", authcode($activationauth, 'DECODE'));
if($activationauth[1] == FORMHASH && !($activation = daddslashes(uc_get_user($activationauth[0]), 1))) {
showmessage('register_activation_invalid', 'logging.php?action=login');
}
}
if(!$activation) {
$username = addslashes(trim(stripslashes($username)));
if(uc_get_user($username) && !$db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$username'")) {
if($inajax) {
showmessage('profile_username_duplicate');
} else {
showmessage('register_activation_message', 'logging.php?action=login');
}
}
if($password != $password2) {
showmessage('profile_passwd_notmatch');
}
if(!$password || $password != addslashes($password)) {
showmessage('profile_passwd_illegal');
}
$email = trim($email);
}
$guestexp = '\xA1\xA1|\xAC\xA3|^Guest|^\xD3\xCE\xBF\xCD|\xB9\x43\xAB\xC8';
$censorexp = '/^('.str_replace(array('\\*', "\r\n", ' '), array('.*', '|', ''), preg_quote(($censoruser = trim($censoruser)), '/')).')$/i';
if($censoruser && @preg_match($censorexp, $username)) {
showmessage('profile_username_protect');
}
$fieldadd1 = $fieldadd2 = '';
foreach($_DCACHE['fields_required'] as $field) {
$field_key = 'field_'.$field['fieldid'];
$field_val = ${'field_'.$field['fieldid'].'new'};
if($field['required'] && trim($field_val) == '') {
showmessage('profile_required_info_invalid');
} elseif($field['selective'] && $field_val != '' && !isset($field['choices'][$field_val])) {
showmessage('undefined_action', NULL, 'HALTED');
} else {
$fieldadd1 .= ", $field_key";
$fieldadd2 .= ', \''.dhtmlspecialchars($field_val).'\'';
}
}
if($regverify == 2 && !trim($regmessage)) {
showmessage('profile_required_info_invalid');
}
if($ipregctrl) {
foreach(explode("\n", $ipregctrl) as $ctrlip) {
if(preg_match("/^(".preg_quote(($ctrlip = trim($ctrlip)), '/').")/", $onlineip)) {
$ctrlip = $ctrlip.'%';
$regctrl = 72;
break;
} else {
$ctrlip = $onlineip;
}
}
} else {
$ctrlip = $onlineip;
}
if($regstatus > 1) {
if($regstatus == 2 && !$invitecode) {
showmessage('register_invite_notfound');
} elseif($invitecode) {
$groupinfo['groupid'] = $invitegroupid ? intval($invitegroupid) : $groupinfo['groupid'];
$invite = $db->fetch_first("SELECT uid, invitecode, inviteip, expiration FROM {$tablepre}invites WHERE invitecode='$invitecode' AND status IN ('1', '3')");
if(!$invite) {
showmessage('register_invite_error');
} else {
if($invite['inviteip'] == $onlineip) {
showmessage('register_invite_iperror');
} elseif($invite['expiration'] < $timestamp) {
showmessage('register_invite_expiration');
}
}
}
}
if($regctrl) {
$query = $db->query("SELECT ip FROM {$tablepre}regips WHERE ip LIKE '$ctrlip' AND count='-1' AND dateline>$timestamp-'$regctrl'*3600 LIMIT 1");
if($db->num_rows($query)) {
showmessage('register_ctrl', NULL, 'HALTED');
}
}
$secques = $questionid > 0 ? random(8) : '';
if(!$activation) {
$uid = uc_user_register($username, $password, $email, $questionid, $answer);
if($uid <= 0) {
if($uid == -1) {
showmessage('profile_username_illegal');
} elseif($uid == -2) {
showmessage('profile_username_protect');
} elseif($uid == -3) {
showmessage('profile_username_duplicate');
} elseif($uid == -4) {
showmessage('profile_email_illegal');
} elseif($uid == -5) {
showmessage('profile_email_domain_illegal');
} elseif($uid == -6) {
showmessage('profile_email_duplicate');
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
}
} else {
list($uid, $username, $email) = $activation;
}
if($db->result_first("SELECT uid FROM {$tablepre}members WHERE uid='$uid'")) {
if(!$activation) {
uc_user_delete($uid);
}
showmessage('profile_uid_duplicate');
}
if($regfloodctrl) {
if($regattempts = $db->result_first("SELECT count FROM {$tablepre}regips WHERE ip='$onlineip' AND count>'0' AND dateline>'$timestamp'-86400")) {
if($regattempts >= $regfloodctrl) {
showmessage('register_flood_ctrl', NULL, 'HALTED');
} else {
$db->query("UPDATE {$tablepre}regips SET count=count+1 WHERE ip='$onlineip' AND count>'0'");
}
} else {
$db->query("INSERT INTO {$tablepre}regips (ip, count, dateline)
VALUES ('$onlineip', '1', '$timestamp')");
}
}
$idstring = random(6);
$authstr = $regverify == 1 ? "$timestamp\t2\t$idstring" : '';
$password = md5(random(10));
$db->query("INSERT INTO {$tablepre}members (uid, username, password, secques, adminid, groupid, regip, regdate, lastvisit, lastactivity, posts, credits, extcredits1, extcredits2, extcredits3, extcredits4, extcredits5, extcredits6, extcredits7, extcredits8, email, showemail, timeoffset, pmsound, invisible, newsletter)
VALUES ('$uid', '$username', '$password', '$secques', '0', '$groupinfo[groupid]', '$onlineip', '$timestamp', '$timestamp', '$timestamp', '0', $initcredits, '$email', '0', '9999', '1', '$invisiblenew', '1')");
$db->query("REPLACE INTO {$tablepre}memberfields (uid, authstr $fieldadd1) VALUES ('$uid', '$authstr' $fieldadd2)");
if($regctrl || $regfloodctrl) {
$db->query("DELETE FROM {$tablepre}regips WHERE dateline<='$timestamp'-".($regctrl > 72 ? $regctrl : 72)."*3600", 'UNBUFFERED');
if($regctrl) {
$db->query("INSERT INTO {$tablepre}regips (ip, count, dateline)
VALUES ('$onlineip', '-1', '$timestamp')");
}
}
$regmessage = dhtmlspecialchars($regmessage);
if($regverify == 2) {
$db->query("REPLACE INTO {$tablepre}validating (uid, submitdate, moddate, admin, submittimes, status, message, remark)
VALUES ('$uid', '$timestamp', '0', '', '1', '0', '$regmessage', '')");
}
if($invitecode && $regstatus > 1) {
$db->query("UPDATE {$tablepre}invites SET reguid='$uid', regdateline='$timestamp', status='2' WHERE invitecode='$invitecode'");
if($inviteaddbuddy) {
include_once DISCUZ_ROOT.'./uc_client/client.php';
uc_friend_add($invite['uid'], $uid, '');
}
if($inviterewardcredit) {
if($inviteaddcredit) {
$db->query("UPDATE {$tablepre}members SET extcredits$inviterewardcredit=extcredits$inviterewardcredit+'$inviteaddcredit' WHERE uid='$uid'");
}
if($invitedaddcredit) {
$db->query("UPDATE {$tablepre}members SET extcredits$inviterewardcredit=extcredits$inviterewardcredit+'$invitedaddcredit' WHERE uid='$invite[uid]'");
}
}
}
$discuz_uid = $uid;
$discuz_user = $username;
$discuz_userss = stripslashes($discuz_user);
$discuz_pw = $password;
$discuz_secques = $secques;
$groupid = $groupinfo['groupid'];
$styleid = $styleid ? $styleid : $_DCACHE['settings']['styleid'];
if($welcomemsg && !empty($welcomemsgtxt)) {
$welcomtitle = !empty($welcomemsgtitle) ? $welcomemsgtitle : "Welcome to $bbname!";
$welcomtitle = addslashes(replacesitevar($welcomtitle));
$welcomemsgtxt = addslashes(replacesitevar($welcomemsgtxt));
if($welcomemsg == 1) {
sendpm($uid, $welcomtitle, $welcomemsgtxt, 0);
} elseif($welcomemsg == 2) {
sendmail("$username <$email>", $welcomtitle, $welcomemsgtxt);
}
}
if($fromuid) {
updatecredits($fromuid, $creditspolicy['promotion_register']);
dsetcookie('promotion', '');
}
if($taskon && $newbietask && $task = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='$newbietask' AND available='2'")) {
require_once DISCUZ_ROOT.'./include/task.func.php';
$task['newbie'] = 1;
task_apply($task);
} else {
$newbietask = 0;
}
require_once DISCUZ_ROOT.'./include/cache.func.php';
$_DCACHE['settings']['totalmembers']++;
updatesettings();
dsetcookie('loginuser', '');
dsetcookie('activationauth', '', -86400 * 365);
if(!empty($inajax)) {
$msgforward = unserialize($msgforward);
$mrefreshtime = intval($msgforward['refreshtime']) * 1000;
$message = 1;
if($regverify != 1) {
include template('register');
}
}
switch($regverify) {
case 1:
sendmail("$username <$email>", 'email_verify_subject', 'email_verify_message');
if(!empty($inajax)) {
include template('register');
} else {
showmessage('profile_email_verify');
}
break;
case 2:
showmessage('register_manual_verify', 'memcp.php');
break;
default:
if($_DCACHE['settings']['frameon'] && $_DCOOKIE['frameon'] == 'yes') {
$extrahead .= '<script>if(top != self) {parent.leftmenu.location.reload();}</script>';
}
if($newbietask) {
showmessage('register_succeed_newbietask', "task.php?action=view&id=$task[taskid]");
} else {
showmessage('register_succeed', dreferer());
}
break;
}
}
function replacesitevar($string, $replaces = array()) {
global $sitename, $bbname, $timestamp, $timeoffset, $adminemail, $adminemail, $discuz_user;
$sitevars = array(
'{sitename}' => $sitename,
'{bbname}' => $bbname,
'{time}' => gmdate('Y-n-j H:i', $timestamp + $timeoffset * 3600),
'{adminemail}' => $adminemail,
'{username}' => $discuz_user,
'{myname}' => $discuz_user
);
$replaces = array_merge($sitevars, $replaces);
return str_replace(array_keys($replaces), array_values($replaces), $string);
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/register.php
|
PHP
|
asf20
| 12,544
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: logs.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
if(!isset($_DCACHE['forums'])) {
include(DISCUZ_ROOT.'./forumdata/cache/cache_forums.php');
}
include language('misc');
$lpp = empty($lpp) ? 20 : intval($lpp);
$lpp = min(200, max(5, $lpp));
$logdir = DISCUZ_ROOT.'./forumdata/logs/';
$logfiles = get_log_files($logdir, 'modcp');
$logs = array();
foreach($logfiles as $logfile) {
$logs = array_merge($logs, file($logdir.$logfile));
}
$page = max(1, intval($page));
$start = ($page - 1) * $lpp;
$logs = array_reverse($logs);
if(!empty($keyword)) {
foreach($logs as $key => $value) {
if(strpos($value, $keyword) === FALSE) {
unset($logs[$key]);
}
}
}
$num = count($logs);
$multipage = multi($num, $lpp, $page, "$cpscript?action=logs&lpp=$lpp&keyword=".rawurlencode($keyword));
$logs = array_slice($logs, $start, $lpp);
$keyword = isset($keyword) ? dhtmlspecialchars($keyword) : '';
$usergroup = array();
$filters = '';
$loglist = array();
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
if(strtolower($log[2]) == strtolower($discuz_userss)) {
$log[2] = '<a href="space.php?username='.rawurlencode($log[2]).'" target="_blank"><b>'.$log[2].'</b></a>';
}
$log[5] = trim($log[5]);
$check = 'modcp_logs_action_'.$log[5];
$log[5] = isset($language[$check]) ? $language[$check] : $log[5];
$log[7] = intval($log[7]);
//$fname = !empty($log[7]) ? strip_tags("{$_DCACHE['forums'][$log[7]]['name']}") : '';
$log[7] = !empty($log[7]) ? '<a href="forumdisplay.php?fid='.$log[7].'" target="_blank">'.strip_tags("{$_DCACHE['forums'][$log[7]]['name']}").'</a>' : '';
$log[8] = str_replace(array('GET={};', 'POST={};'), '', $log[8]);
$log[8] = cutstr($log['8'], 60);
$loglist[] = $log;
}
function get_log_files($logdir='', $action='action') {
$dir = opendir($logdir);
$files = array();
while($entry = readdir($dir)) {
$files[] = $entry;
}
closedir($dir);
sort($files);
$logfile = $action;
$logfiles = array();
foreach($files as $file) {
if(strpos($file, $logfile) !== FALSE) {
$logfiles[] = $file;
}
}
$logfiles = array_slice($logfiles, -2, 2);
return $logfiles;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/logs.inc.php
|
PHP
|
asf20
| 2,511
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: members.inc.php 16746 2008-11-17 07:59:46Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
if($op == 'edit') {
$member = loadmember($uid, $username, $error);
$usernameenc = rawurlencode($member['username']);
if($member && submitcheck('editsubmit') && !$error) {
$sql = 'uid=uid';
if($allowedituser) {
if(!empty($clearavatar)) {
require_once DISCUZ_ROOT.'./uc_client/client.php';
uc_user_deleteavatar($member['uid']);
}
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
if($bionew) {
$bionew = censor($bionew);
$biohtmlnew = addslashes(discuzcode(stripslashes($bionew), 1, 0, 0, 0, $member['allowbiobbcode'], $member['allowbioimgcode'], 0, 0, 1));
} else {
$biohtmlnew = '';
}
if($biotradenew) {
$biotradenew = censor($biotradenew);
$biohtmlnew .= "\t\t\t".addslashes(discuzcode(stripslashes($biotradenew), 1, 0, 0, 0, 1, 1, 0, 0, 1));
}
if($signaturenew) {
$signaturenew = censor($signaturenew);
$sightmlnew = addslashes(discuzcode(stripslashes($signaturenew), 1, 0, 0, 0, $member['allowsigbbcode'], $member['allowsigimgcode'], 0, 0, 1));
} else {
$sightmlnew = '';
}
$locationnew && $locationnew = dhtmlspecialchars($locationnew);
$sql .= ', sigstatus=\''.($signaturenew ? 1 : 0).'\'';
$db->query("UPDATE {$tablepre}memberfields SET location='$locationnew', bio='$biohtmlnew', sightml='$sightmlnew' WHERE uid='$member[uid]'");
}
$db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$member[uid]'");
acpmsg('members_edit_succeed', "$cpscript?action=$action&op=$op");
} elseif($member) {
require_once DISCUZ_ROOT.'./include/editor.func.php';
$bio = explode("\t\t\t", $member['bio']);
$member['bio'] = html2bbcode($bio[0]);
$member['biotrade'] = html2bbcode($bio[1]);
$member['signature'] = html2bbcode($member['sightml']);
$username = !empty($username) ? $member['username'] : '';
}
} elseif($op == 'ban' && $allowbanuser) {
$member = loadmember($uid, $username, $error);
$usernameenc = rawurlencode($member['username']);
if($member && submitcheck('bansubmit') && !$error) {
$sql = 'uid=uid';
$reason = trim($reason);
if(!$reason && ($reasonpm == 1 || $reasonpm == 3)) {
acpmsg('admin_reason_invalid');
}
if($bannew == 4 || $bannew == 5) {
$groupidnew = $bannew;
$banexpirynew = !empty($banexpirynew) ? $timestamp + $banexpirynew * 86400 : 0;
$banexpirynew = $banexpirynew > $timestamp ? $banexpirynew : 0;
if($banexpirynew) {
$member['groupterms'] = $member['groupterms'] && is_array($member['groupterms']) ? $member['groupterms'] : array();
$member['groupterms']['main'] = array('time' => $banexpirynew, 'adminid' => $member['adminid'], 'groupid' => $member['groupid']);
$member['groupterms']['ext'][$groupidnew] = $banexpirynew;
$sql .= ', groupexpiry=\''.groupexpiry($member['groupterms']).'\'';
} else {
$sql .= ', groupexpiry=0';
}
$adminidnew = -1;
} elseif($member['groupid'] == 4 || $member['groupid'] == 5) {
if(!empty($member['groupterms']['main']['groupid'])) {
$groupidnew = $member['groupterms']['main']['groupid'];
$adminidnew = $member['groupterms']['main']['adminid'];
unset($member['groupterms']['main']);
unset($member['groupterms']['ext'][$member['groupid']]);
$sql .= ', groupexpiry=\''.groupexpiry($member['groupterms']).'\'';
} else {
$query = $db->query("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditshigher<='$member[credits]' AND creditslower>'$member[credits]'");
$groupidnew = $db->result($query, 0);
$adminidnew = 0;
}
} else {
$groupidnew = $member['groupid'];
$adminidnew = $member['adminid'];
}
$sql .= ", adminid='$adminidnew', groupid='$groupidnew'";
$db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$member[uid]'");
if($db->affected_rows($query)) {
savebanlog($member['username'], $member['groupid'], $groupidnew, $banexpirynew, $reason);
}
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".($member['groupterms'] ? addslashes(serialize($member['groupterms'])) : '')."' WHERE uid='$member[uid]'");
acpmsg('modcp_member_ban_successed', "$cpscript?action=$action&op=$op");
}
} elseif($op == "ipban" && $allowbanip) {
require_once DISCUZ_ROOT.'./include/misc.func.php';
$iptoban = isset($ip) ? dhtmlspecialchars(explode('.', $ip)) : array('','','','');
$updatecheck = $addcheck = $deletecheck = $adderror = 0;
if(submitcheck('ipbansubmit')) {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}banned WHERE id IN ($ids) AND ('$adminid'='1' OR admin='$discuz_user')");
$deletecheck = $db->affected_rows();
}
if($ip1new != '' && $ip2new != '' && $ip3new != '' && $ip4new != '') {
$addcheck = ipbanadd($ip1new, $ip2new, $ip3new, $ip4new, $validitynew, $adderror);
if(!$addcheck) {
$iptoban = array($ip1new, $ip2new, $ip3new, $ip4new);
}
}
if(!empty($expirationnew) && is_array($expirationnew)) {
foreach($expirationnew as $id => $expiration) {
$db->query("UPDATE {$tablepre}banned SET expiration='".strtotime($expiration)."' WHERE id='$id' AND ('$adminid'='1' OR admin='$discuz_user')");
empty($updatecheck) && $updatecheck = $db->affected_rows();
}
}
if($deletecheck || $addcheck || $updatecheck) {
require_once(DISCUZ_ROOT.'./include/cache.func.php');
updatecache('ipbanned');
}
}
$iplist = array();
$query = $db->query("SELECT * FROM {$tablepre}banned ORDER BY dateline");
while($banned = $db->fetch_array($query)) {
for($i = 1; $i <= 4; $i++) {
if($banned["ip$i"] == -1) {
$banned["ip$i"] = '*';
}
}
$banned['disabled'] = $adminid != 1 && $banned['admin'] != $discuz_userss ? 'disabled' : '';
$banned['dateline'] = gmdate($dateformat, $banned['dateline'] + $timeoffset * 3600);
$banned['expiration'] = gmdate($dateformat, $banned['expiration'] + $timeoffset * 3600);
$banned['theip'] = "$banned[ip1].$banned[ip2].$banned[ip3].$banned[ip4]";
$banned['location'] = convertip($banned['theip']);
$iplist[$banned['id']] = $banned;
}
} else {
showmessage('undefined_action');
}
function loadmember(&$uid, &$username, &$error) {
global $db, $tablepre, $timeoffset;
$uid = !empty($uid) && is_numeric($uid) && $uid > 0 ? $uid : '';
$username = isset($username) && $username != '' ? dhtmlspecialchars(trim($username)) : '';
$member = array();
if($uid || $username != '') {
$query = $db->query("SELECT m.uid, m.username, m.groupid, m.adminid, mf.groupterms, mf.location, mf.bio, mf.sightml, u.type AS grouptype, u.allowsigbbcode, u.allowsigimgcode, u.allowcusbbcode, u.allowbiobbcode, u.allowbioimgcode, u.allowcusbbcode FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE ".($uid ? "m.uid='$uid'" : "m.username='$username'"));
if(!$member = $db->fetch_array($query)) {
$error = 2;
} elseif(($member['grouptype'] == 'system' && in_array($member['groupid'], array(1, 2, 3, 6, 7, 8))) || $member['grouptype'] == 'special') {
$error = 3;
} else {
$member['groupterms'] = unserialize($member['groupterms']);
$member['banexpiry'] = !empty($member['groupterms']['main']['time']) && ($member['groupid'] == 4 || $member['groupid'] == 5) ? gmdate('Y-n-j', $member['groupterms']['main']['time'] + $timeoffset * 3600) : '';
$error = 0;
}
} else {
$error = 1;
}
return $member;
}
function ipbanadd($ip1new, $ip2new, $ip3new, $ip4new, $validitynew, &$error) {
global $db, $tablepre, $timestamp, $adminid, $onlineip, $discuz_user;
if($ip1new != '' && $ip2new != '' && $ip3new != '' && $ip4new != '') {
$own = 0;
$ip = explode('.', $onlineip);
for($i = 1; $i <= 4; $i++) {
if(!is_numeric(${'ip'.$i.'new'}) || ${'ip'.$i.'new'} < 0) {
if($adminid != 1) {
$error = 1;
return FALSE;
}
${'ip'.$i.'new'} = -1;
$own++;
} elseif(${'ip'.$i.'new'} == $ip[$i - 1]) {
$own++;
}
${'ip'.$i.'new'} = intval(${'ip'.$i.'new'}) > 255 ? 255 : intval(${'ip'.$i.'new'});
}
if($own == 4) {
$error = 2;
return FALSE;
}
$query = $db->query("SELECT * FROM {$tablepre}banned WHERE (ip1='$ip1new' OR ip1='-1') AND (ip2='$ip2new' OR ip2='-1') AND (ip3='$ip3new' OR ip3='-1') AND (ip4='$ip4new' OR ip4='-1')");
if($banned = $db->fetch_array($query)) {
$error = 3;
return FALSE;
}
$expiration = $validitynew > 1 ? ($timestamp + $validitynew * 86400) : $timestamp + 86400;
$db->query("UPDATE {$tablepre}sessions SET groupid='6' WHERE ('$ip1new'='-1' OR ip1='$ip1new') AND ('$ip2new'='-1' OR ip2='$ip2new') AND ('$ip3new'='-1' OR ip3='$ip3new') AND ('$ip4new'='-1' OR ip4='$ip4new')");
$db->query("INSERT INTO {$tablepre}banned (ip1, ip2, ip3, ip4, admin, dateline, expiration)
VALUES ('$ip1new', '$ip2new', '$ip3new', '$ip4new', '$discuz_user', '$timestamp', '$expiration')");
return TRUE;
}
return FALSE;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/members.inc.php
|
PHP
|
asf20
| 9,378
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: recyclebins.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
$op = !in_array($op , array('list', 'delete', 'search', 'restore')) ? 'list' : $op;
$do = !empty($do) ? dhtmlspecialchars($do) : '';
$tidarray = array();
if($fid && $forum['ismoderator'] && $modforums['recyclebins'][$fid]) {
$srchupdate = false;
if($adminid == 1 && ($op == 'delete' || $op == 'restore') && submitcheck('dosubmit')) {
if($ids = implodeids($moderate)) {
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE tid IN($ids) AND fid='$fid' AND displayorder='-1'");
while ($tid = $db->fetch_array($query)) {
$tidarray[] = $tid['tid'];
}
if($tidarray) {
require_once DISCUZ_ROOT.'./include/post.func.php';
($op == 'delete') && deletethreads($tidarray);
($op == 'restore') && undeletethreads($tidarray);
if($oldop == 'search') {
$srchupdate = true;
}
}
}
$op = dhtmlspecialchars($oldop);
}
$result = array();
foreach (array('threadoption', 'viewsless', 'viewsmore', 'repliesless', 'repliesmore', 'noreplydays') as $key) {
$$key = isset($$key) && is_numeric($$key) ? intval($$key) : '';
$result[$key] = $$key;
}
foreach (array('starttime', 'endtime', 'keywords', 'users') as $key) {
$result[$key] = isset($$key) ? dhtmlspecialchars($$key) : '';
}
$threadoptionselect = array($threadoption => 'selected');
if($op == 'search' && submitcheck('searchsubmit')) {
$sql = '';
if($threadoption > 0 && $threadoption < 255) {
$sql .= " AND special='$threadoption'";
} elseif($threadoption == 999) {
$sql .= " AND digest in(1,2,3)";
} elseif($threadoption == 888) {
$sql .= " AND displayorder IN(1,2,3)";
}
$sql .= $viewsless !== ''? " AND views<='$viewsless'" : '';
$sql .= $viewsmore !== ''? " AND views>='$viewsmore'" : '';
$sql .= $repliesless !== ''? " AND replies<='$repliesless'" : '';
$sql .= $repliesmore !== ''? " AND replies>='$repliesmore'" : '';
$sql .= $noreplydays !== ''? " AND lastpost<='$timestamp'-'$noreplydays'*86400" : '';
$sql .= $starttime != '' ? " AND dateline>='".strtotime($starttime)."'" : '';
$sql .= $endtime != '' ? " AND dateline<='".strtotime($endtime)."'" : '';
if(trim($keywords)) {
$sqlkeywords = '';
$or = '';
$keywords = explode(',', str_replace(' ', '', $keywords));
for($i = 0; $i < count($keywords); $i++) {
$sqlkeywords .= " $or subject LIKE '%".$keywords[$i]."%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
$keywords = implode(', ', $keywords);
}
if(trim($users)) {
$sql .= " AND author IN ('".str_replace(',', '\',\'', str_replace(' ', '', trim($users)))."')";
}
if($sql) {
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND displayorder='-1' $sql ORDER BY displayorder DESC, lastpost DESC LIMIT 1000");
$tids = $comma = '';
$count = 0;
while ($tid = $db->fetch_array($query)) {
$tids .= $comma.$tid['tid'];
$comma = ',';
$count ++;
}
$result['tids'] = $tids;
$result['count'] = $count;
$result['fid'] = $fid;
$modsession->set('srchresult_r', $result, true);
$db->free_result($query);
unset($result, $tids);
$page = 1;
} else {
$op = 'list';
}
}
$page = max(1, intval($page));
$total = 0;
$query = $multipage = '';
if($op == 'list') {
$total = $db->result_first("SELECT count(*) FROM {$tablepre}threads WHERE fid='$fid' AND displayorder='-1'");
$tpage = ceil($total / $tpp);
$page = min($tpage, $page);
$multipage = multi($total, $tpp, $page, "$cpscript?action=$action&op=$op&fid=$fid&do=$do");
if($total) {
$start = ($page - 1) * $tpp;
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE fid='$fid' AND displayorder='-1' ORDER BY displayorder DESC, lastpost DESC LIMIT $start, $tpp");
}
}
if($op == 'search') {
$result = $modsession->get('srchresult_r');
if($result['fid'] == $fid) {
if($srchupdate && $result['count'] && $tidarray) {
$td = explode(',', $result['tids']);
$newtids = $comma = $newcount = '';
if(is_array($td)) {
foreach ($td as $v) {
$v = intval($v);
if(!in_array($v, $tidarray)) {
$newcount ++;
$newtids .= $comma.$v; $comma = ',';
}
}
$result['count'] = $newcount;
$result['tids'] = $newtids;
$modsession->set('srchresult_r'.$fid, $result, true);
}
}
$threadoptionselect = array($result['threadoption'] => 'selected');
$total = $result['count'];
$tpage = ceil($total / $tpp);
$page = min($tpage, $page);
$multipage = multi($total, $tpp, $page, "$cpscript?action=$action&op=$op&fid=$fid&do=$do");
if($total) {
$start = ($page - 1) * $tpp;
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid in($result[tids]) AND fid='$fid' AND displayorder='-1' ORDER BY lastpost DESC LIMIT $start, $tpp");
}
} else {
$result = array();
$modsession->set('srchresult_r', array());
}
}
$postlist = array();
if($query) {
require_once DISCUZ_ROOT.'./include/misc.func.php';
while ($thread = $db->fetch_array($query)) {
$post = procthread($thread);
$post['modthreadkey'] = modthreadkey($post['tid']);
$postlist[] = $post;
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/recyclebins.inc.php
|
PHP
|
asf20
| 5,588
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: announcements.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
$annlist = null;
$add_successed = false;
$op = empty($op) ? 'add' : $op;
$announce = array();
$announce['checked'] = array('selected="selected"', '');
switch ($op) {
case 'add':
if(!submitcheck('submit')) {
$announce['starttime'] = gmdate("$dateformat", $timestamp + 3600 * $timeoffset);
$announce['endtime'] = gmdate("$dateformat", $timestamp + 3600 * $timeoffset + 86400 * 30);
} else {
$message = is_array($message) ? $message[$type] : '';
save_announce(0, $starttime, $endtime, $subject, $type, $message, 0);
$add_successed = true;
}
break;
case 'manage':
$annlist = get_annlist();
if(submitcheck('submit')) {
$delids = array();
if(!empty($delete) && is_array($delete)) {
foreach ($delete as $id) {
$id = intval($id);
if(isset($annlist[$id])) {
unset($annlist[$id]);
$delids[] = $id;
}
}
if($delids) {
$db->query("DELETE FROM {$tablepre}announcements WHERE id IN(".implodeids($delids).") AND author='$discuz_user'", 'UNBUFFERED');
}
}
$updateorder = false;
if(!empty($order) && is_array($order)) {
foreach ($order as $id => $val) {
$val = intval($val);
if(isset($annlist[$id]) && $annlist[$id]['displayorder'] != $val) {
$annlist[$id]['displayorder'] = $val;
$db->query("UPDATE {$tablepre}announcements SET displayorder='$val' WHERE id='$id'", "UNBUFFERED");
$updateorder = true;
}
}
}
if($delids || $updateorder) {
update_announcecache();
}
}
break;
case 'edit':
$id = intval($id);
$query = $db->query("SELECT * FROM {$tablepre}announcements WHERE id='$id' AND author='$discuz_user'");
if(!$announce = $db->fetch_array($query)) {
showmessage('modcp_ann_nofound');
}
if(!submitcheck('submit')) {
$announce['starttime'] = $announce['starttime'] ? gmdate($dateformat, $announce['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '';
$announce['endtime'] = $announce['endtime'] ? gmdate($dateformat, $announce['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '';
$announce['message'] = $announce['type'] != 1 ? dhtmlspecialchars($announce['message']) : $announce['message'];
$announce['checked'] = $announce['type'] != 1 ? array('selected="selected"', '') : array('', 'selected="selected"');
} else {
$announce['starttime'] = $starttime;
$announce['endtime'] = $endtime;
$announce['checked'] = $type != 1 ? array('selected="selected"', '') : array('', 'selected="selected"');
$message = $message[$type];
save_announce($id, $starttime, $endtime, $subject, $type, $message, $displayorder);
$edit_successed = true;
}
break;
}
$annlist = get_annlist();
function get_annlist() {
global $db, $tablepre, $adminid, $discuz_userss, $dateformat, $_DCACHE;
$annlist = array();
$query = $db->query("SELECT * FROM {$tablepre}announcements ORDER BY displayorder, starttime DESC, id DESC");
while($announce = $db->fetch_array($query)) {
$announce['disabled'] = $announce['author'] != $discuz_userss ? 'disabled' : '';
$announce['starttime'] = $announce['starttime'] ? gmdate($dateformat, $announce['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '-';
$announce['endtime'] = $announce['endtime'] ? gmdate($dateformat, $announce['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '-';
$annlist[$announce['id']] = $announce;
}
return $annlist;
}
function update_announcecache() {
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache(array('announcements', 'announcements_forum'));
}
function save_announce($id = 0, $starttime, $endtime, $subject, $type, $message, $displayorder = 0) {
global $db, $tablepre, $discuz_user, $timestamp;
$displayorder = intval($displayorder);
$type = intval($type);
$starttime = empty($starttime) || strtotime($starttime) < $timestamp ? $timestamp : strtotime($starttime);
$endtime = empty($endtime) ? 0 : (strtotime($endtime) < $starttime ? ($starttime + 86400 * 30) : strtotime($endtime));
$subject = htmlspecialchars(trim($subject));
if($type == 1) {
list($message) = explode("\n", trim($message));
$message = dhtmlspecialchars($message);
} else {
$type = 0;
$message = trim($message);
}
if(empty($subject) || empty($message)) {
acpmsg('modcp_ann_empty');
} elseif($type == 1 && substr(strtolower($message), 0, 7) != 'http://') {
acpmsg('modcp_ann_urlerror');
} else {
$sql = "author='$discuz_user', subject='$subject', type='$type', starttime='$starttime', endtime='$endtime',
message='$message', displayorder='$displayorder'";
if(empty($id)) {
$db->query("INSERT INTO {$tablepre}announcements SET $sql");
} else {
$db->query("UPDATE {$tablepre}announcements SET $sql WHERE id='$id'", 'UNBUFFERED');
}
update_announcecache();
return true;
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/announcements.inc.php
|
PHP
|
asf20
| 5,209
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: noperm.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/noperm.inc.php
|
PHP
|
asf20
| 262
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: threads.inc.php 16886 2008-11-26 05:08:30Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
$op = !in_array($op , array('threads', 'posts')) ? 'threads' : $op;
$do = !empty($do) ? dhtmlspecialchars($do) : '';
$modtpl = $op == 'posts' ? 'modcp_posts' : 'modcp_threads';
if($op == 'threads') {
if($fid && $forum['ismoderator']) {
$result = array();
foreach (array('threadoption', 'viewsless', 'viewsmore', 'repliesless', 'repliesmore', 'noreplydays') as $key) {
$$key = isset($$key) && is_numeric($$key) ? intval($$key) : '';
$result[$key] = $$key;
}
foreach (array('starttime', 'endtime', 'keywords', 'users') as $key) {
$result[$key] = isset($$key) ? dhtmlspecialchars($$key) : '';
}
$threadoptionselect = array($threadoption => 'selected');
if($do == 'search' && submitcheck('submit')) {
$sql = '';
if($threadoption > 0 && $threadoption < 255) {
$sql .= " AND special='$threadoption'";
} elseif($threadoption == 999) {
$sql .= " AND digest in(1,2,3)";
} elseif($threadoption == 888) {
$sql .= " AND displayorder IN(1,2,3)";
}
$sql .= $viewsless !== ''? " AND views<='$viewsless'" : '';
$sql .= $viewsmore !== ''? " AND views>='$viewsmore'" : '';
$sql .= $repliesless !== ''? " AND replies<='$repliesless'" : '';
$sql .= $repliesmore !== ''? " AND replies>='$repliesmore'" : '';
$sql .= $noreplydays !== ''? " AND lastpost<='$timestamp'-'$noreplydays'*86400" : '';
$sql .= $starttime != '' ? " AND dateline>='".strtotime($starttime)."'" : '';
$sql .= $endtime != '' ? " AND dateline<='".strtotime($endtime)."'" : '';
if(trim($keywords)) {
$sqlkeywords = '';
$or = '';
$keywords = explode(',', str_replace(' ', '', $keywords));
for($i = 0; $i < count($keywords); $i++) {
$sqlkeywords .= " $or subject LIKE '%".$keywords[$i]."%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
$keywords = implode(', ', $keywords);
}
if(trim($users)) {
$sql .= " AND author IN ('".str_replace(',', '\',\'', str_replace(' ', '', trim($users)))."')";
}
if($sql) {
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>=0 $sql ORDER BY displayorder DESC, lastpost DESC LIMIT 1000");
$tids = $comma = '';
$count = 0;
while ($tid = $db->fetch_array($query)) {
$tids .= $comma.$tid['tid'];
$comma = ',';
$count ++;
}
$result['tids'] = $tids;
$result['count'] = $count;
$result['fid'] = $fid;
$modsession->set('srchresult', $result, true);
$db->free_result($query);
unset($result, $tids);
$do = 'list';
$page = 1;
} else {
$do = '';
}
}
$page = max(1, intval($page));
$total = 0;
$query = $multipage = '';
if(empty($do)) {
$total = $db->result_first("SELECT count(*) FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>=0");
$tpage = ceil($total / $tpp);
$page = min($tpage, $page);
$multipage = multi($total, $tpp, $page, "$cpscript?action=$action&op=$op&fid=$fid&do=$do");
if($total) {
$start = ($page - 1) * $tpp;
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>=0 ORDER BY displayorder DESC, lastpost DESC LIMIT $start, $tpp");
}
} else {
$result = $modsession->get('srchresult');
$threadoptionselect = array($result['threadoption'] => 'selected');
if($result['fid'] == $fid) {
$total = $result['count'];
$tpage = ceil($total / $tpp);
$page = min($tpage, $page);
$multipage = multi($total, $tpp, $page, "$cpscript?action=$action&op=$op&fid=$fid&do=$do");
if($total) {
$start = ($page - 1) * $tpp;
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid in($result[tids]) ORDER BY lastpost DESC LIMIT $start, $tpp");
}
}
}
$postlist = array();
if($query) {
require_once DISCUZ_ROOT.'./include/misc.func.php';
while ($thread = $db->fetch_array($query)) {
$postlist[] = procthread($thread);
}
}
}
return;
}
if($op == 'posts') {
$error = 0;
$result = array();
$result['threadoption'] = intval($threadoption);
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? gmdate('Y-n-j', $timestamp + $timeoffset * 3600 - 86400 * 7) : $starttime;
$endtime = $adminid == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? gmdate('Y-n-j', $timestamp + $timeoffset * 3600) : $endtime;
foreach (array('starttime', 'endtime', 'keywords', 'users', 'useip') as $key) {
$$key = isset($$key) ? trim($$key) : '';
$result[$key] = dhtmlspecialchars($$key);
}
$threadoptionselect = array($threadoption => 'selected');
$fidadd = '';
if($fid && $modforums['list'][$fid]) {
$fidadd = "AND fid='$fid'";
} else {
if($adminid == 1 && $adminid == $groupid) {
$fidadd = '';
} elseif(!$modforums['fids']) {
$fidadd = 'AND 0 ';
} else {
$fidadd = "AND fid in($modforums[fids])";
}
}
if($do == 'delete' && submitcheck('deletesubmit')) {
if(!$allowmassprune) {
$error = 4;
return;
}
$tidsdelete = $pidsdelete = '0';
$prune = array();
if($pids = implodeids($delete)) {
$tidsdelete = $pidsdelete = '0';
$query = $db->query("SELECT fid, tid, pid, first, authorid FROM {$tablepre}posts WHERE pid IN ($pids) $fidadd");
while($post = $db->fetch_array($query)) {
$prune['forums'][] = $post['fid'];
$prune['thread'][$post['tid']]++;
$pidsdelete .= ",$post[pid]";
$tidsdelete .= $post['first'] ? ",$post[tid]" : '';
}
}
if($pidsdelete) {
require_once DISCUZ_ROOT.'./include/post.func.php';
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE pid IN ($pidsdelete) OR tid IN ($tidsdelete)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if(!$nocredit) {
$postsarray = $tuidarray = $ruidarray = array();
$query1 = $db->query("SELECT pid, first, authorid FROM {$tablepre}posts WHERE pid IN ($pidsdelete)");
$query2 = $db->query("SELECT pid, first, authorid FROM {$tablepre}posts WHERE tid IN ($tidsdelete)");
while(($post = $db->fetch_array($query1)) || ($post = $db->fetch_array($query2))) {
$postsarray[$post['pid']] = $post;
}
foreach($postsarray as $post) {
if($post['first']) {
$tuidarray[] = $post['authorid'];
} else {
$ruidarray[] = $post['authorid'];
}
}
if($tuidarray) {
updatepostcredits('-', $tuidarray, $creditspolicy['post']);
}
if($ruidarray) {
updatepostcredits('-', $ruidarray, $creditspolicy['reply']);
}
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($tidsdelete)");
$deletedthreads = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pidsdelete)");
$deletedposts = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($tidsdelete)");
$deletedposts += $db->affected_rows();
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activities WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activityapplies WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
if(count($prunt['thread']) < 50) {
foreach($prune['thread'] as $tid => $decrease) {
updatethreadcount($tid);
}
} else {
$repliesarray = array();
foreach($prune['thread'] as $tid => $decrease) {
$repliesarray[$decrease][] = $tid;
}
foreach($repliesarray as $decrease => $tidarray) {
$db->query("UPDATE {$tablepre}threads SET replies=replies-$decrease WHERE tid IN (".implode(',', $tidarray).")");
}
}
foreach(array_unique($prune['forums']) as $id) {
updateforumcount($id);
}
}
$do = 'list';
}
if($do == 'search' && submitcheck('searchsubmit')) {
if(($starttime == '0' && $endtime == '0') || ($keywords == '' && $useip == '' && $users == '')) {
$error = 1;
return ;
}
$sql = '';
if($threadoption == 1) {
$sql .= " AND first='1'";
} elseif($threadoption == 2) {
$sql .= " AND first='0'";
}
if($starttime != '0') {
$starttime = strtotime($starttime);
$sql .= " AND dateline>'$starttime'";
}
if($adminid == 1 && $endtime != gmdate('Y-n-j', $timestamp + $timeoffset * 3600)) {
if($endtime != '0') {
$endtime = strtotime($endtime);
$sql .= " AND dateline<'$endtime'";
}
} else {
$endtime = $timestamp;
}
if(($adminid == 2 && $endtime - $starttime > 86400 * 16) || ($adminid == 3 && $endtime - $starttime > 86400 * 8)) {
$error = '2';
return;
}
if($users != '') {
$uids = $comma = '';
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE username IN ('".str_replace(',', '\',\'', str_replace(' ', '', $users))."')");
while($member = $db->fetch_array($query)) {
$uids .= $comma.$member[uid]; $comma = ',';
}
if($uids) {
$sql .= " AND authorid IN ($uids)";
}
}
if(trim($keywords)) {
$sqlkeywords = '';
$or = '';
$keywords = explode(',', str_replace(' ', '', $keywords));
for($i = 0; $i < count($keywords); $i++) {
if(strlen($keywords[$i]) > 3) {
$sqlkeywords .= " $or message LIKE '%".$keywords[$i]."%'";
$or = 'OR';
} else {
$error = 3;
return ;
}
}
$sql .= " AND ($sqlkeywords)";
}
$useip = trim($useip);
if($useip != '') {
$sql .= " AND useip LIKE '".str_replace('*', '%', $useip)."'";
}
if($sql) {
$query = $db->query("SELECT pid FROM {$tablepre}posts WHERE 1 $fidadd $sql ORDER BY dateline DESC LIMIT 1000");
$pids = $comma = '';
$count = 0;
while ($pid = $db->fetch_array($query)) {
$pids .= $comma.$pid['pid'];
$comma = ',';
$count ++;
}
$result['pids'] = $pids;
$result['count'] = $count;
$result['fid'] = $fid;
$modsession->set('srchresult_p'.$fid, $result, true);
$db->free_result($query);
unset($result, $pids);
$do = 'list';
$page = 1;
} else {
$do = '';
}
}
$page = max(1, intval($page));
$total = 0;
$query = $multipage = '';
if($do == 'list') {
$result = $modsession->get('srchresult_p'.$fid);
$threadoptionselect = array($result['threadoption'] => 'selected');
if($result['fid'] == $fid) {
$total = $result['count'];
$tpage = ceil($total / $tpp);
$page = min($tpage, $page);
$multipage = multi($total, $tpp, $page, "$cpscript?action=$action&op=$op&fid=$fid&do=$do");
if($total && $result[pids]) {
$start = ($page - 1) * $tpp;
$query = $db->query("SELECT p.*, t.subject as tsubject FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE pid in($result[pids]) ORDER BY dateline DESC LIMIT $start, $tpp");
}
}
}
$postlist = array();
if($query) {
while ($post = $db->fetch_array($query)) {
$post['dateline'] = gmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['message'] = dhtmlspecialchars(cutstr($post['message'], 200), 200);
$post['forum'] = $modforums['list'][$post[fid]];
$post['modthreadkey'] = modthreadkey($post['tid']);
$postlist[] = $post;
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/threads.inc.php
|
PHP
|
asf20
| 12,590
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: report.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
$reportlist = $logids = array();
if(!empty($fid) && ($forum['type'] == 'group' || !$forum['ismoderator'])) {
return false;
}
$fidadd = $fid ? "fid='$fid'" : "fid IN ($modforums[fids])";
if(submitcheck('deletesubmit') && $logids = implodeids($ids)) {
if($op == 'delete') {
$db->query("DELETE FROM {$tablepre}reportlog WHERE id IN ($logids) AND $fidadd", 'UNBUFFERED');
if($forum['modworks'] && !$db->result_first("SELECT COUNT(*) FROM {$tablepre}reportlog WHERE $fidadd AND status=1")) {
$db->query("UPDATE {$tablepre}forums SET modworks='0' WHERE $fidadd", 'UNBUFFERED');
}
}
}
$page = max(1, intval($page));
$ppp = 10;
$reportlist = array('pagelink' => '', 'data' => array());
$reportnums = array();
$query = $db->query("SELECT fid, count(*) AS num FROM {$tablepre}reportlog GROUP BY fid");
while ($row = $db->fetch_array($query)) {
$reportnums[$row['fid']] = $row['num'];
}
if($num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}reportlog WHERE $fidadd")) {
$page = $page > ceil($num / $ppp) ? ceil($num / $ppp) : $page;
$start_limit = ($page - 1) * $ppp;
$reportlist['pagelink'] = multi($num, $ppp, $page, "modcp.php?fid=$fid&action=report");
$query = $db->query("SELECT r.*, p.tid, p.message, p.author, p.authorid, t.subject, t.displayorder FROM {$tablepre}reportlog r
LEFT JOIN {$tablepre}posts p ON p.pid=r.pid
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
WHERE r.$fidadd ORDER BY r.dateline DESC LIMIT $start_limit, $ppp");
$deleteids = $comma = '';
while($report = $db->fetch_array($query)) {
if($report['tid'] && $report['displayorder'] >= 0) {
$report['dateline'] = gmdate("$dateformat $timeformat", $report['dateline'] + $timeoffset * 3600);
$report['subject'] = cutstr($report['subject'], 30);
$report['message'] = htmlspecialchars($report['message']);
$report['author'] = $report['author'] != '' ? "<a href=\"space.php?uid=$report[authorid]\" target=\"_blank\">$report[author]</a>" : 'Guest';
$report['username'] = "<a href=\"space.php?uid=$report[uid]\" target=\"_blank\">$report[username]</a>";
$reportlist['data'][] = $report;
} else {
$deleteids .= $comma.$report['id'];
$comma = ',';
}
}
if($deleteids) {
$db->query("DELETE FROM {$tablepre}reportlog WHERE id in ($deleteids)");
if($forum['modworks'] && !$db->result_first("SELECT COUNT(*) FROM {$tablepre}reportlog WHERE fid='$fid' AND status=1")) {
$db->query("UPDATE {$tablepre}forums SET modworks='0' WHERE fid='$fid'", 'UNBUFFERED');
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/report.inc.php
|
PHP
|
asf20
| 2,821
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: index.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
header('Location: ../modcp.php');
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/index.php
|
PHP
|
asf20
| 201
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: home.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
if($op == 'addnote' && submitcheck('submit')) {
$newaccess = 4 + (2 & $newaccess[2]) + (1 & $newaccess[3]);
$newexpiration = $timestamp + (intval($newexpiration) > 0 ? intval($newexpiration) : 30) * 86400;
$newmessage = nl2br(dhtmlspecialchars(trim($newmessage)));
if($newmessage != '') {
$db->query("INSERT INTO {$tablepre}adminnotes (admin, access, adminid, dateline, expiration, message)
VALUES ('$discuz_user', '$newaccess', '$adminid', '$timestamp', '$newexpiration', '$newmessage')");
}
}
if($op == 'delete' && submitcheck('submit')) {
if(is_array($delete) && $deleteids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}adminnotes WHERE id IN($deleteids) AND ($adminid=1 OR admin='$discuz_user')");
}
}
switch($adminid) {
case 1: $access = '1,2,3,4,5,6,7'; break;
case 2: $access = '2,3,6,7'; break;
default: $access = '1,3,5,7'; break;
}
$notelist = array();
$query = $db->query("SELECT * FROM {$tablepre}adminnotes WHERE access IN ($access) OR admin='$discuz_user' ORDER BY dateline DESC");
while($note = $db->fetch_array($query)) {
if($note['expiration'] < $timestamp) {
$db->query("DELETE FROM {$tablepre}adminnotes WHERE id='$note[id]'");
} else {
$note['expiration'] = ceil(($note['expiration'] - $note['dateline']) / 86400);
$note['dateline'] = gmdate("$dateformat $timeformat", $note['dateline'] + $timeoffset * 3600);
$note['checkbox'] = '<input class="checkbox" type="checkbox" name="delete[]" '.($note['admin'] == $discuz_userss || $adminid == 1 ? "value=\"$note[id]\"" : 'disabled').'>';
$note['admin'] = '<a href="space.php?username='.rawurlencode($note['admin']).'" target="_blank">'.$note['admin'].'</a>';
$notelist[] = $note;
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/home.inc.php
|
PHP
|
asf20
| 1,995
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: moderate.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
if($op == 'members') {
if(!$allowmoduser) {
showmessage('modcp_moduser_invite_nopermission');
}
$filter = isset($filter) ? intval($filter) : 0;
$filtercheck = array( $filter => 'selected');
if(submitcheck('dosubmit', 1) || submitcheck('modsubmit')) {
if(empty($mod) || !in_array($mod, array('invalidate', 'validate', 'delete'))) {
showmessage('modcp_noaction');
}
$list = array();
if($moderate && is_array($moderate)) {
foreach($moderate as $val) {
if(is_numeric($val) && $val) {
$list[] = $val;
}
}
}
if(submitcheck('dosubmit', 1)) {
include template('modcp_moderate_float');
dexit();
} elseif ($uids = implodeids($list)) {
$members = $uidarray = array();
$query = $db->query("SELECT v.*, m.uid, m.username, m.email, m.regdate FROM {$tablepre}validating v, {$tablepre}members m
WHERE v.uid IN ($uids) AND m.uid=v.uid AND m.groupid='8' AND status='$filter'");
while($member = $db->fetch_array($query)) {
$members[$member['uid']] = $member;
$uidarray[] = $member['uid'];
}
if($uids = implodeids($uidarray)) {
$reason = dhtmlspecialchars(trim($reason));
if($mod == 'delete') {
$db->query("DELETE FROM {$tablepre}members WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)");
}
if($mod == 'validate') {
$newgroupid = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE creditshigher<=0 AND 0<creditslower LIMIT 1");
$db->query("UPDATE {$tablepre}members SET adminid='0', groupid='$newgroupid' WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)");
}
if($mod == 'invalidate') {
$db->query("UPDATE {$tablepre}validating SET moddate='$timestamp', admin='$discuz_user', status='1', remark='$reason' WHERE uid IN ($uids)");
}
if($sendemail) {
foreach($members as $uid => $member) {
$member['regdate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $member['regdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
$member['submitdate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $member['submitdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
$member['moddate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$member['operation'] = 'moderate_member_'.$mod;
$member['remark'] = $reason ? $reason : 'N/A';
sendmail("$member[username] <$member[email]>", 'moderate_member_subject', 'moderate_member_message');
}
}
}
showmessage('modcp_mod_succeed', "{$cpscript}?action=$action&op=$op&filter=$filter");
} else {
showmessage('modcp_moduser_invalid');
}
} else {
$count = array(0, 0, 0);
$query = $db->query("SELECT status, COUNT(*) AS count FROM {$tablepre}validating GROUP BY status");
while($num = $db->fetch_array($query)) {
$count[$num['status']] = $num['count'];
}
$page = max(1, intval($page));
$memberperpage = 20;
$start_limit = ($page - 1) * $memberperpage;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}validating WHERE status='0'");
$multipage = multi($db->result($query, 0), $memberperpage, $page, "{$cpscript}?action=$action&op=$op&fid=$fid&filter=$filter");
$vuids = '0';
$memberlist = array();
$query = $db->query("SELECT m.uid, m.username, m.groupid, m.email, m.regdate, m.regip, v.message, v.submittimes, v.submitdate, v.moddate, v.admin, v.remark
FROM {$tablepre}validating v, {$tablepre}members m
WHERE v.status='$filter' AND m.uid=v.uid ORDER BY v.submitdate DESC LIMIT $start_limit, $memberperpage");
while($member = $db->fetch_array($query)) {
if($member['groupid'] != 8) {
$vuids .= ','.$member['uid'];
continue;
}
$member['regdate'] = gmdate("$dateformat $timeformat", $member['regdate'] + $timeoffset * 3600);
$member['submitdate'] = gmdate("$dateformat $timeformat", $member['submitdate'] + $timeoffset * 3600);
$member['moddate'] = $member['moddate'] ? gmdate("$dateformat $timeformat", $member['moddate'] + $timeoffset * 3600) : $lang['none'];
$member['message'] = dhtmlspecialchars($member['message']);
$member['admin'] = $member['admin'] ? "<a href=\"space.php?username=".rawurlencode($member['admin'])."\" target=\"_blank\">$member[admin]</a>" : $lang['none'];
$memberlist[] = $member;
}
if($vuids) {
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($vuids)", 'UNBUFFERED');
}
return true;
}
}
if(empty($modforums['fids'])) {
return false;
} elseif ($fid && ($forum['type'] == 'group' || !$forum['ismoderator'])) {
return false;
} else {
if($fid) {
$modfidsadd = "fid='$fid'";
} elseif($adminid == 1) {
$modfidsadd = "";
} else {
$modfidsadd = "fid in ($modforums[fids])";
}
}
$updatestat = false;
$op = !in_array($op , array('replies', 'threads')) ? 'threads' : $op;
$mod = !in_array($mod , array('delete', 'ignore', 'validate')) ? 'ignore' : $mod;
$filter = !empty($filter) ? -3 : 0;
$filtercheck = array($filter => 'selected="selected"');
$pstat = $filter == -3 ? -3 : -2;
$tpp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$postlist = array();
$modpost = array('validate' => 0, 'delete' => 0, 'ignore' => 0);
$moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
if(submitcheck('dosubmit', 1) || submitcheck('modsubmit')) {
$list = array();
if($moderate && is_array($moderate)) {
foreach($moderate as $val) {
if(is_numeric($val) && $val) {
$moderation[$mod][] = $val;
}
}
}
if(submitcheck('dosubmit', 1)) {
$list = $moderation[$mod];
include template('modcp_moderate_float');
dexit();
} else {
require_once DISCUZ_ROOT.'./include/post.func.php';
$updatestat = $op == 'replies' ? 1 : 2;
$modpost = array(
'ignore' => count($moderation['ignore']),
'delete' => count($moderation['delete']),
'validate' => count($moderation['validate'])
);
}
}
if($op == 'replies') {
if(submitcheck('modsubmit')) {
$pmlist = array();
if($ignorepids = implodeids($moderation['ignore'])) {
$db->query("UPDATE {$tablepre}posts SET invisible='-3' WHERE pid IN ($ignorepids) AND invisible='-2' AND first='0' AND ".($modfidsadd ? $modfidsadd : '1'));
}
if($deletepids = implodeids($moderation['delete'])) {
$query = $db->query("SELECT pid, authorid, tid, message FROM {$tablepre}posts WHERE pid IN ($deletepids) AND invisible='$pstat' AND first='0' AND ".($modfidsadd ? $modfidsadd : '1'));
$pids = '0';
while($post = $db->fetch_array($query)) {
$pids .= ','.$post['pid'];
$pm = 'pm_'.$post['pid'];
if(isset($$pm) && $$pm <> '' && $post['authorid']) {
$pmlist[] = array(
'act' => 'modreplies_delete_',
'authorid' => $post['authorid'],
'tid' => $post['tid'],
'post' => dhtmlspecialchars(cutstr($post['message'], 30)),
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($pids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE pid IN ($pids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE pid IN ($pids)", 'UNBUFFERED');
}
updatemodworks('DLP', count($moderation['delete']));
}
$repliesmod = 0;
if($validatepids = implodeids($moderation['validate'])) {
$threads = $lastpost = $attachments = $pidarray = $authoridarray = array();
$query = $db->query("SELECT t.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, ff.replycredits
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}forumfields ff ON ff.fid=p.fid
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
WHERE p.pid IN ($validatepids) AND p.invisible='$pstat' AND p.first='0' AND ".($modfidsadd ? "p.{$modfidsadd}" : '1'));
while($post = $db->fetch_array($query)) {
$repliesmod ++;
$pidarray[] = $post['pid'];
if($post['replycredits']) {
updatepostcredits('+', $post['authorid'], unserialize($post['replycredits']));
} else {
$authoridarray[] = $post['authorid'];
}
$threads[$post['tid']]['posts']++;
$threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ?
", lastpost='$post[dateline]', lastposter='".($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author]))."'" : '';
$threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : '';
$pm = 'pm_'.$post['pid'];
if(isset($$pm) && $$pm <> '' && $post['authorid']) {
$pmlist[] = array(
'act' => 'modreplies_validate_',
'authorid' => $post['authorid'],
'tid' => $post['tid'],
'post' => dhtmlspecialchars(cutstr($post['message'], 30)),
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($authoridarray) {
updatepostcredits('+', $authoridarray, $creditspolicy['reply']);
}
foreach($threads as $tid => $thread) {
$db->query("UPDATE {$tablepre}threads SET replies=replies+$thread[posts] $thread[lastpostadd] $thread[attachadd] WHERE tid='$tid'", 'UNBUFFERED');
}
updateforumcount($fid);
if(!empty($pidarray)) {
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE pid IN (0,".implode(',', $pidarray).")");
$repliesmod = $db->affected_rows();
updatemodworks('MOD', $repliesmod);
} else {
updatemodworks('MOD', 1);
}
}
if($pmlist) {
foreach($pmlist as $pm) {
$reason = $pm['reason'];
$post = $pm['post'];
$tid = intval($pm['tid']);
sendpm($pm['authorid'], $pm['act'].'subject', $pm['act'].'message', 0);
}
}
showmessage('modcp_mod_succeed', "{$cpscript}?action=$action&op=$op&filter=$filter&fid=$fid");
}
$attachlist = array();
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$ppp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $ppp;
$modcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE invisible='$pstat' AND first='0' AND ".($modfidsadd ? $modfidsadd : '1'));
$multipage = multi($modcount, $ppp, $page, "{$cpscript}?action=$action&op=$op&filter=$filter&fid=$fid");
if($modcount) {
$query = $db->query("SELECT f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode,
p.pid, p.fid, p.tid, p.author, p.authorid, p.subject, p.dateline, p.message, p.useip, p.attachment,
p.htmlon, p.smileyoff, p.bbcodeoff, t.subject AS tsubject
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
LEFT JOIN {$tablepre}forums f ON f.fid=p.fid
WHERE p.invisible='$pstat' AND p.first='0' AND ".($modfidsadd ? "p.{$modfidsadd}" : '1')."
ORDER BY p.dateline DESC LIMIT $start_limit, $ppp");
while($post = $db->fetch_array($query)) {
$post['id'] = $post['pid'];
$post['dateline'] = gmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['subject'] = $post['subject'] ? '<b>'.$post['subject'].'</b>' : '<i>'.$lang['nosubject'].'</i>';
$post['message'] = nl2br(dhtmlspecialchars($post['message']));
if($post['attachment']) {
$queryattach = $db->query("SELECT aid, filename, filetype, filesize, attachment, isimage, remote FROM {$tablepre}attachments WHERE pid='$post[pid]'");
while($attach = $db->fetch_array($queryattach)) {
$attachurl = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
$attach['url'] = $attach['isimage']
? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"$attachurl/$attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">"
: "<a href=\"$attachurl/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
$post['message'] .= "<br /><br />File: ".attachtype(fileext($attach['filename'])."\t".$attach['filetype']).$attach['url'];
}
}
$postlist[] = $post;
}
}
} else {
if(submitcheck('modsubmit')) {
if($ignoretids = implodeids($moderation['ignore'])) {
$db->query("UPDATE {$tablepre}threads SET displayorder='-3' WHERE tid IN ($ignoretids) AND displayorder='-2' AND ".($modfidsadd ? $modfidsadd : '1'));
}
$threadsmod = 0;
$pmlist = array();
$reason = trim($reason);
if($ids = implodeids($moderation['delete'])) {
$deletetids = '0';
$recyclebintids = '0';
$query = $db->query("SELECT tid, fid, authorid, subject FROM {$tablepre}threads WHERE tid IN ($ids) AND displayorder='$pstat' AND ".($modfidsadd ? $modfidsadd : '1'));
while($thread = $db->fetch_array($query)) {
if($modforums['recyclebins'][$thread['fid']]) {
$recyclebintids .= ','.$thread['tid'];
} else {
$deletetids .= ','.$thread['tid'];
}
if($reason != '' && $thread['authorid']) {
$pmlist[] = array(
'act' => 'modthreads_delete_',
'authorid' => $thread['authorid'],
'thread' => $thread['subject'],
'reason' => dhtmlspecialchars($reason)
);
}
}
if($recyclebintids) {
$db->query("UPDATE {$tablepre}threads SET displayorder='-1', moderated='1' WHERE tid IN ($recyclebintids)");
updatemodworks('MOD', $db->affected_rows());
$db->query("UPDATE {$tablepre}posts SET invisible='-1' WHERE tid IN ($recyclebintids)");
updatemodlog($recyclebintids, 'DEL');
}
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($deletetids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ($deletetids)");
$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($deletetids)", 'UNBUFFERED');
}
if($validatetids = implodeids($moderation['validate'])) {
$tids = $comma = $comma2 = '';
$authoridarray = $moderatedthread = array();
$query = $db->query("SELECT t.fid, t.tid, t.authorid, t.subject, t.author, t.dateline FROM {$tablepre}threads t
WHERE t.tid IN ($validatetids) AND t.displayorder='$pstat' AND ".($modfidsadd ? "t.{$modfidsadd}" : '1'));
while($thread = $db->fetch_array($query)) {
$tids .= $comma.$thread['tid'];
$comma = ',';
if($thread['postcredits']) {
updatepostcredits('+', $thread['authorid'], $forum['postcredits']);
} else {
$authoridarray[] = $thread['authorid'];
}
$validatedthreads[] = $thread;
if($reason != '' && $thread['authorid']) {
$pmlist[] = array(
'act' => 'modthreads_validate_',
'authorid' => $thread['authorid'],
'tid' => $thread['tid'],
'thread' => $thread['subject'],
'reason' => dhtmlspecialchars($reason)
);
}
}
if($tids) {
if($authoridarray) {
updatepostcredits('+', $authoridarray, $creditspolicy['post']);
}
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE tid IN ($tids)");
$db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ($tids)");
$threadsmod = $db->affected_rows();
updateforumcount($fid);
updatemodworks('MOD', $threadsmod);
updatemodlog($tids, 'MOD');
}
}
if($pmlist) {
foreach($pmlist as $pm) {
$reason = $pm['reason'];
$threadsubject = $pm['thread'];
$tid = intval($pm['tid']);
sendpm($pm['authorid'], $pm['act'].'subject', $pm['act'].'message', 0);
}
}
showmessage('modcp_mod_succeed', "{$cpscript}?action=$action&op=$op&filter=$filter&fid=$fid");
}
$modcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE ".($modfidsadd ? " $modfidsadd AND " : '')." displayorder='$pstat'");
$multipage = multi($modcount, $tpp, $page, "{$cpscript}?action=$action&op=$op&filter=$filter&fid=$fid");
if($modcount) {
$query = $db->query("SELECT t.tid, t.fid, t.author, t.sortid, t.authorid, t.subject as tsubject, t.dateline, t.attachment,
p.pid, p.message, p.useip, p.attachment
FROM {$tablepre}threads t
LEFT JOIN {$tablepre}posts p ON p.tid=t.tid AND p.first = 1
WHERE ".($modfidsadd ? " t.{$modfidsadd} AND " : '')." t.displayorder='$pstat'
ORDER BY t.dateline DESC LIMIT $start_limit, $tpp");
while($thread = $db->fetch_array($query)) {
$thread['id'] = $thread['tid'];
if($thread['authorid'] && $thread['author'] != '') {
$thread['author'] = "<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>";
} elseif($thread['authorid']) {
$thread['author'] = "<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">UID $thread[uid]</a>";
} else {
$thread['author'] = 'guest';
}
$thread['dateline'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
$thread['message'] = nl2br(dhtmlspecialchars($thread['message']));
if($thread['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$queryattach = $db->query("SELECT aid, filename, filetype, filesize, attachment, isimage, remote FROM {$tablepre}attachments WHERE tid='$thread[tid]'");
while($attach = $db->fetch_array($queryattach)) {
$attachurl = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
$attach['url'] = $attach['isimage']
? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"$attachurl/$attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">"
: "<a href=\"$attachurl/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
$thread['attach'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($thread['filename'])."\t".$attach['filetype']).$attach['url'];
}
} else {
$thread['attach'] = '';
}
$optiondata = $optionlist = array();
if($thread['sortid']) {
if(@include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$thread['sortid'].'.php') {
$query = $db->query("SELECT optionid, value FROM {$tablepre}typeoptionvars WHERE tid='$thread[tid]'");
while($option = $db->fetch_array($query)) {
$optiondata[$option['optionid']] = $option['value'];
}
foreach($_DTYPE as $optionid => $option) {
$optionlist[$option['identifier']]['title'] = $_DTYPE[$optionid]['title'];
if($_DTYPE[$optionid]['type'] == 'checkbox') {
$optionlist[$option['identifier']]['value'] = '';
foreach(explode("\t", $optiondata[$optionid]) as $choiceid) {
$optionlist[$option['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].' ';
}
} elseif(in_array($_DTYPE[$optionid]['type'], array('radio', 'select'))) {
$optionlist[$option['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$optiondata[$optionid]];
} elseif($_DTYPE[$optionid]['type'] == 'image') {
$maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : '';
$maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : '';
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$optiondata[$optionid]\" $maxwidth $maxheight border=\"0\"></a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'url') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\">$optiondata[$optionid]</a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'textarea') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? nl2br($optiondata[$optionid]) : '';
} else {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid];
}
}
}
foreach($optionlist as $option) {
$thread['sortinfo'] .= '<br />'.$option['title'].' '.$option['value'];
}
} else {
$thread['sortinfo'] = '';
}
$postlist[] = $thread;
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/moderate.inc.php
|
PHP
|
asf20
| 21,602
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forums.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
$forumupdate = $listupdate = false;
$op = !in_array($op , array('editforum', 'recommend')) ? 'editforum' : $op;
if(empty($fid)) {
if(!empty($_DCOOKIE['modcpfid'])) {
$fid = $_DCOOKIE['modcpfid'];
} else {
list($fid) = array_keys($modforums['list']);
}
dheader("Location: {$cpscript}?action=$action&op=$op&fid=$fid");
}
if($fid && $forum['ismoderator']) {
if($op == 'editforum') {
require_once DISCUZ_ROOT.'./include/editor.func.php';
$alloweditrules = $adminid == 1 || $forum['alloweditrules'] ? true : false;
if(!submitcheck('editsubmit')) {
$forum['description'] = html2bbcode($forum['description']);
$forum['rules'] = html2bbcode($forum['rules']);
} else {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$forumupdate = true;
$descnew = addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($descnew), 1, 0, 0, 0, 1, 1, 0, 0, 1)));
$rulesnew = $alloweditrules ? addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($rulesnew), 1, 0, 0, 0, 1, 1, 0, 0, 1))) : addslashes($forum['rules']);
$db->query("UPDATE {$tablepre}forumfields SET description='$descnew', rules='$rulesnew' WHERE fid='$fid'");
$forum['description'] = html2bbcode(stripslashes($descnew));
$forum['rules'] = html2bbcode(stripslashes($rulesnew));
}
} elseif($op == 'recommend') {
$useradd = $adminid == 3 ? "AND moderatorid='$discuz_uid'" : '';
$ordernew = !empty($ordernew) && is_array($ordernew) ? $ordernew : array();
if(submitcheck('editsubmit')) {
if($ids = implodeids($delete)) {
$listupdate = true;
$db->query("DELETE FROM {$tablepre}forumrecommend WHERE fid='$fid' AND tid IN($ids) $useradd");
}
}
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$threadcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}forumrecommend WHERE fid='$fid' $useradd");
$multipage = multi($threadcount, $tpp, $page, "$cpscript?action=$action&fid=$fid&page=$page");
$threadlist = array();
$query = $db->query("SELECT f.*, m.username as moderator
FROM {$tablepre}forumrecommend f
LEFT JOIN {$tablepre}members m ON f.moderatorid=m.uid
WHERE f.fid='$fid' $useradd LIMIT $start_limit,$tpp");
while($thread = $db->fetch_array($query)) {
$thread['author'] =$thread['authorid'] ? "<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>" : 'Guest';
$thread['moderator'] = $thread['moderator'] ? "<a href=\"space.php?uid=$thread[moderatorid]\" target=\"_blank\">$thread[moderator]</a>" : 'System';
$thread['expiration'] = $thread['expiration'] ? gmdate("$dateformat $timeformat", $thread['expiration'] + ($timeoffset * 3600)) : '';
if(isset($ordernew[$thread['tid']]) && $ordernew[$thread['tid']] != $thread['displayorder']) {
$listupdate = true;
$thread['displayorder'] = intval($ordernew[$thread['tid']]);
$db->query("UPDATE {$tablepre}forumrecommend SET displayorder='$thread[displayorder]' WHERE fid='$fid' AND tid='$thread[tid]' $useradd", "UNBUFFERED");
}
$threadlist[] = $thread;
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/forums.inc.php
|
PHP
|
asf20
| 3,535
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: editpost.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
if(!$discuz_uid || !($forum['ismoderator'])) {
// showmessage('admin_nopermission', NULL, 'HALTED');
exit('Admin Nopermission');
}
if($action == 'editsubject') {
$orig = $db->fetch_first("SELECT m.adminid, p.first, p.authorid, p.author, p.dateline, p.anonymous, p.invisible FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
WHERE p.tid='$tid' AND p.first='1' AND fid='$fid'");
if(empty($orig)) {
showmessage('thread_nonexistence', NULL, 'AJAXERROR');
}
periodscheck('postbanperiods');
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
showmessage('forum_nopermission', NULL, 'NOPERM');
}
}
if(!$forum['ismoderator'] || !$alloweditpost || (in_array($orig['adminid'], array(1, 2, 3)) && $adminid > $orig['adminid'])) {
showmessage('post_edit_nopermission', NULL, 'HALTED');
}
if(!submitcheck('editsubjectsubmit', 1)) {
include template('modcp_editpost');
exit;
} else {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$subjectnew = dhtmlspecialchars(censor(trim($subjectnew)));
if(strlen($subjectnew) > 80) {
showmessage('post_subject_toolong');
}
$query = $db->query("UPDATE {$tablepre}threads SET subject='$subjectnew' WHERE tid='$tid'");
$query = $db->query("UPDATE {$tablepre}posts SET subject='$subjectnew' WHERE tid='$tid' AND first='1'");
showmessage('<a href="viewthread.php?tid='.$tid.'">'.stripslashes($subjectnew).'</a>');
}
} elseif($action == 'editmessage') {
$orig = $db->fetch_first("SELECT m.adminid, p.first, p.authorid, p.author, p.dateline, p.anonymous, p.invisible, p.message FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
WHERE p.pid='$pid' AND p.invisible > -1");
if(empty($orig)) {
showmessage('post_check', NULL, 'AJAXERROR');
}
periodscheck('postbanperiods');
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
showmessage('forum_nopermission', NULL, 'NOPERM');
}
}
if(!$forum['ismoderator'] || !$alloweditpost || (in_array($orig['adminid'], array(1, 2, 3)) && $adminid > $orig['adminid'])) {
showmessage('post_edit_nopermission', NULL, 'HALTED');
}
if(!submitcheck('editmessagesubmit', 1)) {
include template('modcp_editpost');
exit;
} else {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
if($do == 'notupdate') {
$message = $orig['message'];
$message = discuzcode($message, 0, 0, 0, $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], 0, 0, $orig['authorid']);
showmessage(stripslashes($message));
} else {
$message = censor(trim($message));
if(!$disablepostctrl) {
if($maxpostsize && strlen($message) > $maxpostsize) {
showmessage('post_message_toolong');
} elseif($minpostsize && strlen(preg_replace("/\[quote\].+?\[\/quote\]/is", '', $message)) < $minpostsize) {
showmessage('post_message_tooshort');
}
}
$query = $db->query("UPDATE {$tablepre}posts SET message='$message' WHERE pid='$pid'");
$message = discuzcode($message, 0, 0, 0, $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], 0, 0, $orig['authorid']);
showmessage(stripslashes($message));
}
}
}
include template('modcp_editpost');
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/editpost.inc.php
|
PHP
|
asf20
| 3,925
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: login.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/login.inc.php
|
PHP
|
asf20
| 261
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forumaccess.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
exit('Access Denied');
}
$list = $logids = array();
include_once(DISCUZ_ROOT.'./include/forum.func.php');
$forumlistall = forumselect(false, false, $fid);
$adderror = $successed = 0;
$new_user = isset($new_user) ? trim($new_user) : '';
if($fid && $forum['ismoderator'] && $new_user != '' && submitcheck('addsubmit')) {
$deleteaccess = isset($deleteaccess) ? 1 : 0;
if($new_user != '') {
$user = $db->fetch_first("SELECT uid, adminid FROM {$tablepre}members WHERE username='$new_user'");
$uid = $user['uid'];
if(empty($user)) {
$adderror = 1;
} elseif($user['adminid'] && $adminid != 1) {
$adderror = 2;
} else {
$access = $db->fetch_first("SELECT * FROM {$tablepre}access WHERE fid='$fid' AND uid='$uid'");
if($deleteaccess) {
if($access && $adminid != 1 && inwhitelist($access)) {
$adderror = 3;
} else {
$successed = true;
$access && delete_access($user['uid'], $fid);
}
} elseif(!(empty($new_view) && empty($new_post) && empty($new_reply) && empty($new_getattach) && empty($new_postattach))) {
if($new_view == -1) {
$new_view = $new_post = $new_reply = $new_getattach = $new_postattach = -1;
} else {
$new_view = 0;
$new_post = $new_post ? -1 : 0;
$new_reply = $new_reply ? -1 : 0;
$new_getattach = $new_getattach ? -1 : 0;
$new_postattach = $new_postattach ? -1 : 0;
}
if(empty($access)) {
$successed = true;
$db->query("INSERT INTO {$tablepre}access SET
uid='$uid', fid='$fid', allowview='$new_view', allowpost='$new_post', allowreply='$new_reply',
allowpostattach='$new_postattach', allowgetattach='$new_getattach', adminuser='$discuz_uid', dateline='$timestamp'");
$db->query("UPDATE {$tablepre}members SET accessmasks='1' WHERE uid='$uid'", 'UNBUFFERED');
} elseif($new_view == -1 && $access['allowview'] == 1 && $adminid != 1) {
$adderror = 3;
} else {
if($adminid > 1) {
$new_view = $access['allowview'] == 1 ? 1 : $new_view;
$new_post = $access['allowpost'] == 1 ? 1 : $new_post;
$new_reply = $access['allowreply'] == 1 ? 1 : $new_reply;
$new_getattach = $access['allowgetattach'] == 1 ? 1 : $new_getattach;
$new_postattach = $access['postattach'] == 1 ? 1 : $new_postattach;
}
$successed = true;
$db->query("UPDATE {$tablepre}access SET
allowview='$new_view', allowpost='$new_post', allowreply='$new_reply',
allowpostattach='$new_postattach', allowgetattach='$new_getattach',
adminuser='$discuz_uid', dateline='$timestamp' WHERE uid='$uid' AND fid='$fid'");
$db->query("UPDATE {$tablepre}members SET accessmasks='1' WHERE uid='$uid'", 'UNBUFFERED');
}
}
}
}
$new_user = $adderror ? $new_user : '';
}
$new_user = dhtmlspecialchars($new_user);
$fidadd = $useradd = '';
$suser = isset($suser) ? trim($suser) : '';
if(submitcheck('searchsubmit')) {
$fidadd = $fid ? "AND fid='$fid'" : '';
if($suser != '') {
$suid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$suser'");
$useradd = "AND uid='$suid'";
}
}
$suser = dhtmlspecialchars($suser);
$page = max(1, intval($page));
$ppp = 10;
$list = array('pagelink' => '', 'data' => array());
if($num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}access WHERE 1=1 $fidadd $useradd")) {
$page = $page > ceil($num / $ppp) ? ceil($num / $ppp) : $page;
$start_limit = ($page - 1) * $ppp;
$list['pagelink'] = multi($num, $ppp, $page, "modcp.php?fid=$fid&action=$action");
$query = $db->query("SELECT * FROM {$tablepre}access WHERE 1=1 $fidadd $useradd ORDER BY dateline DESC LIMIT $start_limit, $ppp");
$uidarray = array();
while($access = $db->fetch_array($query)) {
$uidarray[$access['uid']] = $access['uid'];
$uidarray[$access['adminuser']] = $access['adminuser'];
$access['allowview'] = accessimg($access['allowview']);
$access['allowpost'] = accessimg($access['allowpost']);
$access['allowreply'] = accessimg($access['allowreply']);
$access['allowpostattach'] = accessimg($access['allowpostattach']);
$access['allowgetattach'] = accessimg($access['allowgetattach']);
$access['dateline'] = gmdate("$dateformat", $access['dateline'] + $timeoffset * 3600);
$access['forum'] = '<a href="forumdisplay.php?fid='.$access['fid'].'" target="_blank">'.strip_tags($_DCACHE['forums'][$access['fid']]['name']).'</a>';
$list['data'][] = $access;
}
$users = array();
if($uids = implodeids($uidarray)) {
$query = $db->query("SELECT uid, username FROM {$tablepre}members WHERE uid IN ($uids)");
while ($user = $db->fetch_array($query)) {
$users[$user['uid']] = $user['username'];
}
}
}
function delete_access($uid, $fid) {
global $db, $tablepre;
$db->query("DELETE FROM {$tablepre}access WHERE uid='$uid' AND fid='$fid'");
$mask = $db->result_first("SELECT count(*) FROM {$tablepre}access WHERE uid='$uid'");
if(!$mask) {
$db->query("UPDATE {$tablepre}members SET accessmasks='' WHERE uid='$uid'", 'UNBUFFERED');
}
}
function accessimg($access) {
return $access == -1 ? '<img src="images/common/access_disallow.gif" />' :
($access == 1 ? '<img src="images/common/access_allow.gif" />' : '<img src="images/common/access_normal.gif" />');
}
function inwhitelist($access) {
$return = false;
foreach (array('allowview', 'allowpost', 'allowreply', 'allowpostattach', 'allowgetattach') as $key) {
if($access[$key] == 1) {
$return = true;
break;
}
}
return $return;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/modcp/forumaccess.inc.php
|
PHP
|
asf20
| 5,677
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: campaign.php 12695 2008-03-06 09:46:12Z liuqiang $
*/
define('CURSCRIPT', 'campaign');
require_once './include/common.inc.php';
if($action == 'list') {
$query = $db->query("SELECT * FROM {$tablepre}virtualforums WHERE status='1'");
$catlist = $forumlist = array();
while($forum = $db->fetch_array($query)) {
if($forum['type'] == 'group') {
$catlist[$forum['fid']] = $forum;
} elseif($forum['type'] == 'forum') {
if($forum['lastpost']) {
list($forum['lp']['tid'], $forum['lp']['subject'], $forum['lp']['dateline'], $forum['lp']['author']) = explode("\t", $forum['lastpost']);
$forum['lp']['dateline'] = @dgmdate("$dateformat $timeformat", $forum['lp']['dateline']);
}
$forum['description'] = addslashes($forum['description']);
$forumlist[$forum['fup']][] = $forum;
}
}
} elseif($action == 'view' && $cid) {
$campaign = $db->fetch_first("SELECT status, url, autoupdate, lastupdated FROM {$tablepre}campaigns WHERE id='$cid' AND type='4'");
if(!$campaign || $campaign['status'] != 2) {
showmessage('forum_nonexistence');
}
$insenz = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='insenz'");
$insenz = $insenz ? unserialize($insenz) : array();
if(empty($insenz['authkey'])) {
showmessage('forum_nonexistence');
}
require_once DISCUZ_ROOT.'./include/insenz.func.php';
$iframeurl = $campaign['url']."siteid=$insenz[siteid]&cid=$cid&s=".urlencode(insenz_authcode("sitename=$bbname&siteurl=$boardurl&username=$discuz_userss&uid=$discuz_uid&email=$email&grouptitle=$grouptitle", 'ENCODE', $insenz['authkey'])).'&'.$_SERVER['QUERY_STRING'];
$update = $campaign['autoupdate'] && ($timestamp - $campaign['lastupdated']) < 600 ? FALSE : TRUE;
} else {
showmessage('undefined_action');
}
include template('campaign');
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/campaign.php
|
PHP
|
asf20
| 1,955
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: menu.inc.php 17261 2008-12-11 07:21:49Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
showmenu('global', array(
array('menu_settings_basic', 'settings&operation=basic'),
array('menu_settings_access', 'settings&operation=access'),
array('menu_settings_optimize', 'settings&operation=seo'),
array('menu_settings_functions', 'settings&operation=functions'),
array('menu_settings_user', 'settings&operation=permissions'),
array('menu_settings_credits', 'settings&operation=credits'),
$isfounder ? array('menu_settings_mail', 'settings&operation=mail') :array(),
array('menu_settings_sec', 'settings&operation=sec'),
array('menu_settings_datetime', 'settings&operation=datetime'),
array('menu_settings_attachments', 'settings&operation=attach'),
array('menu_settings_wap', 'settings&operation=wap'),
$isfounder ? array('menu_settings_uc', 'settings&operation=uc') : array(),
array('menu_settings_uchome', 'settings&operation=uchome'),
));
showmenu('forum', array(
array('menu_forums', 'forums'),
array('menu_forums_merge', 'forums&operation=merge'),
array('menu_forums_threadtypes', 'threadtypes'),
array('menu_forums_infotypes', 'threadtypes&special=1'),
array('menu_forums_infomodel', 'threadtypes&operation=typemodel'),
array('menu_forums_infooption', 'threadtypes&operation=typeoption')
));
showmenu('user', array(
array('menu_members_add', 'members&operation=add'),
array('menu_members_edit', 'members'),
array('menu_members_edit_ban_user', 'members&operation=ban'),
array('menu_members_ipban', 'members&operation=ipban'),
array('menu_members_credits', 'members&operation=reward'),
array('menu_moderate_modmembers', 'moderate&operation=members'),
array('menu_profilefields', 'profilefields'),
array('menu_admingroups', 'admingroups'),
array('menu_usergroups', 'usergroups'),
array('menu_ranks', 'ranks')
));
showmenu('topic', array(
array('menu_moderate_posts', 'moderate&operation=threads'),
array('menu_maint_threads', 'threads'),
array('menu_maint_prune', 'prune'),
array('menu_maint_attaches', 'attach'),
array('menu_moderate_recyclebin', 'recyclebin'),
array('menu_posting_tags', 'misc&operation=tag'),
array('menu_posting_censors', 'misc&operation=censor'),
array('menu_posting_attachtypes', 'misc&operation=attachtype')
));
showmenu('extended', array(
array('menu_plugins', 'plugins&operation=config'),
array('menu_tasks', 'tasks'),
array('menu_magics', 'magics&operation=config'),
array('menu_medals', 'medals'),
array('menu_tools_relatedtag', 'tools&operation=tag'),
array('menu_misc_help', 'faq&operation=list'),
array('menu_qihoo', 'qihoo&operation=config'),
array('menu_video', 'video&operation=config'),
array('menu_ec', 'settings&operation=ec'),
array('menu_settings_msn', 'settings&operation=msn')
));
showmenu('style', array(
array('menu_settings_styles', 'settings&operation=styles'),
array('menu_styles', 'styles'),
$isfounder ? array('menu_styles_templates', 'templates') : array(),
array('menu_posting_smilies', 'smilies'),
array('menu_thread_icon', 'misc&operation=icon'),
array('menu_posting_editor', 'settings&operation=editor'),
array('menu_misc_onlinelist', 'misc&operation=onlinelist'),
));
showmenu('tool', array(
array('menu_members_newsletter', 'members&operation=newsletter'),
array('menu_misc_announce', 'announce'),
array('menu_tools_updatecaches', 'tools&operation=updatecache'),
array('menu_tools_updatecounters', 'counter'),
array('menu_tools_javascript', 'jswizard'),
array('menu_tools_creditwizard', 'creditwizard'),
array('menu_forum_scheme', 'project'),
$isfounder ? array('menu_db', 'db&operation=export') : array(),
array('menu_logs', 'logs&operation=illegal'),
array('menu_custommenu_manage', 'misc&operation=custommenu'),
array('menu_misc_cron', 'misc&operation=cron'),
array('menu_tools_fileperms', 'tools&operation=fileperms'),
array('menu_tools_filecheck', 'checktools&operation=filecheck')
));
$insenz = ($insenz = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='insenz'")) ? unserialize($insenz) : array();
showmenu('adv', array(
array('menu_misc_link', 'misc&operation=link'),
array('menu_adv_custom', 'adv'),
array('menu_insenz_settings', 'insenz&operation=settings&do=basic'),
array('menu_insenz_softad', 'insenz&operation=campaignlist&c_status=2'),
$insenz['topicstatus'] ? array('menu_insenz_virtualforum', 'insenz&operation=virtualforum&c_status=2') : array(),
array('menu_insenz_tools_myinsenz', 'http://www.insenz.com/publishers/', '_blank'),
array('menu_insenz_tools_faq', 'http://www.insenz.com/publishers/faq/', '_blank')
));
showmenu('uc', array());
$historymenus = array(array('menu_home', 'home'));
$query = $db->query("SELECT title, url FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='0' ORDER BY dateline DESC LIMIT 0, 10");
while($custom = $db->fetch_array($query)) {
$historymenus[] = array($custom['title'], substr($custom['url'], 19));
}
if(count($historymenus) > 1) {
$historymenus[] = array('menu_home_clearhistorymenus', 'misc&operation=custommenu&do=clean', 'main', 'class="menulink"');
}
showmenu('index', $historymenus);
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/menu.inc.php
|
PHP
|
asf20
| 5,396
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: logs.inc.php 17465 2008-12-24 09:23:03Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$lpp = empty($lpp) ? 20 : $lpp;
$checklpp = array();
$checklpp[$lpp] = 'selected="selected"';
if(!in_array($operation, array('illegal', 'rate', 'credit', 'mods', 'medal', 'ban', 'cp', 'magic', 'error', 'invite'))) {
cpmsg('undefined_action', '', 'error');
}
$logdir = DISCUZ_ROOT.'./forumdata/logs/';
$logfiles = get_log_files($logdir, $operation.'log');
$logs = array();
foreach($logfiles as $logfile) {
$logs = array_merge($logs, file($logdir.$logfile));
}
$page = max(1, intval($page));
$start = ($page - 1) * $lpp;
$logs = array_reverse($logs);
if(empty($keyword)) {
$num = count($logs);
$multipage = multi($num, $lpp, $page, "$BASESCRIPT?action=logs&operation=$operation&lpp=$lpp", 0, 3);
$logs = array_slice($logs, $start, $lpp);
} else {
foreach($logs as $key => $value) {
if(strpos($value, $keyword) === FALSE) {
unset($logs[$key]);
}
}
$multipage = '';
}
$usergroup = array();
if(in_array($operation, array('rate', 'mods', 'ban', 'cp'))) {
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$usergroup[$group['groupid']] = $group['grouptitle'];
}
}
shownav('tools', 'nav_logs', 'nav_logs_'.$operation);
showsubmenu('nav_logs', array(
array('nav_logs_illegal', 'logs&operation=illegal', $operation == 'illegal'),
array('nav_logs_rate', 'logs&operation=rate', $operation == 'rate'),
array('nav_logs_credit', 'logs&operation=credit', $operation == 'credit'),
array('nav_logs_mods', 'logs&operation=mods', $operation == 'mods'),
array('nav_logs_medal', 'logs&operation=medal', $operation == 'medal'),
array('nav_logs_ban', 'logs&operation=ban', $operation == 'ban'),
array('nav_logs_cp', 'logs&operation=cp', $operation == 'cp'),
array('nav_logs_magic', 'logs&operation=magic', $operation == 'magic'),
array('nav_logs_invite', 'logs&operation=invite', $operation == 'invite'),
array('nav_logs_error', 'logs&operation=error', $operation == 'error')
));
showformheader("logs&operation=$operation");
showtableheader('', 'fixpadding');
$filters = '';
if($operation == 'illegal') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td23"','class="td23"'), array(
lang('logs_passwd_username'),
lang('logs_passwd_password'),
lang('logs_passwd_security'),
lang('ip'),
lang('time'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
if(strtolower($log[2]) == strtolower($discuz_userss)) {
$log[2] = "<b>$log[2]</b>";
}
$log[5] = $allowviewip ? $log[5] : '-';
showtablerow('', array('class="bold"', '', '', 'class="smallefont"', 'class="smallefont"'), array(
$log[2],
$log[3],
$log[4],
$log[5],
$log[1]
));
}
} elseif($operation == 'rate') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td23"','class="td23"','class="td24"'), array(
lang('username'),
lang('usergroup'),
lang('time'),
lang('logs_rating_username'),
lang('logs_rating_rating'),
lang('subject'),
lang('reason'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = "<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">$log[2]</a>";
$log[3] = $usergroup[$log[3]];
if($log[4] == $discuz_userss) {
$log[4] = "<b>$log[4]</b>";
}
$log[4] = "<a href=\"space.php?username=".rawurlencode($log[4])."\" target=\"_blank\">$log[4]</a>";
$log[6] = $extcredits[$log[5]]['title'].' '.($log[6] < 0 ? "<b>$log[6]</b>" : "+$log[6]").' '.$extcredits[$log[5]]['unit'];
$log[7] = $log[7] ? "<a href=\"./viewthread.php?tid=$log[7]\" target=\"_blank\" title=\"$log[8]\">".cutstr($log[8], 20)."</a>" : "<i>$lang[logs_rating_manual]</i>";
showtablerow('', array('class="bold"'), array(
$log[2],
$log[3],
$log[1],
$log[4],
(trim($log[10]) == 'D' ? $lang['logs_rating_delete'] : '').$log[6],
$log[7],
$log[9]
));
}
} elseif($operation == 'credit') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td24"','class="td24"'), array(
lang('username'),
lang('logs_credit_fromto'),
lang('time'),
lang('logs_credit_send'),
lang('logs_credit_receive'),
lang('action'),
));
$lpp = max(5, empty($lpp) ? 50 : intval($lpp));
$page = max(1, intval($page));
$start_limit = ($page - 1) * $lpp;
$keywordadd = !empty($keyword) ? "AND c.fromto LIKE '%$keyword%'" : '';
$mpurl = "$BASESCRIPT?action=logs&operation=$operation&keyword=".rawurlencode($keyword)."&lpp=$lpp";
if(in_array($opt, array('TFR', 'RCV', 'EXC', 'UGP', 'AFD'))) {
$optadd = "AND c.operation='$opt'";
$mpurl .= '&opt='.$opt;
} else {
$optadd = '';
}
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}creditslog c WHERE 1 $keywordadd $optadd");
$multipage = multi($num, $lpp, $page, $mpurl, 0, 3);
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=credit&opt=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array('TFR', 'RCV', 'EXC', 'UGP', 'AFD') as $o) {
$filters .= '<option value="'.$o.'" '.(!empty($opt) && $o == $opt ? 'selected="selected"' : '').'>'.$lang['logs_credit_operation_'.strtolower($o)].'</option>';
}
$filters .= '</select>';
$total['send'] = $total['receive'] = array();
$query = $db->query("SELECT c.*, m.username FROM {$tablepre}creditslog c
LEFT JOIN {$tablepre}members m USING (uid)
WHERE 1 $keywordadd $optadd ORDER BY dateline DESC LIMIT $start_limit, $lpp");
while($log = $db->fetch_array($query)) {
$total['send'][$log['sendcredits']] += $log['send'];
$total['receive'][$log['receivecredits']] += $log['receive'];
$log['dateline'] = gmdate('y-n-j H:i', $log['dateline'] + $timeoffset * 3600);
$log['operation'] = $lang['logs_credit_operation_'.strtolower($log['operation'])];
showtablerow('', array('class="bold"'), array(
"<a href=\"space.php?username=".rawurlencode($log['username'])."\" target=\"_blank\">$log[username]",
$log[fromto],
$log[dateline],
isset($extcredits[$log['sendcredits']]) ? $extcredits[$log['sendcredits']]['title'].' '.$log['send'].' '.$extcredits[$log['sendcredits']]['unit'] : $log['send'],
isset($extcredits[$log['receivecredits']]) ? $extcredits[$log['receivecredits']]['title'].' '.$log['receive'].' '.$extcredits[$log['receivecredits']]['unit'] : $log['receive'],
$log[operation],
));
}
$result = array('send' => array(), 'receive' => array());
foreach(array('send', 'receive') as $key) {
foreach($total[$key] as $id => $amount) {
if(isset($extcredits[$id])) {
$result[$key][] = $extcredits[$id]['title'].' '.$amount.' '.$extcredits[$id]['unit'];
}
}
}
showtablerow('', '', array(
'',
'',
'',
$lang['logs_credit_total'].implode('; ', $result['send']),
$lang['logs_credit_total'].implode(', ', $result['receive']),
''
));
} elseif($operation == 'mods') {
include language('modactions');
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td23"','class="td24"','class="td24"','class="td23"'), array(
lang('operator'),
lang('usergroup'),
lang('ip'),
lang('time'),
lang('forum'),
lang('thread'),
lang('action'),
lang('reason'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = stripslashes($log[2]);
$log[3] = $usergroup[$log[3]];
$log[4] = $allowviewip ? $log[4] : '-';
$log[6] = "<a href=\"./forumdisplay.php?fid=$log[5]\" target=\"_blank\">$log[6]</a>";
$log[8] = "<a href=\"./viewthread.php?tid=$log[7]\" target=\"_blank\" title=\"$log[8]\">".cutstr($log[8], 15)."</a>";
$log[9] = $modactioncode[trim($log[9])];
showtablerow('', array('class="bold"'), array(
"<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">".($log[2] != $discuz_userss ? "<b>$log[2]</b>" : $log[2]),
$log[3],
$log[4],
$log[1],
$log[6],
$log[8],
$log[9],
$log[10],
));
}
} elseif($operation == 'ban') {
showtablerow('class="header"', array('class="td23"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td24"', 'class="td23"'), array(
lang('operator'),
lang('usergroup'),
lang('ip'),
lang('time'),
lang('username'),
lang('operation'),
lang('logs_banned_group'),
lang('validity'),
lang('reason'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = "<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">$log[2]";
$log[3] = $usergroup[$log[3]];
$log[4] = $allowviewip ? $log[4] : '-';
$log[5] = "<a href=\"space.php?username=".rawurlencode($log[5])."\" target=\"_blank\">$log[5]</a>";
$log[8] = trim($log[8]) ? gmdate('y-n-j', $log[8] + $timeoffset * 3600) : '';
showtablerow('', array('class="bold"'), array(
$log[2],
$log[3],
$log[4],
$log[1],
$log[5],
(in_array($log[6], array(4, 5)) && !in_array($log[7], array(4, 5)) ? '<i>'.$lang['logs_banned_unban'].'</i>' : '<b>'.$lang['logs_banned_ban'].'</b>'),
"{$usergroup[$log[6]]} / {$usergroup[$log[7]]}",
$log[8],
$log[9]
));
}
} elseif($operation == 'cp') {
showtablerow('class="header"', array('class="td23"','class="td23"','class="td23"','class="td24"','class="td24"', ''), array(
lang('operator'),
lang('usergroup'),
lang('ip'),
lang('time'),
lang('action'),
lang('other')
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$log[2] = stripslashes($log[2]);
$log[2] = "<a href=\"space.php?username=".rawurlencode($log[2])."\" target=\"_blank\">".($log[2] != $discuz_userss ? "<b>$log[2]</b>" : $log[2])."</a>";
$log[3] = $usergroup[$log[3]];
$log[4] = $allowviewip ? $log[4] : '-';
$log[5] = $lang['cplog_'.rtrim($log[5])];
$log[6] = cutstr($log[6], 200);
showtablerow('', array('class="bold"'), array($log[2], $log[3], $log[4], $log[1], $log[5], $log[6]));
}
} elseif($operation == 'error') {
showtablerow('class="header"', array('class="td23"', 'class="td24"', 'class="td24"'), array(
lang('type'),
lang('username'),
lang('time'),
lang('message'),
));
foreach($logs as $logrow) {
$log = explode("\t", $logrow);
if(empty($log[1])) {
continue;
}
$log[1] = gmdate('y-n-j H:i', $log[1] + $timeoffset * 3600);
$tmp = explode('<br />', $log[3]);
$username = $tmp[1] ? "<a href=\"space.php?username=".rawurlencode($tmp[0])."\" target=\"_blank\">$tmp[0]</a>" : '';
$ip = $tmp[1] ? $tmp[1] : $tmp[0];
showtablerow('', array('class="bold"'), array(
$log[2],
($username ? $username."<br />" : '').$ip,
$log[1],
$log[4]
));
}
} elseif($operation == 'invite') {
if(!submitcheck('invitesubmit')) {
showtablerow('class="header"', array('width="35"','class="td23"','class="td24"','class="td24"','class="td23"','class="td24"','class="td24"'), array(
'',
lang('logs_invite_buyer'),
lang('logs_invite_buydate'),
lang('logs_invite_expiration'),
lang('logs_invite_ip'),
lang('logs_invite_code'),
lang('logs_invite_status'),
));
$tpp = $lpp ? intval($lpp) : $tpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$addstatus = '';
if(in_array($status, array(1,2,3,4))) {
$statusurl .= '&status='.$status;
$addstatus = "AND status='$status'";
}
$invitecount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}invites WHERE 1 $addstatus");
$multipage = multi($invitecount, $tpp, $page, "$BASESCRIPT?action=logs&operation=invite&lpp=$lpp$statusurl", 0, 3);
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=invite&status=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array(1,2,3,4) as $s) {
$filters .= '<option value="'.$s.'" '.(!empty($status) && $s == $status ? 'selected="selected"' : '').'>'.lang('logs_invite_status_'.$s).'</option>';
}
$filters .= '</select>';
$query = $db->query("SELECT i.*, m.username FROM {$tablepre}invites i, {$tablepre}members m
WHERE i.uid=m.uid $addstatus
ORDER BY i.dateline LIMIT $start_limit,$tpp");
while($invite = $db->fetch_array($query)) {
$invite['statuslog'] = $lang['logs_invite_status_'.$invite['status']];
$username = "<a href=\"space.php?uid=$invite[uid]\">$invite[username]</a>";
$invite['dateline'] = gmdate('Y-n-j H:i', $invite['dateline'] + $timeoffset * 3600);
$invite['expiration'] = gmdate('Y-n-j H:i', $invite['expiration'] + $timeoffset * 3600);
$stats = $invite['statuslog'].($invite['status'] == 2 ? ' [<a href="space.php?uid='.$invite['reguid'].'">'.$lang['logs_invite_target'].'</a>]' : '');
showtablerow('', array('', 'class="bold"'), array(
'<input type="checkbox" class="checkbox" name="delete[]" value="'.$invite[invitecode].'" />',
$username,
$invite['dateline'],
$invite['expiration'],
$invite['inviteip'],
$invite['invitecode'],
$stats
));
}
} else {
if($deletelist = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}invites WHERE invitecode IN ($deletelist)");
}
header("Location: $boardurl$BASESCRIPT?action=logs&operation=invite");
}
} elseif($operation == 'magic') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
$lpp = empty($lpp) ? 50 : $lpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $lpp;
$mpurl = "$BASESCRIPT?action=logs&operation=magic&lpp=$lpp";
if(in_array($opt, array('1', '2', '3', '4', '5'))) {
$optadd = "AND ma.action='$opt'";
$mpurl .= '&opt='.$opt;
} else {
$optadd = '';
}
if(!empty($magicid)) {
$magicidadd = "AND ma.magicid='".intval($magicid)."'";
} else {
$magicidadd = '';
}
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}magiclog ma WHERE 1 $magicidadd $optadd");
$multipage = multi($num, $lpp, $page, $mpurl, 0, 3);
$check1 = $check2 = array();
$check1[$magicid] = 'selected="selected"';
$check2[$opt] = 'selected="selected"';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=magic&opt='.$opt.'&lpp='.$lpp.'&magicid=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['magics_type'].'</option><option value="">'.$lang['magics_type_all'].'</option>';
foreach($_DCACHE['magics'] as $id => $magic) {
$filters .= '<option value="'.$id.'" '.$check1[$id].'>'.$magic['name'].'</option>';
}
$filters .= '</select>';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=magic&magicid='.$magicid.'&lpp='.$lpp.'&opt=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array('1', '2', '3', '4', '5') as $o) {
$filters .= '<option value="'.$o.'" '.$check2[$o].'>'.$lang['logs_magic_operation_'.$o].'</option>';
}
$filters .= '</select>';
showtablerow('class="header"', array('class="td23"', 'class="td23"', 'class="td24"', 'class="td23"', 'class="td23"', 'class="td24"'), array(
lang('username'),
lang('name'),
lang('time'),
lang('num'),
lang('price'),
lang('action')
));
$query = $db->query("SELECT ma.*, m.username FROM {$tablepre}magiclog ma
LEFT JOIN {$tablepre}members m USING (uid)
WHERE 1 $magicidadd $optadd ORDER BY dateline DESC LIMIT $start_limit, $lpp");
while($log = $db->fetch_array($query)) {
$log['name'] = $_DCACHE['magics'][$log['magicid']]['name'];
$log['dateline'] = gmdate('Y-n-j H:i', $log['dateline'] + $timeoffset * 3600);
$log['action'] = $lang['logs_magic_operation_'.$log['action']];
showtablerow('', array('class="bold"'), array(
"<a href=\"space.php?username=".rawurlencode($log['username'])."\" target=\"_blank\">$log[username]",
$log['name'],
$log['dateline'],
$log['amount'],
$log['price'],
$log['action']
));
}
} elseif($operation == 'medal') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
$lpp = empty($lpp) ? 50 : $lpp;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $lpp;
$mpurl = "$BASESCRIPT?action=logs&operation=medal&lpp=$lpp";
if(in_array($opt, array('0', '1', '2', '3'))) {
$optadd = "AND me.type='$opt'";
$mpurl .= '&opt='.$opt;
} else {
$optadd = '';
}
if(!empty($medalid)) {
$medalidadd = "AND me.medalid='".intval($medalid)."'";
} else {
$medalidadd = '';
}
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}medallog me WHERE 1 $medalidadd $optadd");
$multipage = multi($num, $lpp, $page, $mpurl, 0, 3);
$check1 = $check2 = array();
$check1[$medalid] = 'selected="selected"';
$check2[$opt] = 'selected="selected"';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=medal&opt='.$opt.'&lpp='.$lpp.'&medalid=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['medals'].'</option><option value="">'.$lang['all'].'</option>';
foreach($_DCACHE['medals'] as $id => $medal) {
$filters .= '<option value="'.$id.'" '.$check1[$id].'>'.$medal['name'].'</option>';
}
$filters .= '</select>';
$filters .= '<select onchange="window.location=\''.$BASESCRIPT.'?action=logs&operation=medal&medalid='.$medalid.'&lpp='.$lpp.'&opt=\'+this.options[this.selectedIndex].value"><option value="">'.$lang['action'].'</option><option value="">'.$lang['all'].'</option>';
foreach(array('0', '1', '2', '3') as $o) {
$filters .= '<option value="'.$o.'" '.$check2[$o].'>'.$lang['logs_medal_operation_'.$o].'</option>';
}
$filters .= '</select>';
showtablerow('class="header"', array('class="td23"', 'class="td24"', 'class="td23"', 'class="td23"'), array(
lang('username'),
lang('logs_medal_name'),
lang('type'),
lang('time'),
lang('logs_medal_expiration')
));
$query = $db->query("SELECT me.*, m.username FROM {$tablepre}medallog me
LEFT JOIN {$tablepre}members m USING (uid)
WHERE 1 $medalidadd $optadd ORDER BY dateline DESC LIMIT $start_limit, $lpp");
while($log = $db->fetch_array($query)) {
$log['name'] = $_DCACHE['medals'][$log['medalid']]['name'];
$log['dateline'] = gmdate('Y-n-j H:i', $log['dateline'] + $timeoffset * 3600);
$log['expiration'] = empty($log['expiration']) ? lang('logs_noexpire') : gmdate('Y-n-j H:i', $log['expiration'] + $timeoffset * 3600);
showtablerow('', array('class="td23"', 'class="td24"', 'class="td23"', 'class="td24"'), array(
"<a href=\"space.php?username=".rawurlencode($log['username'])."\" target=\"_blank\">$log[username]",
$log['name'],
$lang['logs_medal_operation_'.$log['type']],
$log['dateline'],
$log['expiration']
));
}
}
function get_log_files($logdir = '', $action = 'action') {
$dir = opendir($logdir);
$files = array();
while($entry = readdir($dir)) {
$files[] = $entry;
}
closedir($dir);
if($files) {
sort($files);
$logfile = $action;
$logfiles = array();
$ym = '';
foreach($files as $file) {
if(strpos($file, $logfile) !== FALSE) {
if(substr($file, 0, 6) != $ym) {
$ym = substr($file, 0, 6);
}
$logfiles[$ym][] = $file;
}
}
if($logfiles) {
$lfs = array();
foreach($logfiles as $ym => $lf) {
$lastlogfile = $lf[0];
unset($lf[0]);
$lf[] = $lastlogfile;
$lfs = array_merge($lfs, $lf);
}
return array_slice($lfs, -2, 2);
}
return array();
}
return array();
}
showsubmit($operation == 'invite' ? 'invitesubmit' : '', 'submit', 'del', $filters, $multipage.lang('logs_lpp').':<select onchange="if(this.options[this.selectedIndex].value != \'\') {window.location=\''.$BASESCRIPT.'?action=logs&operation='.$operation.'&lpp=\'+this.options[this.selectedIndex].value+\'&sid='.$sid.'\' }"><option value="20" '.$checklpp[20].'> 20 </option><option value="40" '.$checklpp[40].'> 40 </option><option value="80" '.$checklpp[80].'> 80 </option></select> <input type="text" class="txt" name="keyword" value="'.$keyword.'" /><input type="submit" class="btn" value="'.$lang['search'].'" />');
showtablefooter();
showformfooter();
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/logs.inc.php
|
PHP
|
asf20
| 21,349
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: recyclebin.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./include/post.func.php';
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
cpheader();
if(!$operation) {
if(!submitcheck('rbsubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="inforum"><option value=""> > '.$lang['select'].'</option>'.
'<option value=""> </option>'.forumselect().'</select>';
if($inforum) {
$forumselect = preg_replace("/(\<option value=\"$inforum\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
}
shownav('topic', 'nav_recyclebin');
showsubmenu('nav_recyclebin', array(
array('search', 'recyclebin', 1),
array('clean', 'recyclebin&operation=clean', 0)
));
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
showtagheader('div', 'threadsearch', !$searchsubmit);
showformheader('recyclebin');
showtableheader('recyclebin_search');
showsetting('recyclebin_search_forum', '', '', $forumselect);
showsetting('recyclebin_search_author', 'authors', $authors, 'text');
showsetting('recyclebin_search_keyword', 'keywords', $keywords, 'text');
showsetting('recyclebin_search_admin', 'admins', $admins, 'text');
showsetting('recyclebin_search_post_time', array('pstarttime', 'pendtime'), array($pstarttime, $pendtime), 'daterange');
showsetting('recyclebin_search_mod_time', array('mstarttime', 'mendtime'), array($mstarttime, $mendtime), 'daterange');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
$sql = '';
$sql .= $inforum ? " AND t.fid='$inforum'" : '';
$sql .= $authors != '' ? " AND t.author IN ('".str_replace(',', '\',\'', str_replace(' ', '', $authors))."')" : '';
$sql .= $admins != '' ? " AND tm.username IN ('".str_replace(',', '\',\'', str_replace(' ', '', $admins))."')" : '';
$sql .= $pstarttime != '' ? " AND t.dateline>='".strtotime($pstarttime)."'" : '';
$sql .= $pendtime != '' ? " AND t.dateline<'".strtotime($pendtime)."'" : '';
$sql .= $mstarttime != '' ? " AND tm.dateline>='".strtotime($mstarttime)."'" : '';
$sql .= $mendtime != '' ? " AND tm.dateline<'".strtotime($mendtime)."'" : '';
if(trim($keywords)) {
$sqlkeywords = $or = '';
foreach(explode(',', str_replace(' ', '', $keywords)) as $keyword) {
$sqlkeywords .= " $or t.subject LIKE '%$keyword%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
$query = $db->query("SELECT f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode,
t.tid, t.fid, t.authorid, t.author, t.subject, t.views, t.replies, t.dateline,
p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff,
tm.uid AS moduid, tm.username AS modusername, tm.dateline AS moddateline, tm.action AS modaction
FROM {$tablepre}threads t
LEFT JOIN {$tablepre}posts p ON p.tid=t.tid AND p.first='1'
LEFT JOIN {$tablepre}threadsmod tm ON tm.tid=t.tid
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
WHERE t.displayorder='-1' $sql
GROUP BY t.tid ORDER BY t.dateline DESC");
$threadcount = $db->num_rows($query);
echo '<script type="text/JavaScript">function attachimg() {}</script>';
showtagheader('div', 'threadlist', $searchsubmit);
showformheader('recyclebin', '', 'rbform');
showtableheader(lang('recyclebin_result').' '.$threadcount.' <a href="#" onclick="$(\'threadlist\').style.display=\'none\';$(\'threadsearch\').style.display=\'\';" class="act lightlink normal">'.lang('research').'</a>', 'fixpadding');
while($thread = $db->fetch_array($query)) {
$thread['message'] = discuzcode($thread['message'], $thread['smileyoff'], $thread['bbcodeoff'], sprintf('%00b', $thread['htmlon']), $thread['allowsmilies'], $thread['allowbbcode'], $thread['allowimgcode'], $thread['allowhtml']);
$thread['moddateline'] = gmdate("$dateformat $timeformat", $thread['moddateline'] + $timeoffset * 3600);
$thread['dateline'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
if($thread['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$queryattach = $db->query("SELECT aid, filename, filetype, filesize FROM {$tablepre}attachments WHERE tid='$thread[tid]'");
while($attach = $db->fetch_array($queryattach)) {
$thread['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($thread['filename'])."\t".$attach['filetype'])." $attach[filename] (".sizecount($attach['filesize']).")";
}
}
showtablerow("id=\"mod_$thread[tid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_1\" value=\"delete\" checked=\"checked\" /><label for=\"mod_$thread[tid]_1\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_2\" value=\"undelete\" /><label for=\"mod_$thread[tid]_2\">$lang[undelete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_3\" value=\"ignore\" /><label for=\"mod_$thread[tid]_3\">$lang[ignore]</label></li></ul>",
"<h3><a href=\"forumdisplay.php?fid=$thread[fid]\" target=\"_blank\">$thread[forumname]</a> » $thread[subject]</h3><p><span class=\"bold\">$lang[author]:</span> <a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a> <span class=\"bold\">$lang[time]:</span> $thread[dateline] $lang[threads_replies]: $thread[replies] $lang[threads_views]: $thread[views]</p>"
));
showtablerow("id=\"mod_$thread[tid]_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">'.$thread['message'].'</div>');
showtablerow("id=\"mod_$thread[tid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "$lang[operator]: <a href=\"space.php?uid=$thread[moduid]\" target=\"_blank\">$thread[modusername]</a> $lang[recyclebin_delete_time]: $thread[moddateline]");
}
showsubmit('rbsubmit', 'submit', '', '<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'delete\')">'.lang('recyclebin_all_delete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'undelete\')">'.lang('recyclebin_all_undelete').'</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'ignore\')">'.lang('recyclebin_all_ignore').'</a> ');
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
$moderation = array('delete' => array(), 'undelete' => array(), 'ignore' => array());
if(is_array($mod)) {
foreach($mod as $tid => $action) {
$moderation[$action][] = intval($tid);
}
}
$threadsdel = deletethreads($moderation['delete']);
$threadsundel = undeletethreads($moderation['undelete']);
cpmsg('recyclebin_succeed', $BASESCRIPT.'?action=recyclebin&operation=', 'succeed');
}
} elseif($operation == 'clean') {
if(!submitcheck('rbsubmit')) {
shownav('topic', 'nav_recyclebin');
showsubmenu('nav_recyclebin', array(
array('search', 'recyclebin', 0),
array('clean', 'recyclebin&operation=clean', 1)
));
showformheader('recyclebin&operation=clean');
showtableheader('recyclebin_clean');
showsetting('recyclebin_clean_days', 'days', '30', 'text');
showsubmit('rbsubmit');
showtablefooter();
showformfooter();
} else {
$deletetids = array();
$query = $db->query("SELECT tm.tid FROM {$tablepre}threadsmod tm, {$tablepre}threads t
WHERE tm.dateline<$timestamp-'$days'*86400 AND tm.action='DEL' AND t.tid=tm.tid AND t.displayorder='-1'");
while($thread = $db->fetch_array($query)) {
$deletetids[] = $thread['tid'];
}
$threadsdel = deletethreads($deletetids);
$threadsundel = 0;
cpmsg('recyclebin_succeed', $BASESCRIPT.'?action=recyclebin&operation=clean', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/recyclebin.inc.php
|
PHP
|
asf20
| 8,507
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ec.inc.php 17455 2008-12-23 05:28:37Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if($operation == 'alipay') {
$settings = array();
$query = $db->query("SELECT variable, value FROM {$tablepre}settings WHERE variable='ec_account'");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
if(!submitcheck('alipaysubmit')) {
if($from == 'creditwizard') {
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', 0),
array('creditwizard_step_menu_2', 'creditwizard&step=2', 0),
array('creditwizard_step_menu_3', 'creditwizard&step=3', 0),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 1),
));
} else {
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 1),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0)
));
}
showtips('ec_alipay_tips');
showformheader('ec&operation=alipay');
showtableheader('','nobottom');
showtitle('ec_alipay');
showsetting('ec_alipay_account', 'settingsnew[ec_account]', $settings['ec_account'], 'text');
showtablefooter();
showtableheader('', 'notop');
showsubmit('alipaysubmit');
showtablefooter();
showformfooter();
} else {
$db->query("UPDATE {$tablepre}settings SET value='$settingsnew[ec_account]' WHERE variable='ec_account'");
updatecache('settings');
cpmsg('alipay_succeed', $BASESCRIPT.'?action=ec&operation=alipay', 'succeed');
}
} elseif($operation == 'orders') {
$orderurl = array(
'alipay' => 'https://www.alipay.com/trade/query_trade_detail.htm?trade_no=',
);
if(!$creditstrans || !$ec_ratio) {
cpmsg('orders_disabled', '', 'error');
}
if(!submitcheck('ordersubmit')) {
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 1),
array('nav_ec_tradelog', 'tradelog', 0)
));
showtips('ec_orders_tips');
showtagheader('div', 'ordersearch', !submitcheck('searchsubmit', 1));
showformheader('ec&operation=orders');
showtableheader('ec_orders_search');
showsetting('ec_orders_search_status', array('orderstatus', array(
array('', $lang['ec_orders_search_status_all']),
array(1, $lang['ec_orders_search_status_pending']),
array(2, $lang['ec_orders_search_status_auto_finished']),
array(3, $lang['ec_orders_search_status_manual_finished'])
)), intval($orderstatus), 'select');
showsetting('ec_orders_search_id', 'orderid', $orderid, 'text');
showsetting('ec_orders_search_users', 'users', $users, 'text');
showsetting('ec_orders_search_buyer', 'buyer', $buyer, 'text');
showsetting('ec_orders_search_admin', 'admin', $admin, 'text');
showsetting('ec_orders_search_submit_date', array('sstarttime', 'sendtime'), array($sstarttime, $sendtime), 'daterange');
showsetting('ec_orders_search_confirm_date', array('cstarttime', 'cendtime'), array($cstarttime, $cendtime), 'daterange');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit', 1)) {
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$sql = '';
$sql .= $orderstatus != '' ? " AND o.status='$orderstatus'" : '';
$sql .= $orderid != '' ? " AND o.orderid='$orderid'" : '';
$sql .= $users != '' ? " AND m.username IN ('".str_replace(',', '\',\'', str_replace(' ', '', $users))."')" : '';
$sql .= $buyer != '' ? " AND o.buyer='$buyer'" : '';
$sql .= $admin != '' ? " AND o.admin='$admin'" : '';
$sql .= $sstarttime != '' ? " AND o.submitdate>='".strtotime($sstarttime)."'" : '';
$sql .= $sendtime != '' ? " AND o.submitdate<'".strtotime($sendtime)."'" : '';
$sql .= $cstarttime != '' ? " AND o.confirmdate>='".strtotime($cstarttime)."'" : '';
$sql .= $cendtime != '' ? " AND o.confirmdate<'".strtotime($cendtime)."'" : '';
$ordercount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}orders o, {$tablepre}members m WHERE m.uid=o.uid $sql");
$multipage = multi($ordercount, $tpp, $page, "$BASESCRIPT?action=ec&operation=orders&searchsubmit=yes&orderstatus=$orderstatus&orderid=$orderid&users=$users&buyer=$buyer&admin=$admin&sstarttime=$sstarttime&sendtime=$sendtime&cstarttime=$cstarttime&cendtime=$cendtime");
showtagheader('div', 'orderlist', TRUE);
showformheader('ec&operation=orders');
showtableheader('result');
showsubtitle(array('', 'ec_orders_id', 'ec_orders_status', 'ec_orders_buyer', 'ec_orders_amount', 'ec_orders_price', 'ec_orders_submitdate', 'ec_orders_confirmdate'));
$query = $db->query("SELECT o.*, m.username
FROM {$tablepre}orders o, {$tablepre}members m
WHERE m.uid=o.uid $sql ORDER BY o.submitdate DESC
LIMIT $start_limit, $tpp");
while($order = $db->fetch_array($query)) {
switch($order['status']) {
case 1: $order['orderstatus'] = $lang['ec_orders_search_status_pending']; break;
case 2: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_auto_finished'].'</b>'; break;
case 3: $order['orderstatus'] = '<b>'.$lang['ec_orders_search_status_manual_finished'].'</b><br />(<a href="space.php?username='.rawurlencode($order['admin']).'" target="_blank">'.$order['admin'].'</a>)'; break;
}
$order['submitdate'] = gmdate("$dateformat $timeformat", $order['submitdate'] + $timeoffset * 3600);
$order['confirmdate'] = $order['confirmdate'] ? gmdate("$dateformat $timeformat", $order['confirmdate'] + $timeoffset * 3600) : 'N/A';
list($orderid, $apitype) = explode("\t", $order['buyer']);
$apitype = $apitype ? $apitype : 'alipay';
$orderid = '<a href="'.$orderurl[$apitype].$orderid.'" target="_blank">'.$orderid.'</a>';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"validate[]\" value=\"$order[orderid]\" ".($order['status'] != 1 ? 'disabled' : '').">",
"$order[orderid]<br />$orderid",
$order[orderstatus],
"<a href=\"space.php?uid=$order[uid]\" target=\"_blank\">$order[username]</a>",
"{$extcredits[$creditstrans]['title']} $order[amount] {$extcredits[$creditstrans]['unit']}",
"$lang[rmb] $order[price] $lang[rmb_yuan]",
$order[submitdate],
$order[confirmdate]
));
}
showsubmit('ordersubmit', 'submit', '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'validate\')" /><label for="chkall">'.lang('ec_orders_validate').'</label>', '<a href="#" onclick="$(\'orderlist\').style.display=\'none\';$(\'ordersearch\').style.display=\'\';">'.lang('research').'</a>', $multipage);
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
$numvalidate = 0;
if($validate) {
$orderids = $comma = '';
$confirmdate = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$query = $db->query("SELECT * FROM {$tablepre}orders WHERE orderid IN ('".implode('\',\'', $validate)."') AND status='1'");
while($order = $db->fetch_array($query)) {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+'$order[amount]' WHERE uid='$order[uid]'");
$orderids .= "$comma'$order[orderid]'";
$comma = ',';
$submitdate = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $order['submitdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
sendpm($order['uid'], 'addfunds_subject', 'addfunds_message', $fromid = '0', $from = 'System Message');
}
if($numvalidate = $db->num_rows($query)) {
$db->query("UPDATE {$tablepre}orders SET status='3', admin='$discuz_user', confirmdate='$timestamp' WHERE orderid IN ($orderids)");
}
}
cpmsg('orders_validate_succeed', "$BASESCRIPT?action=ec&operation=orders&searchsubmit=yes&orderstatus=$orderstatus&orderid=$orderid&users=$users&buyer=$buyer&admin=$admin&sstarttime=$sstarttime&sendtime=$sendtime&cstarttime=$cstarttime&cendtime=$cendtime", 'succeed');
}
} elseif($operation == 'credit') {
$defaultrank = array(
1 => 4,
2 => 11,
3 => 41,
4 => 91,
5 => 151,
6 => 251,
7 => 501,
8 => 1001,
9 => 2001,
10 => 5001,
11 => 10001,
12 => 20001,
13 => 50001,
14 => 100001,
15 => 200001
);
if(!submitcheck('creditsubmit')) {
$ec_credit = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='ec_credit'");
$ec_credit = $ec_credit ? unserialize($ec_credit) : array(
'maxcreditspermonth' => '6',
'rank' => $defaultrank
);
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=ec_credit', 1),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0)
));
showtips('ec_credit_tips');
showformheader('ec&operation=credit');
showtableheader('ec_credit', 'nobottom');
showsetting('ec_credit_maxcreditspermonth', 'ec_creditnew[maxcreditspermonth]', $ec_credit['maxcreditspermonth'], 'text');
showtablefooter('</tbody>');
showtableheader('ec_credit_rank', 'notop fixpadding');
showsubtitle(array('ec_credit_rank', 'ec_credit_between', 'ec_credit_sellericon', 'ec_credit_buyericon'));
foreach($ec_credit['rank'] as $rank => $mincredits) {
showtablerow('', '', array(
$rank,
'<input type="text" class="txt" size="6" name="ec_creditnew[rank]['.$rank.']" value="'.$mincredits.'" /> ~ '.$ec_credit[rank][$rank + 1],
"<img src=\"images/rank/seller/$rank.gif\" border=\"0\">",
"<img src=\"images/rank/buyer/$rank.gif\" border=\"0\">"
));
}
showsubmit('creditsubmit');
showtablefooter();
showformfooter();
} else {
$ec_creditnew['maxcreditspermonth'] = intval($ec_creditnew['maxcreditspermonth']);
if(is_array($ec_creditnew['rank'])) {
foreach($ec_creditnew['rank'] as $rank => $mincredits) {
$mincredits = intval($mincredits);
if($rank == 1 && $mincredits <= 0) {
cpmsg('ecommerce_invalidcredit', '', 'error');
} elseif($rank > 1 && $mincredits <= $ec_creditnew['rank'][$rank - 1]) {
cpmsg('ecommerce_must_larger', '', 'error');
}
$ec_creditnew['rank'][$rank] = $mincredits;
}
} else {
$ec_creditnew['rank'] = $defaultrank;
}
$db->query("UPDATE {$tablepre}settings SET value='".serialize($ec_creditnew)."' WHERE variable='ec_credit'");
updatecache('settings');
cpmsg('ec_credit_succeed', $BASESCRIPT.'?action=ec&operation=credit', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/ec.inc.php
|
PHP
|
asf20
| 11,566
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: smilies.inc.php 17528 2009-01-14 02:04:19Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$imgextarray = array('jpg', 'gif');
if($operation == 'export' && $id) {
$smileyarray = $db->fetch_first("SELECT name, directory FROM {$tablepre}imagetypes WHERE typeid='$id' AND type='smiley'");
if(!$smileyarray) {
cpheader();
cpmsg('smilies_type_nonexistence', '', 'error');
}
$smileyarray['smilies'] = array();
$query = $db->query("SELECT typeid, displayorder, code, url FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
while($smiley = $db->fetch_array($query)) {
$smileyarray['smilies'][] = $smiley;
}
$smileyarray['version'] = strip_tags($version);
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
$smiley_export = "# Discuz! Smilies Dump\n".
"# Version: Discuz! $version\n".
"# Time: $time\n".
"# From: $bbname ($boardurl)\n".
"#\n".
"# This file was BASE64 encoded\n".
"#\n".
"# Discuz! Community: http://www.Discuz.net\n".
"# Please visit our website for latest news about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
wordwrap(base64_encode(serialize($smileyarray)), 50, "\n", 1);
ob_end_clean();
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
dheader('Cache-Control: no-cache, must-revalidate');
dheader('Pragma: no-cache');
dheader('Content-Encoding: none');
dheader('Content-Length: '.strlen($smiley_export));
dheader('Content-Disposition: attachment; filename=discuz_smilies_'.$smileyarray['name'].'.txt');
dheader('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
echo $smiley_export;
dexit();
}
cpheader();
if(!$operation) {
if(!submitcheck('smiliessubmit')) {
shownav('style', 'smilies_edit');
showsubmenu('nav_smilies', array(
array('smilies_type', 'smilies', 1),
array('smilies_import', 'smilies&operation=import', 0),
));
showtips('smilies_tips_smileytypes');
showformheader('smilies');
showtableheader();
showsubtitle(array('', 'display_order', 'enable', 'smilies_type', 'dir', 'smilies_nums', '', '', ''));
$smtypes = 0;
$dirfilter = array();
$query = $db->query("SELECT * FROM {$tablepre}imagetypes WHERE type='smiley' ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$squery = $db->query("SELECT COUNT(*) FROM {$tablepre}smilies WHERE typeid='$type[typeid]'");
$smiliesnum = $db->result($squery, 0);
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\" ".($smiliesnum ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\" size=\"2\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$type[typeid]]\" value=\"1\" ".($type['available'] ? 'checked' : '').">",
"<input type=\"text\" class=\"txt\" name=\"namenew[$type[typeid]]\" value=\"$type[name]\" size=\"15\">",
"./images/smilies/$type[directory]",
"$smiliesnum<input type=\"hidden\" name=\"smiliesnum[$type[typeid]]\" value=\"$smiliesnum\" />",
"<a href=\"$BASESCRIPT?action=smilies&operation=update&id=$type[typeid]\" class=\"act\" onclick=\"return confirm('$lang[smilies_update_confirm1]$type[directory]$lang[smilies_update_confirm2]$type[name]$lang[smilies_update_confirm3]')\">$lang[smilies_update]</a>",
"<a href=\"$BASESCRIPT?action=smilies&operation=export&id=$type[typeid]\" class=\"act\">$lang[export]</a>",
"<a href=\"$BASESCRIPT?action=smilies&operation=edit&id=$type[typeid]\" class=\"act\">$lang[detail]</a>"
));
$dirfilter[] = $type['directory'];
$smtypes++;
}
$smdir = DISCUZ_ROOT.'./images/smilies';
$smtypedir = dir($smdir);
$dirnum = 0;
while($entry = $smtypedir->read()) {
if($entry != '.' && $entry != '..' && !in_array($entry, $dirfilter) && preg_match("/^\w+$/", $entry) && strlen($entry) < 30 && is_dir($smdir.'/'.$entry)){
$smiliesdir = dir($smdir.'/'.$entry);
$smnums = 0;
$smilies = '';
while($subentry = $smiliesdir->read()) {
if(in_array(strtolower(fileext($subentry)), $imgextarray) && preg_match("/^[\w\-\.\[\]\(\)\<\> &]+$/", substr($subentry, 0, strrpos($subentry, '.'))) && strlen($subentry) < 30 && is_file($smdir.'/'.$entry.'/'.$subentry)) {
$smilies .= '<input type="hidden" name="smilies['.$dirnum.']['.$smnums.'][available]" value="1"><input type="hidden" name="smilies['.$dirnum.']['.$smnums.'][displayorder]" value="0"><input type="hidden" name="smilies['.$dirnum.']['.$smnums.'][url]" value="'.$subentry.'">';
$smnums++;
}
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
($dirnum ? ' ' : $lang['add_new']),
'<input type="text" class="txt" name="newdisplayorder['.$dirnum.']" value="'.($smtypes + $dirnum + 1).'" size="2" />',
'<input class="checkbox" type="checkbox" name="newavailable['.$dirnum.']" value="1"'.($smnums ? ' checked="checked"' : ' disabled="disabled"').' />',
'<input type="text" class="txt" name="newname['.$dirnum.']" value="" size="15" />',
'./images/smilies/'.$entry.'<input type="hidden" name="newdirectory['.$dirnum.']" value="'.$entry.'">',
"$smnums<input type=\"hidden\" name=\"smnums[$dirnum]\" value=\"$smnums\" />",
$smilies,
'',
''
));
$dirnum++;
}
}
if(!$dirnum) {
showtablerow('', array('', 'colspan="8"'), array(
lang('add_new'),
lang('smiliesupload_tips')
));
}
showsubmit('smiliessubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($namenew)) {
foreach($namenew as $id => $val) {
$availablenew[$id] = $availablenew[$id] && $smiliesnum[$id] > 0 ? 1 : 0;
$db->query("UPDATE {$tablepre}imagetypes SET available='$availablenew[$id]', name='".htmlspecialchars(trim($val))."', displayorder='$displayordernew[$id]' WHERE typeid='$id'");
}
}
if($ids = implodeids($delete)) {
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}smilies WHERE type='smiley' AND typeid IN ($ids)")) {
cpmsg('smilies_delete_invalid', '', 'error');
}
$db->query("DELETE FROM {$tablepre}imagetypes WHERE typeid IN ($ids)");
}
if(is_array($newname)) {
foreach($newname as $key => $val) {
$val = trim($val);
if($val) {
$smurl = './images/smilies/'.$newdiredctory[$key];
if(!is_dir(DISCUZ_ROOT.$smurl)) {
cpmsg('smilies_directory_invalid', '', 'error');
}
$newavailable[$key] = $newavailable[$key] && $smnums[$key] > 0 ? 1 : 0;
$db->query("INSERT INTO {$tablepre}imagetypes (available, name, type, displayorder, directory) VALUES ('$newavailable[$key]', '".htmlspecialchars($val)."', 'smiley', '$newdisplayorder[$key]', '$newdirectory[$key]')");
if($smilies[$key]) {
addsmilies($db->insert_id(), $smilies[$key]);
}
}
}
}
updatecache(array('smileytypes', 'smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_edit_succeed', $BASESCRIPT.'?action=smilies', 'succeed');
}
} elseif($operation == 'edit' && $id) {
$type = $db->fetch_first("SELECT typeid, name, directory FROM {$tablepre}imagetypes WHERE typeid='$id'AND type='smiley'");
$smurl = './images/smilies/'.$type['directory'];
$smdir = DISCUZ_ROOT.$smurl;
if(!is_dir($smdir)) {
cpmsg('smilies_directory_invalid', '', 'error');
}
if(!$do) {
if(!submitcheck('editsubmit')) {
$smiliesperpage = 100;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $smiliesperpage;
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
$multipage = multi($num, $smiliesperpage, $page, $BASESCRIPT.'?action=smilies&operation=edit&id='.$id);
$smileynum = 1;
$smilies = '';
$query = $db->query("SELECT * FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id' ORDER BY displayorder LIMIT $start_limit, $smiliesperpage");
while($smiley = $db->fetch_array($query)) {
$smilies .= showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"', 'class="td23"', 'class="td24"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$smiley[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$smiley[id]]\" value=\"$smiley[displayorder]\">",
"<img src=\"$smurl/$smiley[url]\" border=\"0\" onload=\"if(this.height>30) {this.resized=true; this.height=30;}\" onmouseover=\"if(this.resized) this.style.cursor='pointer';\" onclick=\"if(!this.resized) {return false;} else {window.open(this.src);}\">",
$smiley['id'],
"<input type=\"text\" class=\"txt\" size=\"25\" name=\"code[$smiley[id]]\" value=\"".dhtmlspecialchars($smiley['code'])."\" id=\"code_$smileynum\" smileyid=\"$smiley[id]\" />",
"<input type=\"hidden\" value=\"$smiley[url]\" id=\"url_$smileynum\">$smiley[url]"
), TRUE);
$imgfilter[] = $smiley[url];
$smileynum ++;
}
echo <<<EOT
<script type="text/JavaScript">
function addsmileycodes(smiliesnum, pre) {
smiliesnum = parseInt(smiliesnum);
if(smiliesnum > 1) {
for(var i = 1; i < smiliesnum; i++) {
var prefix = trim($(pre + 'prefix').value);
var suffix = trim($(pre + 'suffix').value);
var page = parseInt('$page');
var middle = $(pre + 'middle').value == 1 ? $(pre + 'url_' + i).value.substr(0,$(pre + 'url_' + i).value.lastIndexOf('.')) : ($(pre + 'middle').value == 2 ? i + page * 10 : $(pre + 'code_'+ i).attributes['smileyid'].nodeValue);
if(!prefix || prefix == '$lang[smilies_prefix]' || !suffix || suffix == '$lang[smilies_suffix]') {
alert('$lang[smilies_prefix_tips]');
return;
}
suffix = !suffix || suffix == '$lang[smilies_suffix]' ? '' : suffix;
$(pre + 'code_' + i).value = prefix + middle + suffix;
}
}
}
function autoaddsmileycodes(smiliesnum) {
smiliesnum = parseInt(smiliesnum);
if(smiliesnum > 1) {
for(var i = 1; i < smiliesnum; i++) {
$('code_' + i).value = '{:' + '$id' + '_' + $('code_'+ i).attributes['smileyid'].nodeValue + ':}';
}
}
}
function clearinput(obj, defaultval) {
if(obj.value == defaultval) {
obj.value = '';
}
}
</script>
EOT;
shownav('style', 'nav_smilies');
showsubmenu(lang('smilies_edit').' - '.$type[name], array(
array('admin', "smilies&operation=edit&id=$id", !$do),
array('add', "smilies&operation=edit&do=add&id=$id", $do == 'add')
));
showformheader("smilies&operation=edit&id=$id");
showtableheader('', 'nobottom');
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_id', 'smilies_edit_code', 'smilies_edit_filename'));
echo $smilies;
showtablerow('', array('', 'colspan="5"'), array(
'',
$lang['smilies_edit_add_code'].' <input type="text" class="txt" style="margin-right:0;width:40px;" size="2" value="{:" title="'.$lang['smilies_prefix'].'" id="prefix" onclick="clearinput(this, \''.$lang['smilies_prefix'].'\')" /> + <select id="middle"><option value="1">'.$lang['smilies_edit_order_file'].'</option><option value="2">'.$lang['smilies_edit_order_radom'].'</option><option value="3">'.$lang['smilies_id'].'</option></select> + <input type="text" class="txt" style="margin-right:0;width:40px;" size="2" value=":}" title="'.$lang['smilies_suffix'].'" id="suffix" onclick="clearinput(this, \''.$lang['smilies_suffix'].'\')" /> <input type="button" class="btn" onclick="addsmileycodes(\''.$smileynum.'\', \'\');" value="'.$lang['apply'].'" /> <input type="button" class="btn" onclick="autoaddsmileycodes(\''.$smileynum.'\');" value="'.$lang['smilies_edit_addcode_auto'].'" />'
));
showsubmit('editsubmit', 'submit', 'del', '<input type="button" class="btn" value="'.$lang['return'].'" onclick="window.location=\''.$BASESCRIPT.'?action=smilies\'">', $multipage);
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}smilies WHERE id IN ($ids)");
}
if(is_array($displayorder)) {
foreach($displayorder as $key => $val) {
$displayorder[$key] = intval($displayorder[$key]);
$code[$key] = trim($code[$key]);
$codeadd = !empty($code[$key]) ? ", code='$code[$key]'" : '';
$db->query("UPDATE {$tablepre}smilies SET displayorder='$displayorder[$key]' $codeadd WHERE id='$key'");
}
}
updatecache(array('smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_edit_succeed', "$BASESCRIPT?action=smilies&operation=edit&id=$id", 'succeed');
}
} elseif($do == 'add') {
if(!submitcheck('editsubmit')) {
shownav('style', 'nav_smilies');
showsubmenu(lang('smilies_edit').' - '.$type[name], array(
array('admin', "smilies&operation=edit&id=$id", !$do),
array('add', "smilies&operation=edit&do=add&id=$id", $do == 'add')
));
showtips('smilies_tips');
showtagheader('div', 'addsmilies', TRUE);
showtableheader('smilies_add', 'notop fixpadding');
showtablerow('', '', "<span class=\"bold marginright\">$lang[smilies_type]:</span>$type[name]");
showtablerow('', '', "<span class=\"bold marginright\">$lang[dir]:</span>$smurl $lang[smilies_add_search]");
showtablerow('', '', '<input type="button" class="btn" value="'.$lang['search'].'" onclick="ajaxget(\''.$BASESCRIPT.'?action=smilies&operation=edit&do=add&id='.$id.'&search=yes\', \'addsmilies\', \'addsmilies\', \'auto\');doane(event);">');
showtablefooter();
showtagfooter('div');
if($search) {
$newid = 1;
$newimages = '';
$imgfilter = array();
$query = $db->query("SELECT url FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
while($img = $db->fetch_array($query)) {
$imgfilter[] = $img[url];
}
$smiliesdir = dir($smdir);
while($entry = $smiliesdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && !in_array($entry, $imgfilter) && preg_match("/^[\w\-\.\[\]\(\)\<\> &]+$/", substr($entry, 0, strrpos($entry, '.'))) && strlen($entry) < 30 && is_file($smdir.'/'.$entry)) {
$newimages .= showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"smilies[$newid][available]\" value=\"1\" checked=\"checked\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"smilies[$newid][displayorder]\" value=\"0\">",
"<img src=\"$smurl/$entry\" border=\"0\" onload=\"if(this.height>30) {this.resized=true; this.height=30;}\" onmouseover=\"if(this.resized) this.style.cursor='pointer';\" onclick=\"if(!this.resized) {return false;} else {window.open(this.src);}\">",
"<input type=\"hidden\" size=\"25\" name=\"smilies[$newid][url]\" value=\"$entry\" id=\"addurl_$newid\">$entry"
), TRUE);
$newid ++;
}
}
$smiliesdir->close();
ajaxshowheader();
if($newimages) {
showformheader("smilies&operation=edit&do=add&id=$id");
showtableheader('smilies_add', 'notop fixpadding');
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_edit_filename'));
echo $newimages;
showtablerow('', array('class="td25"', 'colspan="3"'), array(
'<input type="checkbox" name="chkall" onclick="checkAll(\'prefix\', this.form, \'add\')" class="checkbox" checked="checked">'.$lang['enable'],
'<input type="submit" class="btn" name="editsubmit" value="'.$lang['submit'].'"> <input type="button" class="btn" value="'.$lang['research'].'" onclick="ajaxget(\''.$BASESCRIPT.'?action=smilies&operation=edit&do=add&id='.$id.'&search=yes\', \'addsmilies\', \'addsmilies\', \'auto\');doane(event);">'
));
showtablefooter();
showformfooter();
} else {
eval("\$lang[smilies_edit_add_tips] = \"".$lang['smilies_edit_add_tips']."\";");
showtableheader('smilies_add', 'notop');
showtablerow('', 'class="lineheight"', $lang['smilies_edit_add_tips']);
showtablerow('', '', '<input type="button" class="btn" value="'.$lang['research'].'" onclick="ajaxget(\''.$BASESCRIPT.'?action=smilies&operation=edit&do=add&id='.$id.'&search=yes\', \'addsmilies\', \'addsmilies\', \'auto\');doane(event);">');
showtablefooter();
}
ajaxshowfooter();
exit;
}
} else {
if(is_array($smilies)) {
addsmilies($id, $smilies);
}
updatecache(array('smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_edit_succeed', "$BASESCRIPT?action=smilies&operation=edit&id=$id", 'succeed');
}
}
} elseif($operation == 'update' && $id) {
if(!$smtype = $db->fetch_first("SELECT name, directory FROM {$tablepre}imagetypes WHERE typeid='$id' AND type='smiley'")) {
cpmsg('smilies_type_nonexistence', '', 'error');
} else {
$smurl = './images/smilies/'.$smtype['directory'];
$smdir = DISCUZ_ROOT.$smurl;
if(!is_dir($smdir)) {
cpmsg('smilies_directory_invalid', '', 'error');
}
}
$num = 0;
$smilies = $imgfilter = array();
$query = $db->query("SELECT url FROM {$tablepre}smilies WHERE type='smiley' AND typeid='$id'");
while($img = $db->fetch_array($query)) {
$imgfilter[] = $img[url];
}
$smiliesdir = dir($smdir);
while($entry = $smiliesdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && !in_array($entry, $imgfilter) && preg_match("/^[\w\-\.\[\]\(\)\<\> &]+$/", substr($entry, 0, strrpos($entry, '.'))) && strlen($entry) < 30 && is_file($smdir.'/'.$entry)) {
$smilies[] = array('available' => 1, 'displayorder' => 0, 'url' => $entry);
$num++;
}
}
$smiliesdir->close();
if($smilies) {
addsmilies($id, $smilies);
updatecache(array('smilies', 'smileycodes', 'smilies_js'));
cpmsg('smilies_update_succeed', "$BASESCRIPT?action=smilies", 'succeed');
} else {
cpmsg('smilies_update_error', '', 'error');
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit')) {
shownav('style', 'smilies_edit');
showsubmenu('nav_smilies', array(
array('smilies_type', 'smilies', 0),
array('smilies_import', 'smilies&operation=import', 1),
));
showtips('smilies_tips_import');
showformheader('smilies&operation=import', 'enctype');
showtableheader('smilies_import');
showimportdata();
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
$smileyarray = getimportdata();
$renamed = 0;
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}imagetypes WHERE type='smiley' AND name='$smileyarray[name]'")) {
$smileyarray['name'] .= '_'.random(4);
$renamed = 1;
}
$db->query("INSERT INTO {$tablepre}imagetypes (name, type, directory)
VALUES ('$smileyarray[name]', 'smiley', '$smileyarray[directory]')");
$typeid = $db->insert_id();
foreach($smileyarray['smilies'] as $key => $smiley) {
$db->query("INSERT INTO {$tablepre}smilies (type, typeid, displayorder, code, url)
VALUES ('smiley', '$typeid', '$smiley[displayorder]', '', '$smiley[url]')");
}
$db->query("UPDATE {$tablepre}smilies SET code=CONCAT('{:', typeid, '_', id, ':}') WHERE typeid='$typeid'");
updatecache(array('smileytypes', 'smilies', 'smileycodes', 'smilies_js'));
cpmsg($renamed ? 'smilies_import_succeed_renamed' : 'smilies_import_succeed', $BASESCRIPT.'?action=smilies', 'succeed');
}
}
function addsmilies($typeid, $smilies = array()) {
global $db, $tablepre;
if(is_array($smilies)) {
$ids = array();
foreach($smilies as $smiley) {
if($smiley['available']) {
$db->query("INSERT INTO {$tablepre}smilies (type, displayorder, typeid, code, url)
VALUES ('smiley', '$smiley[displayorder]', '$typeid', '', '$smiley[url]')");
$ids[] = $db->insert_id();
}
}
if($ids = implodeids($ids)) {
$db->query("UPDATE {$tablepre}smilies SET code=CONCAT('{:', typeid, '_', id, ':}') WHERE id IN ($ids)");
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/smilies.inc.php
|
PHP
|
asf20
| 20,456
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: announce.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
if(empty($operation)) {
if(!submitcheck('announcesubmit')) {
shownav('tools', 'announce', 'admin');
showsubmenu('announce', array(
array('admin', 'announce', 1),
array('add', 'announce&operation=add', 0)
));
showtips('announce_tips');
showformheader('announce');
showtableheader();
showsubtitle(array('', 'display_order', 'author', 'subject', 'message', 'announce_type', 'start_time', 'end_time', ''));
$announce_type = array(0=>$lang['announce_words'], 1=>$lang['announce_url']);
$query = $db->query("SELECT * FROM {$tablepre}announcements ORDER BY displayorder, starttime DESC, id DESC");
while($announce = $db->fetch_array($query)) {
$disabled = $adminid != 1 && $announce['author'] != $discuz_userss ? 'disabled' : NULL;
$announce['starttime'] = $announce['starttime'] ? gmdate($dateformat, $announce['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'];
$announce['endtime'] = $announce['endtime'] ? gmdate($dateformat, $announce['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'];
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$announce[id]\" $disabled>",
"<input type=\"text\" class=\"txt\" name=\"displayordernew[{$announce[id]}]\" value=\"$announce[displayorder]\" size=\"2\" $disabled>",
"<a href=\"./space.php?username=".rawurlencode($announce['author'])."\" target=\"_blank\">$announce[author]</a>",
dhtmlspecialchars($announce['subject']),
cutstr(strip_tags($announce['message']), 20),
$announce_type[$announce['type']],
$announce['starttime'],
$announce['endtime'],
"<a href=\"$BASESCRIPT?action=announce&operation=edit&announceid=$announce[id]\" $disabled>$lang[edit]</a>"
));
}
showsubmit('announcesubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}announcements WHERE id IN ($ids) AND ('$adminid'='1' OR author='$discuz_user')");
}
if(is_array($displayordernew)) {
foreach($displayordernew as $id => $displayorder) {
$db->query("UPDATE {$tablepre}announcements SET displayorder='$displayorder' WHERE id='$id' AND ('$adminid'='1' OR author='$discuz_user')");
}
}
updatecache(array('pmlist', 'announcements', 'announcements_forum'));
cpmsg('announce_update_succeed', $BASESCRIPT.'?action=announce', 'succeed');
}
} elseif($operation == 'add') {
if(!submitcheck('addsubmit')) {
$newstarttime = gmdate('Y-n-j', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$newendtime = gmdate('Y-n-j', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600 + 86400* 7);
shownav('tools', 'announce', 'add');
showsubmenu('announce', array(
array('admin', 'announce', 0),
array('add', 'announce&operation=add', 1)
));
showformheader('announce&operation=add');
showtableheader('announce_add');
showsetting($lang[subject], 'newsubject', '', 'text');
showsetting($lang['start_time'], 'newstarttime', $newstarttime, 'calendar');
showsetting($lang['end_time'], 'newendtime', $newendtime, 'calendar');
showsetting('announce_type', array('newtype', array(
array(0, $lang['announce_words']),
array(1, $lang['announce_url']))), 0, 'mradio');
showsetting('announce_message', 'newmessage', '', 'textarea');
showsubmit('addsubmit');
showtablefooter();
showformfooter();
} else {
$newstarttime = $newstarttime ? strtotime($newstarttime) : 0;
$newendtime = $newendtime ? strtotime($newendtime) : 0;
if(!$newstarttime) {
cpmsg('announce_time_invalid', '', 'error');
} elseif(!($newsubject = trim($newsubject)) || !($newmessage = trim($newmessage))) {
cpmsg('announce_invalid', '', 'error');
} else {
$newmessage = $newtype == 1 ? explode("\n", $newmessage) : array(0 => $newmessage);
$db->query("INSERT INTO {$tablepre}announcements (author, subject, type, starttime, endtime, message)
VALUES ('$discuz_user', '$newsubject', '$newtype', '$newstarttime', '$newendtime', '{$newmessage[0]}')");
updatecache(array('announcements', 'announcements_forum', 'pmlist'));
cpmsg('announce_succeed', $BASESCRIPT.'?action=announce', 'succeed');
}
}
} elseif($operation == 'edit' && $announceid) {
$announce = $db->fetch_first("SELECT * FROM {$tablepre}announcements WHERE id='$announceid' AND ('$adminid'='1' OR author='$discuz_user')");
if(!$announce) {
cpmsg('announce_nonexistence', '', 'error');
}
if(!submitcheck('editsubmit')) {
$announce['starttime'] = $announce['starttime'] ? gmdate('Y-n-j', $announce['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : "";
$announce['endtime'] = $announce['endtime'] ? gmdate('Y-n-j', $announce['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : "";
shownav('tools', 'announce');
showsubmenu('announce', array(
array('admin', 'announce', 0),
array('add', 'announce&operation=add', 0)
));
showformheader("announce&operation=edit&announceid=$announceid");
showtableheader();
showtitle('announce_edit');
showsetting('subject', 'subjectnew', $announce['subject'], 'text');
showsetting('start_time', 'starttimenew', $announce['starttime'], 'calendar');
showsetting('end_time', 'endtimenew', $announce['endtime'], 'calendar');
showsetting('announce_type', array('typenew', array(
array(0, $lang['announce_words']),
array(1, $lang['announce_url'])
)), $announce['type'], 'mradio');
showsetting('announce_message', 'messagenew', $announce['message'], 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
if(strpos($starttimenew, '-')) {
$time = explode('-', $starttimenew);
$starttimenew = gmmktime(0, 0, 0, $time[1], $time[2], $time[0]) - $_DCACHE['settings']['timeoffset'] * 3600;
} else {
$starttimenew = 0;
}
if(strpos($endtimenew, '-')) {
$time = explode('-', $endtimenew);
$endtimenew = gmmktime(0, 0, 0, $time[1], $time[2], $time[0]) - $_DCACHE['settings']['timeoffset'] * 3600;
} else {
$endtimenew = 0;
}
if(!$starttimenew || ($endtimenew && $endtimenew <= $timestamp)) {
cpmsg('announce_time_invalid', '', 'error');
} elseif(!($subjectnew = trim($subjectnew)) || !($messagenew = trim($messagenew))) {
cpmsg('announce_invalid', '', 'error');
} else {
$messagenew = $typenew == 1 ? explode("\n", $messagenew) : array(0 => $messagenew);
$db->query("UPDATE {$tablepre}announcements SET subject='$subjectnew', type='$typenew', starttime='$starttimenew', endtime='$endtimenew', message='{$messagenew[0]}' WHERE id='$announceid' AND ('$adminid'='1' OR author='$discuz_user')");
updatecache('announcements', 'announcements_forum', 'pmlist');
cpmsg('announce_succeed', $BASESCRIPT.'?action=announce', 'succeed');
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/announce.inc.php
|
PHP
|
asf20
| 7,463
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tools.inc.php 17386 2008-12-17 05:10:00Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if($operation == 'updatecache') {
$step = max(1, intval($step));
shownav('tools', 'nav_updatecache');
showsubmenusteps('nav_updatecache', array(
array('nav_updatecache_confirm', $step == 1),
array('nav_updatecache_verify', $step == 2),
array('nav_updatecache_completed', $step == 3)
));
showtips('tools_updatecache_tips');
if($step == 1) {
cpmsg('<input type=\"checkbox\" name=\"type[]\" value=\"data\" id=\"datacache\" class=\"checkbox\" checked /><label for=\"datacache\">'.$lang[tools_updatecache_data].'</label><input type=\"checkbox\" name=\"type[]\" value=\"tpl\" id=\"tplcache\" class=\"checkbox\" checked /><label for=\"tplcache\">'.$lang[tools_updatecache_tpl].'</label>', $BASESCRIPT.'?action=tools&operation=updatecache&step=2', 'form', '', FALSE);
} elseif($step == 2) {
$type = implode('_', (array)$type);
cpmsg(lang('tools_updatecache_waiting'), "$BASESCRIPT?action=tools&operation=updatecache&step=3&type=$type", 'loading', '', FALSE);
} elseif($step == 3) {
$type = explode('_', $type);
if(in_array('data', $type)) {
updatecache();
}
if(in_array('tpl', $type) && $tplrefresh) {
$tpl = dir(DISCUZ_ROOT.'./forumdata/templates');
while($entry = $tpl->read()) {
if(preg_match("/\.tpl\.php$/", $entry)) {
@unlink(DISCUZ_ROOT.'./forumdata/templates/'.$entry);
}
}
$tpl->close();
}
cpmsg('update_cache_succeed', '', 'succeed', '', FALSE);
}
} elseif($operation == 'tag') {
include_once DISCUZ_ROOT.'./uc_client/client.php';
$applist = uc_app_ls();
if(!submitcheck('submit')) {
$query = $db->query("SELECT variable, value FROM {$tablepre}settings WHERE variable IN ('relatedtag', 'relatedtagstatus')");
$settings = array();
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
$relatedtag = unserialize($settings['relatedtag']);
shownav('tools', 'extended_tag');
showsubmenu('extended_tag');
showformheader('tools&operation=tag');
if(!$tagstatus) {
showtips('extended_tag_tips');
}
showtableheader();
showsetting('extended_tag_on', 'relatedtagstatusnew', $settings['relatedtagstatus'], 'radio');
jsinsertunit();
foreach($applist as $data) {
$appid = $data['appid'];
$status = array(intval($relatedtag['status'][$appid]) => 'checked="checked"');
$template = stripslashes(htmlspecialchars($relatedtag['template'][$appid]['template'] != '' ? $relatedtag['template'][$appid]['template'] : '<a href="{url}" target="_blank">{subject}</a>'));
$name = $relatedtag['name'][$appid] != '' ? $relatedtag['name'][$appid] : $data['name'];
showtitle($data['name']);
showsetting('extended_tag_name', 'relatedtagnew[name]['.$appid.']', $name, 'text');
showsetting('extended_tag_status', 'relatedtagnew[status]['.$appid.']', $status[0] ? 0 : 1, 'radio');
showsetting('extended_tag_order', 'relatedtagnew[order]['.$appid.']', $relatedtag['order'][$appid], 'text');
showsetting('extended_tag_items', 'relatedtagnew[limit]['.$appid.']', intval($relatedtag['limit'][$appid]), 'text');
echo '<tr><td class="td27" colspan="2">'.$lang['extended_tag_tpl'].'</td></tr><tr><td class="vtop rowform">'.
'<textarea cols="100" rows="8" id="jstemplate_'.$appid.'" name="relatedtagnew[template]['.$appid.'][template]" class="tarea">'.$template.'</textarea>'.
'<input type="hidden" name="relatedtagnew[template]['.$appid.'][name]" value="'.$data['name'].'" /></td><td class="vtop"><div class="extcredits">';
if(is_array($data['tagtemplates']['fields'])) {
foreach($data['tagtemplates']['fields'] as $field => $memo) {
echo '<a onclick="insertunit(\'{'.$field.'}\', \'jstemplate_'.$appid.'\')" href="###">{'.$field.'}</a> '.$lang['extended_tag_memo'].' '.$memo.'<br />';
}
}
echo '</td></tr>';
showhiddenfields(array('relatedtagnew[template]['.$appid.'][name]' => $data['name']));
}
showsubmit('submit');
showtablefooter();
showformfooter();
} else {
$value = addslashes(serialize($relatedtagnew));
$relatedtagstatusnew = intval($relatedtagstatusnew);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('relatedtag', '$value'),('relatedtagstatus', '$relatedtagstatusnew')");
updatecache('settings');
cpmsg('jswizard_relatedtag_succeed', $BASESCRIPT.'?action=tools&operation=tag', 'succeed');
}
} elseif($operation == 'fileperms') {
$step = max(1, intval($step));
shownav('tools', 'nav_fileperms');
showsubmenusteps('nav_fileperms', array(
array('nav_fileperms_confirm', $step == 1),
array('nav_fileperms_verify', $step == 2),
array('nav_fileperms_completed', $step == 3)
));
if($step == 1) {
cpmsg(lang('fileperms_check_note'), $BASESCRIPT.'?action=tools&operation=fileperms&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(lang('fileperms_check_waiting'), $BASESCRIPT.'?action=tools&operation=fileperms&step=3', 'loading', '', FALSE);
} elseif($step == 3) {
showtips('fileperms_tips');
$entryarray = array(
'attachments',
'forumdata',
'forumdata/cache',
'forumdata/logs',
'forumdata/templates',
'forumdata/threadcaches'
);
foreach(array('templates', 'forumdata/cache', 'forumdata/logs', 'forumdata/templates') as $directory) {
getdirentry($directory);
}
$result = '';
foreach($entryarray as $entry) {
$fullentry = DISCUZ_ROOT.'./'.$entry;
if(!is_dir($fullentry) && !file_exists($fullentry)) {
continue;
} else {
if(!is_writeable($fullentry)) {
$result .= '<li class="error">'.(is_dir($fullentry) ? $lang['dir'] : $lang['file'])." ./$entry $lang[fileperms_unwritable]</li>";
}
}
}
$result = $result ? $result : '<li>'.$lang['fileperms_check_ok'].'</li>';
echo '<div class="colorbox"><ul class="fileperms">'.$result.'</ul></div>';
}
}
function getdirentry($directory) {
global $entryarray;
$dir = dir(DISCUZ_ROOT.'./'.$directory);
while($entry = $dir->read()) {
if(!in_array($entry, array('.', '..', 'index.htm'))) {
if(is_dir(DISCUZ_ROOT.'./'.$directory.'/'.$entry)) {
getdirentry($directory."/".$entry);
}
$entryarray[] = $directory.'/'.$entry;
}
}
$dir->close();
}
function jsinsertunit() {
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, obj) {
if(!obj) {
obj = 'jstemplate';
}
$(obj).focus();
if(!isUndefined($(obj).selectionStart)) {
var opn = $(obj).selectionStart + 0;
$(obj).value = $(obj).value.substr(0, $(obj).selectionStart) + text + $(obj).value.substr($(obj).selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$(obj).value += text;
}
}
</script>
<?
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/tools.inc.php
|
PHP
|
asf20
| 7,312
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: members.inc.php 17499 2009-01-04 06:26:22Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
@set_time_limit(600);
cpheader();
if(!$operation) {
if(!submitcheck('submit', 1)) {
shownav('user', 'nav_members');
showsubmenu('nav_members', array(
array('search', 'members', 1),
array('clean', 'members&operation=clean', 0),
));
showtips('members_admin_tips');
searchmembers();
} else {
countmembers();
$multipage = multi($membernum, $memberperpage, $page, "$BASESCRIPT?action=members&submit=yes".$urladd);
$usergroups = array();
$query = $db->query("SELECT groupid, type, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
switch($group['type']) {
case 'system': $group['grouptitle'] = '<b>'.$group['grouptitle'].'</b>'; break;
case 'special': $group['grouptitle'] = '<i>'.$group['grouptitle'].'</i>'; break;
}
$usergroups[$group['groupid']] = $group;
}
$query = $db->query("SELECT uid, username, adminid, groupid, credits, extcredits1, extcredits2,
extcredits3, extcredits4, extcredits5, extcredits6, extcredits7, extcredits8, posts FROM {$tablepre}members WHERE $conditions LIMIT $start_limit, $memberperpage");
while($member = $db->fetch_array($query)) {
$memberextcredits = array();
foreach($extcredits as $id => $credit) {
$memberextcredits[] = $extcredits[$id]['title'].': '.$member['extcredits'.$id];
}
$members .= showtablerow('', array('class="td25"', '', 'title="'.implode("\n", $memberextcredits).'"'), array(
"<input type=\"checkbox\" name=\"uidarray[]\" value=\"$member[uid]\"".($member['adminid'] == 1 ? 'disabled' : '')." class=\"checkbox\">",
"<a href=\"space.php?uid=$member[uid]\" target=\"_blank\">$member[username]</a>",
$member['credits'],
$member['posts'],
$usergroups[$member['adminid']]['grouptitle'],
$usergroups[$member['groupid']]['grouptitle'],
"<a href=\"$BASESCRIPT?action=members&operation=group&uid=$member[uid]\" class=\"act\">$lang[usergroup]</a><a href=\"$BASESCRIPT?action=members&operation=access&uid=$member[uid]\" class=\"act\">$lang[members_access]</a>".
($extcredits ? "<a href=\"$BASESCRIPT?action=members&operation=credit&uid=$member[uid]\" class=\"act\">$lang[credits]</a>" : "<span disabled>$lang[edit]</span>").
"<a href=\"$BASESCRIPT?action=members&operation=medal&uid=$member[uid]\" class=\"act\">$lang[medals]</a><a href=\"$BASESCRIPT?action=members&operation=edit&uid=$member[uid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
shownav('user', 'nav_members');
showsubmenu('nav_members');
showformheader("members&operation=clean");
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtableheader(lang('members_search_result').'<a href="javascript:history.go(-1);" class="act lightlink normal">'.lang('research').'</a>');
showsubtitle(array('', 'username', 'credits', 'posts', 'admingroup', 'usergroup', ''));
echo $members;
showtablerow('', array('class="td25"', 'class="lineheight" colspan="7"'), array('', lang('members_admin_comment')));
showsubmit('submit', 'submit', '<input type="checkbox" name="chkall" onclick="checkAll(\'prefix\', this.form, \'uidarray\')" class="checkbox">'.lang('del'), '', $multipage);
showtablefooter();
showformfooter();
}
} elseif($operation == 'clean') {
if(!submitcheck('submit', 1)) {
shownav('user', 'nav_members');
showsubmenu('nav_members', array(
array('search', 'members', 0),
array('clean', 'members&operation=clean', 1),
));
searchmembers('clean');
} else {
countmembers();
$uids = 0;
$extra = '';
if(empty($uidarray)) {
$query = $db->query("SELECT uid, groupid, adminid FROM {$tablepre}members WHERE $conditions AND adminid<>1 AND groupid<>1");
} else {
$uids = is_array($uidarray) ? '\''.implode('\', \'', $uidarray).'\'' : '0';
$query = $db->query("SELECT uid, groupid, adminid FROM {$tablepre}members WHERE uid IN($uids) AND adminid<>1 AND groupid<>1");
}
$membernum = $db->num_rows($query);
$uids = $comma = '';
while($member = $db->fetch_array($query)) {
if($membernum < 2000 || !empty($uidarray)) {
$extra .= '<input type="hidden" name="uidarray[]" value="'.$member['uid'].'" />';
}
$uids .= $comma.$member['uid'];
$comma = ',';
}
if((empty($membernum) || empty($uids))) {
cpmsg('members_no_find_deluser', '', 'error');
}
if(!$confirmed) {
cpmsg('members_delete_confirm', "$BASESCRIPT?action=members&operation=clean&submit=yes&confirmed=yes".$urladd, 'form', $extra.'<br /><input type="checkbox" name="includepost" value="1" class="checkbox" />'.$lang['members_delete_post'].($isfounder ? ' <input type="checkbox" name="includeuc" value="1" class="checkbox" />'.$lang['members_delete_ucdata'] : ''));
} else {
if($isfounder && !empty($includeuc)) {
require_once DISCUZ_ROOT.'./uc_client/client.php';
uc_user_delete($uidarray);
}
if(empty($includepost)) {
$query = $db->query("DELETE FROM {$tablepre}members WHERE uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}access WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}favorites WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}moderators WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}subscriptions WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)", 'UNBUFFERED');
cpmsg('members_delete_succeed', '', 'succeed');
} else {
$numdeleted = $numdeleted ? $numdeleted : count($uidarray);
$pertask = 1000;
$current = intval($current);
$next = $current + $pertask;
$threads = $fids = $threadsarray = array();
$query = $db->query("SELECT f.fid, t.tid FROM {$tablepre}threads t LEFT JOIN {$tablepre}forums f ON t.fid=f.fid WHERE t.authorid IN ($uids) ORDER BY f.fid LIMIT $pertask");
while($thread = $db->fetch_array($query)) {
$threads[$thread['fid']] .= ($threads[$thread['fid']] ? ',' : '').$thread['tid'];
}
$nextlink = "$BASESCRIPT?action=members&operation=clean&confirmed=yes&submit=yes&includepost=yes¤t=$next&pertask=$pertask&lastprocess=$processed".$urladd;
if($threads) {
foreach($threads as $fid => $tids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'debateposts', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions', 'typeoptionvars', 'forumrecommend') as $value) {
$db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED');
}
require_once DISCUZ_ROOT.'./include/post.func.php';
updateforumcount($fid);
}
if($globalstick && $stickmodify) {
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('globalstick');
}
cpmsg(lang('members_delete_post').': '.lang('members_delete_processing'), $nextlink, 'loadingform', $extra);
} elseif($uids) {
$query = $db->query("DELETE FROM {$tablepre}members WHERE uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}access WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}favorites WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}moderators WHERE uid IN ($uids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}subscriptions WHERE uid IN ($uids)", 'UNBUFFERED');
$query = $db->query("SELECT uid, attachment, thumb, remote FROM {$tablepre}attachments WHERE uid IN ($uids) LIMIT $pertask");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}posts WHERE authorid IN ($uids)");
$db->query("DELETE FROM {$tablepre}trades WHERE sellerid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)");
cpmsg('members_delete_succeed', '', 'succeed');
} else {
cpmsg('members_no_find_deluser', '', 'error');
}
}
}
}
} elseif($operation == 'newsletter') {
if(!submitcheck('newslettersubmit', 1)) {
shownav('user', 'nav_members_newsletter');
showsubmenusteps('nav_members_newsletter', array(
array('nav_members_select', !$submit),
array('nav_members_notify', $submit),
));
searchmembers('newsletter');
if(submitcheck('submit', 1)) {
countmembers();
showtagheader('div', 'newsletter', TRUE);
showformheader('members&operation=newsletter'.$urladd);
echo '<table class="tb tb1">';
if(!$membernum) {
showtablerow('', 'class="lineheight"', $lang['members_search_nonexistence']);
} else {
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtablerow('class="first"', array('class="th11"'), array(
lang('members_newsletter_members'),
"$lang[members_search_result] <a href=\"###\" onclick=\"$('searchmembers').style.display='';$('newsletter').style.display='none';$('step1').className='current';$('step2').className='';\" class=\"act\">$lang[research]</a>"
));
showtagheader('tbody', 'messagebody', TRUE);
shownewsletter();
showtagfooter('tbody');
showsubmit('newslettersubmit', 'submit', 'td');
}
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
countmembers();
notifymembers('newsletter', 'newsletter');
}
} elseif($operation == 'reward') {
if(!submitcheck('rewardsubmit', 1)) {
shownav('user', 'nav_members_reward');
showsubmenusteps('nav_members_reward', array(
array('nav_members_select', !$submit),
array('nav_members_reward', $submit),
));
searchmembers('reward');
if(submitcheck('submit', 1)) {
countmembers();
showtagheader('div', 'reward', TRUE);
showformheader('members&operation=reward'.$urladd);
echo '<table class="tb tb1">';
if(!$membernum) {
showtablerow('', 'class="lineheight"', $lang['members_search_nonexistence']);
showtablefooter();
} else {
$creditscols = array('credits_title');
$creditsvalue = $resetcredits = array();
$js_extcreditids = '';
for($i=1; $i<=8; $i++) {
$js_extcreditids .= (isset($extcredits[$i]) ? ($js_extcreditids ? ',' : '').$i : '');
$creditscols[] = isset($extcredits[$i]) ? $extcredits[$i]['title'] : 'extcredits'.$i;
$creditsvalue[] = isset($extcredits[$i]) ? '<input type="text" class="txt" size="3" id="addextcredits['.$i.']" name="addextcredits['.$i.']" value="0"> '.$extcredits['$i']['unit'] : '<input type="text" class="txt" size="3" value="N/A" disabled>';
$resetcredits[] = isset($extcredits[$i]) ? '<input type="checkbox" id="resetextcredits['.$i.']" name="resetextcredits['.$i.']" value="1" class="radio" disabled> '.$extcredits['$i']['unit'] : '<input type="checkbox" disabled class="radio">';
}
$creditsvalue = array_merge(array('<input type="radio" name="updatecredittype" id="updatecredittype0" value="0" class="radio" onclick="var extcredits = new Array('.$js_extcreditids.'); for(k in extcredits) {$(\'resetextcredits[\'+extcredits[k]+\']\').disabled = true; $(\'addextcredits[\'+extcredits[k]+\']\').disabled = false;}" checked="checked" /><label for="updatecredittype0">'.$lang['members_reward_value'].'</label>'), $creditsvalue);
$resetcredits = array_merge(array('<input type="radio" name="updatecredittype" id="updatecredittype1" value="1" class="radio" onclick="var extcredits = new Array('.$js_extcreditids.'); for(k in extcredits) {$(\'addextcredits[\'+extcredits[k]+\']\').disabled = true; $(\'resetextcredits[\'+extcredits[k]+\']\').disabled = false;}" /><label for="updatecredittype1">'.$lang['members_reward_clean'].'</label>'), $resetcredits);
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtablerow('class="first"', array('class="th11"'), array(
lang('members_reward_members'),
"$lang[members_search_result] <a href=\"###\" onclick=\"$('searchmembers').style.display='';$('reward').style.display='none';$('step1').className='current';$('step2').className='';\" class=\"act\">$lang[research]</a>"
));
echo '<tr><td class="th12">'.lang('nav_members_reward').'</td><td>';
showtableheader('', 'noborder');
showsubtitle($creditscols);
showtablerow('', array('class="td23"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), $creditsvalue);
showtablerow('', array('class="td23"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), $resetcredits);
showtablefooter();
echo '</td></tr>';
showtagheader('tbody', 'messagebody');
shownewsletter();
showtagfooter('tbody');
showsubmit('rewardsubmit', 'submit', 'td', '<input class="checkbox" type="checkbox" name="notifymembers" value="1" onclick="$(\'messagebody\').style.display = this.checked ? \'\' : \'none\'" id="credits_notify" /><label for="credits_notify">'.lang('members_reward_notify').'</label>');
}
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
countmembers();
notifymembers('reward', 'creditsnotify');
}
} elseif($operation == 'confermedal') {
$medals = '';
$query = $db->query("SELECT * FROM {$tablepre}medals WHERE available='1'");
while($medal = $db->fetch_array($query)) {
$medals .= showtablerow('', array('class="td25"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"medals[$medal[medalid]]\" value=\"1\" />",
"<img src=\"images/common/$medal[image]\" />",
$medal['name']
), TRUE);
}
if(!$medals) {
cpmsg('members_edit_medals_nonexistence', $BASESCRIPT.'?action=medals', 'error');
}
if(!submitcheck('confermedalsubmit', 1)) {
shownav('user', 'nav_members_confermedal');
showsubmenusteps('nav_members_confermedal', array(
array('nav_members_select', !$submit),
array('nav_members_confermedal', $submit),
));
searchmembers('confermedal');
if(submitcheck('submit', 1)) {
countmembers();
showtagheader('div', 'confermedal', TRUE);
showformheader('members&operation=confermedal'.$urladd);
echo '<table class="tb tb1">';
if(!$membernum) {
showtablerow('', 'class="lineheight"', $lang['members_search_nonexistence']);
showtablefooter();
} else {
eval("\$lang[members_search_result] = \"".$lang['members_search_result']."\";");
showtablerow('class="first"', array('class="th11"'), array(
lang('members_confermedal_members'),
"$lang[members_search_result] <a href=\"###\" onclick=\"$('searchmembers').style.display='';$('confermedal').style.display='none';$('step1').className='current';$('step2').className='';\" class=\"act\">$lang[research]</a>"
));
echo '<tr><td class="th12">'.lang('members_confermedal').'</td><td>';
showtableheader('', 'noborder');
showsubtitle(array('medals_grant', 'medals_image', 'name'));
echo $medals;
showtablefooter();
echo '</td></tr>';
showtagheader('tbody', 'messagebody');
shownewsletter();
showtagfooter('tbody');
showsubmit('confermedalsubmit', 'submit', 'td', '<input class="checkbox" type="checkbox" name="notifymembers" value="1" onclick="$(\'messagebody\').style.display = this.checked ? \'\' : \'none\'" id="grant_notify"/><label for="grant_notify">'.lang('medals_grant_notify').'</label>');
}
showtablefooter();
showformfooter();
showtagfooter('div');
}
} else {
countmembers();
notifymembers('confermedal', 'medalletter');
}
} elseif($operation == 'add') {
if(!submitcheck('addsubmit')) {
$groupselect = '';
$query = $db->query("SELECT groupid, type, grouptitle, creditshigher FROM {$tablepre}usergroups WHERE type='member' AND creditshigher='0' OR (groupid NOT IN ('5', '6', '7') AND radminid<>'1' AND type<>'member') ORDER BY type DESC, (creditshigher<>'0' || creditslower<>'0'), creditslower");
while($group = $db->fetch_array($query)) {
if($group['type'] == 'member' && $group['creditshigher'] == 0) {
$groupselect .= "<option value=\"$group[groupid]\" selected>$group[grouptitle]</option>\n";
} else {
$groupselect .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
}
}
shownav('user', 'nav_members_add');
showsubmenu('members_add');
showformheader('members&operation=add');
showtableheader();
showsetting('username', 'newusername', '', 'text');
showsetting('password', 'newpassword', '', 'text');
showsetting('email', 'newemail', '', 'text');
showsetting('usergroup', '', '', '<select name="newgroupid">'.$groupselect.'</select>');
showsetting('members_add_email_notify', 'emailnotify', '', 'radio');
showsubmit('addsubmit');
showtablefooter();
showformfooter();
} else {
$newusername = trim($newusername);
$newpassword = trim($newpassword);
$newemail = trim($newemail);
if(!$newusername || !$newpassword || !$newemail) {
cpmsg('members_add_invalid', '', 'error');
}
if($db->result_first("SELECT count(*) FROM {$tablepre}members WHERE username='$newusername'")) {
cpmsg('members_add_username_duplicate', '', 'error');
}
require_once DISCUZ_ROOT.'./uc_client/client.php';
$uid = uc_user_register($newusername, $newpassword, $newemail);
if($uid <= 0) {
if($uid == -1) {
cpmsg('members_add_illegal', '', 'error');
} elseif($uid == -2) {
cpmsg('members_username_protect', '', 'error');
} elseif($uid == -3) {
cpmsg('members_add_username_activation', '', 'error');
} elseif($uid == -4) {
cpmsg('members_email_illegal', '', 'error');
} elseif($uid == -5) {
cpmsg('members_email_domain_illegal', '', 'error');
} elseif($uid == -6) {
cpmsg('members_email_duplicate', '', 'error');
} else {
cpmsg('undefined_action', '', 'error');
}
}
$query = $db->query("SELECT groupid, radminid, type FROM {$tablepre}usergroups WHERE groupid='$newgroupid'");
$group = $db->fetch_array($query);
$newadminid = in_array($group['radminid'], array(1, 2, 3)) ? $group['radminid'] : ($group['type'] == 'special' ? -1 : 0);
if($group['radminid'] == 1) {
cpmsg('members_add_admin_none', '', 'error');
}
if(in_array($group['groupid'], array(5, 6, 7))) {
cpmsg('members_add_ban_all_none', '', 'error');
}
$db->query("INSERT INTO {$tablepre}members (uid, username, password, secques, gender, adminid, groupid, regip, regdate, lastvisit, lastactivity, posts, credits, email, bday, sigstatus, tpp, ppp, styleid, dateformat, timeformat, showemail, newsletter, invisible, timeoffset)
VALUES ('$uid', '$newusername', '".md5(random(10))."', '', '0', '$newadminid', '$newgroupid', 'Manual Acting', '$timestamp', '$timestamp', '$timestamp', '0', '0', '$newemail', '0000-00-00', '0', '0', '0', '0', '0', '{$_DCACHE[settings][timeformat]}', '1', '1', '0', '{$_DCACHE[settings][timeoffset]}')");
$db->query("REPLACE INTO {$tablepre}memberfields (uid) VALUES ('$uid')");
if($emailnotify) {
sendmail("$newusername <$newemail>", 'add_member_subject', 'add_member_message');
}
updatecache('settings');
$newusername = stripslashes($newusername);
cpmsg('members_add_succeed', '', 'succeed');
}
} elseif($operation == 'group') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=group'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.uid, m.username, m.adminid, m.groupid, m.groupexpiry, m.extgroupids, m.credits,
mf.groupterms, u.type AS grouptype, u.grouptitle, u.radminid
FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE $condition");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
if(!submitcheck('editsubmit')) {
$checkadminid = array(($member['adminid'] >= 0 ? $member['adminid'] : 0) => 'checked');
$member['groupterms'] = unserialize($member['groupterms']);
if($member['groupterms']['main']) {
$expirydate = gmdate('Y-n-j', $member['groupterms']['main']['time'] + $timeoffset * 3600);
$expirydays = ceil(($member['groupterms']['main']['time'] - $timestamp) / 86400);
$selecteaid = array($member['groupterms']['main']['adminid'] => 'selected');
$selectegid = array($member['groupterms']['main']['groupid'] => 'selected');
} else {
$expirydate = $expirydays = '';
$selecteaid = array($member['adminid'] => 'selected');
$selectegid = array(($member['grouptype'] == 'member' ? 0 : $member['groupid']) => 'selected');
}
$extgroups = $expgroups = '';
$radmingids = 0;
$extgrouparray = explode("\t", $member['extgroupids']);
$groups = array('system' => '', 'special' => '', 'member' => '');
$group = array('groupid' => 0, 'radminid' => 0, 'type' => '', 'grouptitle' => $lang['usergroups_system_0'], 'creditshigher' => 0, 'creditslower' => '0');
$query = $db->query("SELECT groupid, radminid, type, grouptitle, creditshigher, creditslower
FROM {$tablepre}usergroups WHERE groupid NOT IN ('6', '7') ORDER BY creditshigher, groupid");
do {
if($group['groupid'] && !in_array($group['groupid'], array(4, 5, 6, 7, 8)) && ($group['type'] == 'system' || $group['type'] == 'special')) {
$extgroups .= showtablerow('', array('class="td27"', 'style="width:70%"'), array(
'<input class="checkbox" type="checkbox" name="extgroupidsnew[]" value="'.$group['groupid'].'" '.(in_array($group['groupid'], $extgrouparray) ? 'checked' : '').' id="extgid_'.$group['groupid'].'" /><label for="extgid_'.$group['groupid'].'"> '.$group['grouptitle'].'</label>',
'<input type="text" class="txt" size="9" name="extgroupexpirynew['.$group['groupid'].']" value="'.(in_array($group['groupid'], $extgrouparray) && !empty($member['groupterms']['ext'][$group['groupid']]) ? gmdate('Y-n-j', $member['groupterms']['ext'][$group['groupid']] + $timeoffset * 3600) : '').'" onclick="showcalendar(event, this)" />'
), TRUE);
}
if($group['groupid'] && $group['type'] == 'member' && !($member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower']) && $member['groupid'] != $group['groupid']) {
continue;
}
$expgroups .= '<option name="expgroupidnew" value="'.$group['groupid'].'" '.$selectegid[$group['groupid']].'>'.$group['grouptitle'].'</option>';
if($group['groupid'] != 0) {
$groups[$group['type']] .= '<option value="'.$group['groupid'].'"'.($member['groupid'] == $group['groupid'] ? 'selected="selected"' : '').' gtype="'.$group['type'].'">'.$group['grouptitle'].'</option>';
if($group['type'] == 'special' && !$group['radminid']) {
$radmingids .= ','.$group['groupid'];
}
}
} while($group = $db->fetch_array($query));
if(!$groups['member']) {
$group = $db->fetch_first("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type='member' AND creditshigher>='0' ORDER BY creditshigher LIMIT 1");
$groups['member'] = '<option value="'.$group['groupid'].'" gtype="member">'.$group['grouptitle'].'</option>';
}
shownav('user', 'members_group');
eval("\$lang[members_group_member] = \"".$lang['members_group_member']."\";");
showsubmenu('members_group_member');
echo '<script src="include/js/calendar.js" type="text/javascript"></script>';
showformheader("members&operation=group&uid=$member[uid]");
showtableheader('usergroup', 'nobottom');
showsetting('members_group_group', '', '', '<select name="groupidnew" onchange="if(in_array(this.value, ['.$radmingids.'])) {$(\'relatedadminid\').style.display = \'\';$(\'adminidnew\').name=\'adminidnew[\' + this.value + \']\';} else {$(\'relatedadminid\').style.display = \'none\';$(\'adminidnew\').name=\'adminidnew[0]\';}"><optgroup label="'.$lang['usergroups_system'].'">'.$groups['system'].'<optgroup label="'.$lang['usergroups_special'].'">'.$groups['special'].'<optgroup label="'.$lang['usergroups_member'].'">'.$groups['member'].'</select>');
showtagheader('tbody', 'relatedadminid', $member['grouptype'] == 'special' && !$member['radminid'], 'sub');
showsetting('members_group_related_adminid', '', '', '<select id="adminidnew" name="adminidnew['.$member['groupid'].']"><option value="0"'.($member['adminid'] == 0 ? ' selected' : '').'>'.$lang['none'].'</option><option value="3"'.($member['adminid'] == 3 ? ' selected' : '').'>'.$lang['usergroups_system_3'].'</option><option value="2"'.($member['adminid'] == 2 ? ' selected' : '').'>'.$lang['usergroups_system_2'].'</option><option value="1"'.($member['adminid'] == 1 ? ' selected' : '').'>'.$lang['usergroups_system_1'].'</option></select>');
showtagfooter('tbody');
showsetting('members_group_validity', 'expirydatenew', $expirydate, 'calendar');
showsetting('members_group_orig_adminid', '', '', '<select name="expgroupidnew">'.$expgroups.'</select>');
showsetting('members_group_orig_groupid', '', '', '<select name="expadminidnew"><option value="0" '.$selecteaid[0].'>'.$lang['usergroups_system_0'].'</option><option value="1" '.$selecteaid[1].'>'.$lang['usergroups_system_1'].'</option><option value="2" '.$selecteaid[2].'>'.$lang['usergroups_system_2'].'</option><option value="3" '.$selecteaid[3].'>'.$lang['usergroups_system_3'].'</option></select>');
showtablefooter();
showtableheader('members_group_extended', 'noborder fixpadding');
showsubtitle(array('usergroup', 'validity'));
echo $extgroups;
showtablerow('', 'colspan="2"', lang('members_group_extended_comment'));
showtablefooter();
showtableheader('members_edit_reason', 'notop');
showsetting('members_group_ban_reason', 'reason', '', 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$group = $db->fetch_first("SELECT groupid, radminid, type FROM {$tablepre}usergroups WHERE groupid='$groupidnew'");
if(!$group) {
cpmsg('undefined_action', '', 'error');
}
if(strlen(is_array($extgroupidsnew) ? implode("\t", $extgroupidsnew) : '') > 60) {
cpmsg('members_edit_groups_toomany', '', 'error');
}
$adminidnew = $adminidnew[$groupidnew];
switch($group['type']) {
case 'member':
$groupidnew = in_array($adminidnew, array(1, 2, 3)) ? $adminidnew : $groupidnew;
break;
case 'special':
if($group['radminid']) {
$adminidnew = $group['radminid'];
} elseif(!in_array($adminidnew, array(1, 2, 3))) {
$adminidnew = -1;
}
break;
case 'system':
$adminidnew = in_array($groupidnew, array(1, 2, 3)) ? $groupidnew : -1;
break;
}
$groupterms = array();
if($expirydatenew) {
$maingroupexpirynew = strtotime($expirydatenew);
$group = $db->fetch_first("SELECT groupid, radminid, type FROM {$tablepre}usergroups WHERE groupid='$expgroupidnew'");
if(!$group) {
$expgroupidnew = in_array($expadminidnew, array(1, 2, 3)) ? $expadminidnew : $expgroupidnew;
} else {
switch($group['type']) {
case 'special':
if($group['radminid']) {
$expadminidnew = $group['radminid'];
} elseif(!in_array($expadminidnew, array(1, 2, 3))) {
$expadminidnew = -1;
}
break;
case 'system':
$expadminidnew = in_array($expgroupidnew, array(1, 2, 3)) ? $expgroupidnew : -1;
break;
}
}
if($expgroupidnew == $groupidnew) {
cpmsg('members_edit_groups_illegal', '', 'error');
} elseif($maingroupexpirynew > $timestamp) {
if($expgroupidnew || $expadminidnew) {
$groupterms['main'] = array('time' => $maingroupexpirynew, 'adminid' => $expadminidnew, 'groupid' => $expgroupidnew);
} else {
$groupterms['main'] = array('time' => $maingroupexpirynew);
}
$groupterms['ext'][$groupidnew] = $maingroupexpirynew;
}
}
if(is_array($extgroupexpirynew)) {
foreach($extgroupexpirynew as $extgroupid => $expiry) {
if(is_array($extgroupidsnew) && in_array($extgroupid, $extgroupidsnew) && !isset($groupterms['ext'][$extgroupid]) && $expiry && ($expiry = strtotime($expiry)) > $timestamp) {
$groupterms['ext'][$extgroupid] = $expiry;
}
}
}
$grouptermsnew = addslashes(serialize($groupterms));
$groupexpirynew = groupexpiry($groupterms);
$extgroupidsnew = $extgroupidsnew && is_array($extgroupidsnew) ? implode("\t", $extgroupidsnew) : '';
$db->query("UPDATE {$tablepre}members SET groupid='$groupidnew', adminid='$adminidnew', extgroupids='$extgroupidsnew', groupexpiry='$groupexpirynew' WHERE uid='$member[uid]'");
$db->query("UPDATE {$tablepre}memberfields SET groupterms='$grouptermsnew' WHERE uid='$member[uid]'");
if($groupidnew != $member['groupid'] && (in_array($groupidnew, array(4, 5)) || in_array($member['groupid'], array(4, 5)))) {
banlog($member['username'], $member['groupid'], $groupidnew, $groupexpirynew, $reason);
}
cpmsg('members_edit_groups_succeed', "$BASESCRIPT?action=members&operation=group&uid=$member[uid]", 'succeed');
}
} elseif($operation == 'credit' && $extcredits) {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=credit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.*, u.grouptitle, u.type, u.creditslower, u.creditshigher
FROM {$tablepre}members m
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE $condition");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
if(!submitcheck('creditsubmit')) {
eval("\$membercredit = @round($creditsformula);");
if($jscreditsformula = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='creditsformula'")) {
$jscreditsformula = str_replace(array('digestposts', 'posts', 'pageviews', 'oltime'), array($member['digestposts'], $member['posts'],$member['pageviews'],$member['oltime']), $jscreditsformula);
}
$creditscols = array('members_credit_ranges', 'credits');
$creditsvalue = array($member['type'] == 'member' ? "$member[creditshigher]~$member[creditslower]" : 'N/A', '<input type="text" class="txt" name="jscredits" id="jscredits" value="'.$membercredit.'" size="3" disabled>');
for($i = 1; $i <= 8; $i++) {
$jscreditsformula = str_replace('extcredits'.$i, "extcredits[$i]", $jscreditsformula);
$creditscols[] = isset($extcredits[$i]) ? $extcredits[$i]['title'] : 'extcredits'.$i;
$creditsvalue[] = isset($extcredits[$i]) ? '<input type="text" class="txt" size="3" name="extcreditsnew['.$i.']" id="extcreditsnew['.$i.']" value="'.$member['extcredits'.$i].'" onkeyup="membercredits()"> '.$extcredits['$i']['unit'] : '<input type="text" class="txt" size="3" value="N/A" disabled>';
}
echo <<<EOT
<script language="JavaScript">
var extcredits = new Array();
function membercredits() {
var credits = 0;
for(var i = 1; i <= 8; i++) {
e = $('extcreditsnew['+i+']');
if(e && parseInt(e.value)) {
extcredits[i] = parseInt(e.value);
} else {
extcredits[i] = 0;
}
}
$('jscredits').value = Math.round($jscreditsformula);
}
</script>
EOT;
shownav('user', 'members_credit');
showsubmenu('members_credit');
showtips('members_credit_tips');
showformheader("members&operation=credit&uid=$uid");
showtableheader(lang('members_credit').' - '.$member['username']."($member[grouptitle])", 'nobottom');
showsubtitle($creditscols);
showtablerow('', array('', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), $creditsvalue);
showtablefooter();
showtableheader('', 'notop');
showtitle('members_edit_reason');
showsetting('members_credit_reason', 'reason', '', 'textarea');
showsubmit('creditsubmit');
showtablefooter();
showformfooter();
} else {
$diffarray = array();
$sql = $comma = '';
if(is_array($extcreditsnew)) {
foreach($extcreditsnew as $id => $value) {
if($member['extcredits'.$id] != ($value = intval($value))) {
$diffarray[$id] = $value - $member['extcredits'.$id];
$sql .= $comma."extcredits$id='$value'";
$comma = ', ';
}
}
}
if($diffarray) {
if(empty($reason)) {
cpmsg('members_edit_reason_invalid', '', 'error');
}
foreach($diffarray as $id => $diff) {
$logs[] = dhtmlspecialchars("$timestamp\t$discuz_userss\t$adminid\t$member[username]\t$id\t$diff\t0\t\t$reason");
}
$db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$uid'");
writelog('ratelog', $logs);
}
cpmsg('members_edit_credits_succeed', "$BASESCRIPT?action=members&operation=credit&uid=$uid", 'succeed');
}
} elseif($operation == 'medal') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=medal'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.uid, m.username, mf.medals
FROM {$tablepre}memberfields mf, {$tablepre}members m
WHERE $condition AND m.uid=mf.uid");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
}
if(!submitcheck('medalsubmit')) {
$medals = '';
$membermedals = array();
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach (explode("\t", $member['medals']) as $key => $membermedal) {
list($medalid, $medalexpiration) = explode("|", $membermedal);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$membermedals[$key] = $medalid;
} else {
unset($membermedals[$key]);
}
}
$query = $db->query("SELECT * FROM {$tablepre}medals WHERE available='1'");
while($medal = $db->fetch_array($query)) {
$medals .= showtablerow('', array('class="td25"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"medals[$medal[medalid]]\" value=\"1\" ".(in_array($medal['medalid'], $membermedals) ? 'checked' : '')." />",
"<img src=\"images/common/$medal[image]\" />",
$medal['name']
), TRUE);
}
if(!$medals) {
cpmsg('members_edit_medals_nonexistence', '', 'error');
}
shownav('user', 'nav_members_confermedal');
showsubmenu('nav_members_confermedal');
showformheader("members&operation=medal&uid=$uid");
showtableheader("$lang[members_confermedal_to] <a href='space.php?uid=$uid' target='_blank'>$member[username]</a>", 'fixpadding');
showsubtitle(array('medals_grant', 'medals_image', 'name'));
echo $medals;
showsubmit('medalsubmit');
showtablefooter();
showformfooter();
} else {
$medalids = $comma = '';
$medalsdel = $medalsadd = $medalsnew = $origmedalsarray = $medalsarray = array();
if(is_array($medals)) {
foreach($medals as $medalid => $newgranted) {
if($newgranted) {
$medalsarray[] = $medalid;
$medalids .= "$comma'$medalid'";
$comma = ',';
}
}
}
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach($member['medals'] = explode("\t", $member['medals']) as $key => $modmedalid) {
list($medalid, $medalexpiration) = explode("|", $modmedalid);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$origmedalsarray[] = $medalid;
}
}
foreach(array_unique(array_merge($origmedalsarray, $medalsarray)) as $medalid) {
if($medalid) {
$orig = in_array($medalid, $origmedalsarray);
$new = in_array($medalid, $medalsarray);
if($orig != $new) {
if($orig && !$new) {
$medalsdel[] = $medalid;
} elseif(!$orig && $new) {
$medalsadd[] = $medalid;
}
}
}
}
if(!empty($medalids)) {
$query = $db->query("SELECT * FROM {$tablepre}medals WHERE medalid IN ($medalids)");
while($modmedal = $db->fetch_array($query)) {
if(empty($modmedal['expiration'])) {
$medalsnew[] = $modmedal[medalid];
$medalstatus = 0;
} else {
$modmedal['expiration'] = $timestamp + $modmedal['expiration'] * 86400;
$medalsnew[] = $modmedal[medalid].'|'.$modmedal['expiration'];
$medalstatus = 1;
}
if(in_array($modmedal['medalid'], $medalsadd)) {
$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('$uid', '".$modmedal[medalid]."', '0', '$timestamp', '".$modmedal['expiration']."', '$medalstatus')");
}
}
}
if(!empty($medalsdel)) {
$db->query("UPDATE {$tablepre}medallog SET type='4' WHERE uid='$uid' AND medalid IN (".implode(',', $medalsdel).")");
}
$medalsnew = implode("\t", $medalsnew);
$db->query("UPDATE {$tablepre}memberfields SET medals='$medalsnew' WHERE uid='$uid'");
cpmsg('members_edit_medals_succeed', "$BASESCRIPT?action=members&operation=medal&uid=$uid", 'succeed');
}
} elseif($operation == 'ban') {
if(!$allowbanuser) {
cpmsg('action_noaccess', '', 'error');
}
$member = array();
if(!empty($username) || !empty($uid)) {
$member = $db->fetch_first("SELECT m.*, mf.*, u.type AS grouptype, u.allowsigbbcode, u.allowsigimgcode FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE ".($uid ? "m.uid='$uid'" : "m.username='$username'"));
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(($member['grouptype'] == 'system' && in_array($member['groupid'], array(1, 2, 3, 6, 7, 8))) || $member['grouptype'] == 'special') {
cpmsg('members_edit_illegal', '', 'error');
}
$member['groupterms'] = unserialize($member['groupterms']);
$member['banexpiry'] = !empty($member['groupterms']['main']['time']) && ($member['groupid'] == 4 || $member['groupid'] == 5) ? gmdate('Y-n-j', $member['groupterms']['main']['time'] + $timeoffset * 3600) : '';
}
if(!submitcheck('bansubmit')) {
echo '<script src="include/js/calendar.js" type="text/javascript"></script>';
shownav('user', 'members_ban_user');
showsubmenu($lang['members_ban_user'].($member['username'] ? ' -'.$member['username'] : ''));
showformheader('members&operation=ban');
showtableheader();
showsetting('members_ban_username', 'username', $member['username'], 'text');
if($member) {
showtablerow('', 'class="td27"', lang('members_edit_current_status').'<span class="normal">: '.($member['groupid'] == 4 ? $lang['members_ban_post'] : ($member['groupid'] == 5 ? $lang['members_ban_visit'] : $lang['members_ban_none'])).'</span>');
}
showsetting('members_ban_type', array('bannew', array(
array('', $lang['members_ban_none']),
array('post', $lang['members_ban_post']),
array('visit', $lang['members_ban_visit'])
)), '0', 'mradio');
showsetting('members_ban_validity', '', '', selectday('banexpirynew', array(0, 1, 3, 5, 7, 14, 30, 60, 90, 180, 365)));
showsetting('members_ban_delpost', 'delpost', '', 'radio');
showsetting('members_ban_reason', 'reason', '', 'textarea');
showsubmit('bansubmit');
showtablefooter();
showformfooter();
} else {
if(empty($member)) {
cpmsg('members_edit_nonexistence');
}
$sql = 'uid=uid';
$reason = trim($reason);
if(!$reason && ($reasonpm == 1 || $reasonpm == 3)) {
cpmsg('members_edit_reason_invalid', '', 'error');
}
if($bannew == 'post' || $bannew == 'visit') {
$groupidnew = $bannew == 'post' ? 4 : 5;
$banexpirynew = !empty($banexpirynew) ? $timestamp + $banexpirynew * 86400 : 0;
$banexpirynew = $banexpirynew > $timestamp ? $banexpirynew : 0;
if($banexpirynew) {
$member['groupterms']['main'] = array('time' => $banexpirynew, 'adminid' => $member['adminid'], 'groupid' => $member['groupid']);
$member['groupterms']['ext'][$groupidnew] = $banexpirynew;
$sql .= ', groupexpiry=\''.groupexpiry($member['groupterms']).'\'';
} else {
$sql .= ', groupexpiry=0';
}
$adminidnew = -1;
} elseif($member['groupid'] == 4 || $member['groupid'] == 5) {
if(!empty($member['groupterms']['main']['groupid'])) {
$groupidnew = $member['groupterms']['main']['groupid'];
$adminidnew = $member['groupterms']['main']['adminid'];
unset($member['groupterms']['main']);
unset($member['groupterms']['ext'][$member['groupid']]);
$sql .= ', groupexpiry=\''.groupexpiry($member['groupterms']).'\'';
} else {
$groupidnew = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditshigher<='$member[credits]' AND creditslower>'$member[credits]'");
$adminidnew = 0;
}
} else {
$groupidnew = $member['groupid'];
$adminidnew = $member['adminid'];
}
$sql .= ", adminid='$adminidnew', groupid='$groupidnew'";
$db->query("UPDATE {$tablepre}members SET $sql WHERE uid='$member[uid]'");
if($allowbanuser && ($db->affected_rows($query))) {
banlog($member['username'], $member['groupid'], $groupidnew, $banexpirynew, $reason);
}
$db->query("UPDATE {$tablepre}memberfields SET groupterms='".($member['groupterms'] ? addslashes(serialize($member['groupterms'])) : '')."' WHERE uid='$member[uid]'");
if($delpost && $bannew && $adminid == 1) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE uid='$member[uid]'");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if($member['uid']) {
$db->query("DELETE FROM {$tablepre}threads WHERE authorid='$member[uid]'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}posts WHERE authorid='$member[uid]'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE sellerid='$member[uid]'", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE uid='$member[uid]'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}members SET posts='0', digestposts='0' WHERE uid='$member[uid]'", 'UNBUFFERED');
}
}
cpmsg('members_edit_succeed', $BASESCRIPT.'?action=members&operation=ban', 'succeed');
}
} elseif($operation == 'access') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=access'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "uid='$uid'" : "username='$username'";
}
$member = $db->fetch_first("SELECT username, adminid, groupid FROM {$tablepre}members WHERE $condition");
if(!$member) {
cpmsg('undefined_action', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumlist = '<SELECT name="addfid">'.forumselect().'</select>';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
if(!submitcheck('accesssubmit')) {
shownav('user', 'members_access_edit');
showsubmenu('members_access_edit');
showtips('members_access_tips');
showtableheader(lang('members_access_now').' - '.$member['username'], 'nobottom fixpadding');
showsubtitle(array('forum', 'members_access_view', 'members_access_post', 'members_access_reply', 'members_access_postattach', 'members_access_getattach', 'members_access_adminuser', 'members_access_dateline'));
$accessmasks = array();
$query = $db->query("SELECT a.*, m.username as adminusername FROM {$tablepre}access a LEFT JOIN {$tablepre}members m ON a.adminuser=m.uid WHERE a.uid='$uid'");
while($access = $db->fetch_array($query)) {
$accessmasks[$access['fid']] = $access;
$accessmasks[$access['fid']]['dateline'] = $access['dateline'] ? gmdate("$dateformat $timeformat", $timeoffset * 3600 + $access['dateline']) : '';
}
foreach ($accessmasks as $id => $access) {
$forum = $_DCACHE['forums'][$id];
showtablerow('', '', array(
($forum['type'] == 'forum' ? '' : '|-----')." <a href=\"$BASESCRIPT?action=forums&operation=edit&fid=$forum[fid]&anchor=perm\">$forum[name]</a>",
accessimg($access['allowview']),
accessimg($access['allowpost']),
accessimg($access['allowreply']),
accessimg($access['allowpostattach']),
accessimg($access['allowgetattach']),
$access['adminusername'],
$access['dateline'],
));
}
if(empty($accessmasks)) {
showtablerow('', '', array(
'-',
'-',
'-',
'-',
'-',
'-',
'-',
'-',
));
}
showtablefooter();
showformheader("members&operation=access&uid=$uid");
showtableheader(lang('members_access_add'), 'notop fixpadding');
showsetting('members_access_add_forum', '', '', $forumlist);
foreach(array('view', 'post', 'reply', 'postattach', 'getattach') as $perm) {
showsetting('members_access_add_'.$perm, array('allow'.$perm.'new', array(
array(0, lang('default')),
array(1, lang('members_access_allowed')),
array(-1, lang('members_access_disallowed')),
), TRUE), 0, 'mradio');
}
showsubmit('accesssubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$addfid = intval($addfid);
if($addfid && $_DCACHE['forums'][$addfid]) {
$allowviewnew = !$allowviewnew ? 0 : ($allowviewnew > 0 ? 1 : -1);
$allowpostnew = !$allowpostnew ? 0 : ($allowpostnew > 0 ? 1 : -1);
$allowreplynew = !$allowreplynew ? 0 : ($allowreplynew > 0 ? 1 : -1);
$allowgetattachnew = !$allowgetattachnew ? 0 : ($allowgetattachnew > 0 ? 1 : -1);
$allowpostattachnew = !$allowpostattachnew ? 0 : ($allowpostattachnew > 0 ? 1 : -1);
if($allowviewnew == -1) {
$allowpostnew = $allowreplynew = $allowgetattachnew = $allowpostattachnew = -1;
} elseif($allowpostnew == 1 || $allowreplynew == 1 || $allowgetattachnew == 1 || $allowpostattachnew == 1) {
$allowviewnew = 1;
}
if(!$allowviewnew && !$allowpostnew && !$allowreplynew && !$allowgetattachnew && !$allowpostattachnew) {
$db->query("DELETE FROM {$tablepre}access WHERE uid='$uid' AND fid='$addfid'");
if(!$db->result_first("SELECT count(*) FROM {$tablepre}access WHERE uid='$uid'")) {
$db->query("UPDATE {$tablepre}members SET accessmasks='0' WHERE uid='$uid'");
}
} else {
$db->query("REPLACE INTO {$tablepre}access SET
uid='$uid', fid='$addfid', allowview='$allowviewnew',
allowpost='$allowpostnew', allowreply='$allowreplynew', allowgetattach='$allowgetattachnew',
allowpostattach='$allowpostattachnew', adminuser='$discuz_uid', dateline='$timestamp'");
$db->query("UPDATE {$tablepre}members SET accessmasks='1' WHERE uid='$uid'");
}
updatecache('forums');
}
cpmsg('members_access_succeed', $BASESCRIPT.'?action=members&operation=access&uid='.$uid, 'succeed');
}
} elseif($operation == 'edit') {
if(empty($uid) && empty($username)) {
cpmsg('members_nonexistence', $BASESCRIPT.'?action=members&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', '<input type="text" name="username" value="" class="txt" />');
} else {
$condition = !empty($uid) ? "m.uid='$uid'" : "m.username='$username'";
}
$member = $db->fetch_first("SELECT m.*, mf.*, m.uid AS muid, o.*, u.type, u.allowsigbbcode, u.allowsigimgcode, u.allowcusbbcode, u.allowbiobbcode, u.allowbioimgcode, u.allowcusbbcode FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
LEFT JOIN {$tablepre}onlinetime o ON o.uid=m.uid
LEFT JOIN {$tablepre}usergroups u ON u.groupid=m.groupid
WHERE $condition");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} elseif(!$isfounder && ($member['adminid'] == 1 || $member['groupid'] == 1)) {
cpmsg('members_super_edit_admin_allow', '', 'error');
}
$uid = $member['muid'];
require_once DISCUZ_ROOT.'./forumdata/cache/cache_profilefields.php';
$fields = array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']);
if(!submitcheck('editsubmit')) {
require_once DISCUZ_ROOT.'./include/editor.func.php';
$styleselect = "<select name=\"styleidnew\">\n<option value=\"\">$lang[use_default]</option>";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$styleselect .= "<option value=\"$style[styleid]\" ".($style['styleid'] == $member['styleid'] ? 'selected="selected"' : '').">$style[name]</option>\n";
}
$styleselect .= '</select>';
$tfcheck = array($member['timeformat'] => 'checked');
$gendercheck = array($member['gender'] => 'checked');
$pscheck = array($member['pmsound'] => 'checked');
$member['regdate'] = gmdate('Y-n-j h:i A', $member['regdate'] + $timeoffset * 3600);
$member['lastvisit'] = gmdate('Y-n-j h:i A', $member['lastvisit'] + $timeoffset * 3600);
$member['bio'] = html2bbcode($member['bio']);
$member['signature'] = html2bbcode($member['sightml']);
shownav('user', 'members_edit');
showsubmenu("$lang[members_edit] - $member[username]");
showformheader("members&operation=edit&uid=$uid");
showtableheader();
showsetting('members_edit_username', '', '', ' '.$member['username']);
showsetting('members_edit_avatar', '', '', ' '.discuz_uc_avatar($uid).'<br /><br /><input name="clearavatar" class="checkbox" type="checkbox" value="1" /> '.$lang['members_edit_avatar_clear']);
showsetting('members_edit_password', 'passwordnew', '', 'text');
showsetting('members_edit_clearquestion', 'clearquestion', !$member['secques'], 'radio');
showsetting('members_edit_nickname', 'nicknamenew', $member['nickname'], 'text');
showsetting('members_edit_gender', '', '', '<input class="radio" type="radio" name="gendernew" value="1" '.$gendercheck[1].'> '.$lang['members_edit_gender_male'].' <input class="radio" type="radio" name="gendernew" value="2" '.$gendercheck[2].'> '.$lang['members_edit_gender_female'].' <input class="radio" type="radio" name="gendernew" value="0" '.$gendercheck[0].'> '.$lang['members_edit_gender_secret']);
showsetting('members_edit_email', 'emailnew', $member['email'], 'text');
showsetting('members_edit_posts', 'postsnew', $member['posts'], 'text');
showsetting('members_edit_digestposts', 'digestpostsnew', $member['digestposts'], 'text');
showsetting('members_edit_pageviews', 'pageviewsnew', $member['pageviews'], 'text');
showsetting('members_edit_online_total', 'totalnew', $member['total'], 'text');
showsetting('members_edit_online_thismonth', 'thismonthnew', $member['thismonth'], 'text');
showsetting('members_edit_regip', 'regipnew', $member['regip'], 'text');
showsetting('members_edit_regdate', 'regdatenew', $member['regdate'], 'text');
showsetting('members_edit_lastvisit', 'lastvisitnew', $member['lastvisit'], 'text');
showsetting('members_edit_lastip', 'lastipnew', $member['lastip'], 'text');
showtitle('members_edit_info');
showsetting('members_edit_site', 'sitenew', $member['site'], 'text');
showsetting('members_edit_qq', 'qqnew', $member['qq'], 'text');
showsetting('members_edit_icq', 'icqnew', $member['icq'], 'text');
showsetting('members_edit_yahoo', 'yahoonew', $member['yahoo'], 'text');
showsetting('members_edit_msn', 'msnnew', $member['msn'], 'text');
showsetting('members_edit_taobao', 'taobaonew', $member['taobao'], 'text');
showsetting('members_edit_alipay', 'alipaynew', $member['alipay'], 'text');
showsetting('members_edit_location', 'locationnew', $member['location'], 'text');
showsetting('members_edit_bday', 'bdaynew', $member['bday'], 'text');
showsetting('members_edit_bio', 'bionew', $member['bio'], 'textarea');
showsetting('members_edit_signature', 'signaturenew', $member['signature'], 'textarea');
showtitle('members_edit_option');
showsetting('members_edit_style', '', '', $styleselect);
showsetting('members_edit_tpp', 'tppnew', $member['tpp'], 'text');
showsetting('members_edit_ppp', 'pppnew', $member['ppp'], 'text');
showsetting('members_edit_cstatus', 'cstatusnew', $member['customstatus'], 'text');
showsetting('members_edit_timeformat', '', '', '<input class="radio" type="radio" name="timeformatnew" value="0" '.$tfcheck[0].'> '.$lang['default'].' <input class="radio" type="radio" name="timeformatnew" value="1" '.$tfcheck[1].'> '.$lang['members_edit_timeformat_12'].' <input class="radio" type="radio" name="timeformatnew" value="2" '.$tfcheck[2].'> '.$lang['members_edit_timeformat_24']);
showsetting('members_edit_timeoffset', 'timeoffsetnew', $member['timeoffset'], 'text');
showsetting('members_edit_pmsound', '', '', '<input class="radio" type="radio" value="0" name="pmsoundnew" '.$pscheck[0].'>'.$lang['none'].' <input class="radio" type="radio" value="1" name="pmsoundnew" '.$pscheck[1].'><a href="images/sound/pm_1.mp3">#1</a> <input class="radio" type="radio" value="2" name="pmsoundnew" '.$pscheck[2].'><a href="images/sound/pm_2.mp3">#2</a> <input class="radio" type="radio" value="3" name="pmsoundnew" '.$pscheck[3].'><a href="images/sound/pm_3.mp3">#3</a>');
showsetting('members_edit_invisible', 'invisiblenew', $member['invisible'], 'radio');
showsetting('members_edit_showemail', 'showemailnew', $member['showemail'], 'radio');
showsetting('members_edit_newsletter', 'newsletternew', $member['newsletter'], 'radio');
showsetting('members_edit_ignorepm', 'ignorepmnew', $member['ignorepm'], 'textarea');
if($fields) {
showtitle('profilefields_fields');
foreach($fields as $field) {
if($field['selective']) {
$fieldselect = "<select name=\"field_$field[fieldid]new\"><option value=\"\"> </option>";
foreach($field['choices'] as $index => $choice) {
$fieldselect .= "<option value=\"$index\" ".($index == $member['field_'.$field['fieldid']] ? 'selected="selected"' : '').">$choice</option>";
}
$fieldselect .= '</select>';
showsetting($field['title'], '', '', $fieldselect);
} else {
showsetting($field['title'], "field_$field[fieldid]new", $member['field_'.$field['fieldid']], 'text');
}
}
}
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
require_once DISCUZ_ROOT.'./uc_client/client.php';
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$questionid = $clearquestion ? 0 : '';
$ucresult = uc_user_edit($member['username'], $passwordnew, $passwordnew, $emailnew, 1, $questionid);
if($clearavatar) {
uc_user_deleteavatar($member['uid']);
}
$creditsnew = intval($creditsnew);
$regdatenew = strtotime($regdatenew);
$lastvisitnew = strtotime($lastvisitnew);
$secquesadd = $clearquestion ? ", secques=''" : '';
$signaturenew = censor($signaturenew);
$sigstatusnew = $signaturenew ? 1 : 0;
$sightmlnew = addslashes(discuzcode(stripslashes($signaturenew), 1, 0, 0, 0, ($member['allowsigbbcode'] ? ($member['allowcusbbcode'] ? 2 : 1) : 0), $member['allowsigimgcode'], 0));
$bionew = censor(dhtmlspecialchars($bionew));
$biohtmlnew = addslashes(discuzcode(stripslashes($bionew), 1, 0, 0, 0, ($member['allowbiobbcode'] ? ($member['allowcusbbcode'] ? 2 : 1) : 0), $member['allowbioimgcode'], 0));
$oltimenew = round($totalnew / 60);
$fieldadd = '';
foreach(array_merge($_DCACHE['fields_required'], $_DCACHE['fields_optional']) as $field) {
$field_key = 'field_'.$field['fieldid'];
$field_val = trim(${'field_'.$field['fieldid'].'new'});
if($field['selective'] && $field_val != '' && !isset($field['choices'][$field_val])) {
cpmsg('undefined_action', '', 'error');
} else {
$fieldadd .= ", $field_key='".dhtmlspecialchars($field_val)."'";
}
}
$emailadd = $ucresult < 0 ? '' : "email='$emailnew', ";
$passwordadd = $ucresult < 0 ? '' : ", password='".md5(random(10))."'";
$db->query("UPDATE {$tablepre}members SET gender='$gendernew', $emailadd posts='$postsnew', digestposts='$digestpostsnew',
pageviews='$pageviewsnew', regip='$regipnew', regdate='$regdatenew', lastvisit='$lastvisitnew', lastip='$lastipnew', bday='$bdaynew',
styleid='$styleidnew', tpp='$tppnew', ppp='$pppnew', timeformat='$timeformatnew', oltime='$oltimenew',
showemail='$showemailnew', newsletter='$newsletternew', invisible='$invisiblenew', timeoffset='$timeoffsetnew',
pmsound='$pmsoundnew', sigstatus='$sigstatusnew' $passwordadd $secquesadd WHERE uid='$uid'");
$db->query("UPDATE {$tablepre}memberfields SET nickname='$nicknamenew', site='$sitenew', qq='$qqnew', icq='$icqnew', yahoo='$yahoonew', msn='$msnnew',
taobao='$taobaonew', alipay='$alipaynew', location='$locationnew', bio='$biohtmlnew', customstatus='$cstatusnew', ignorepm='$ignorepmnew', sightml='$sightmlnew'
$fieldadd WHERE uid='$uid'");
$db->query("REPLACE INTO {$tablepre}onlinetime (uid, thismonth, total)
VALUES ('$uid', '$thismonthnew', '$totalnew')");
cpmsg('members_edit_succeed', '', 'succeed');
}
} elseif($operation == 'ipban') {
if(!submitcheck('ipbansubmit')) {
require_once DISCUZ_ROOT.'./include/misc.func.php';
$iptoban = explode('.', $ip);
$ipbanned = '';
$query = $db->query("SELECT * FROM {$tablepre}banned ORDER BY dateline");
while($banned = $db->fetch_array($query)) {
for($i = 1; $i <= 4; $i++) {
if($banned["ip$i"] == -1) {
$banned["ip$i"] = '*';
}
}
$disabled = $adminid != 1 && $banned['admin'] != $discuz_userss ? 'disabled' : '';
$banned['dateline'] = gmdate($dateformat, $banned['dateline'] + $timeoffset * 3600);
$banned['expiration'] = gmdate($dateformat, $banned['expiration'] + $timeoffset * 3600);
$theip = "$banned[ip1].$banned[ip2].$banned[ip3].$banned[ip4]";
$ipbanned .= showtablerow('', array('class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$banned[id]]\" value=\"$banned[id]\" $disabled />",
$theip,
convertip($theip, "./"),
$banned[admin],
$banned[dateline],
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"expirationnew[$banned[id]]\" value=\"$banned[expiration]\" $disabled />"
), TRUE);
}
shownav('user', 'nav_members_ipban');
showsubmenu('nav_members_ipban');
showtips('members_ipban_tips');
showformheader('members&operation=ipban');
showtableheader();
showsubtitle(array('', 'ip', 'members_ipban_location', 'operator', 'start_time', 'end_time'));
echo $ipbanned;
showtablerow('', array('', 'class="td28" colspan="3"', 'class="td28" colspan="2"'), array(
$lang['add_new'],
'<input type="text" class="txt" name="ip1new" value="'.$iptoban[0].'" size="3" maxlength="3">.<input type="text" class="txt" name="ip2new" value="'.$iptoban[1].'" size="3" maxlength="3">.<input type="text" class="txt" name="ip3new" value="'.$iptoban[2].'" size="3" maxlength="3">.<input type="text" class="txt" name="ip4new" value="'.$iptoban[3].'" size="3" maxlength="3">',
$lang['validity'].': <input type="text" class="txt" name="validitynew" value="30" size="3"> '.$lang['days']
));
showsubmit('ipbansubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}banned WHERE id IN ($ids) AND ('$adminid'='1' OR admin='$discuz_user')");
}
if($ip1new != '' && $ip2new != '' && $ip3new != '' && $ip4new != '') {
$own = 0;
$ip = explode('.', $onlineip);
for($i = 1; $i <= 4; $i++) {
if(!is_numeric(${'ip'.$i.'new'}) || ${'ip'.$i.'new'} < 0) {
if($adminid != 1) {
cpmsg('members_ipban_nopermission', '', 'error');
}
${'ip'.$i.'new'} = -1;
$own++;
} elseif(${'ip'.$i.'new'} == $ip[$i - 1]) {
$own++;
}
${'ip'.$i.'new'} = intval(${'ip'.$i.'new'});
}
if($own == 4) {
cpmsg('members_ipban_illegal', '', 'error');
}
$query = $db->query("SELECT * FROM {$tablepre}banned");
while($banned = $db->fetch_array($query)) {
$exists = 0;
for($i = 1; $i <= 4; $i++) {
if($banned["ip$i"] == -1) {
$exists++;
} elseif($banned["ip$i"] == ${"ip".$i."new"}) {
$exists++;
}
}
if($exists == 4) {
cpmsg('members_ipban_invalid', '', 'error');
}
}
$expiration = $timestamp + $validitynew * 86400;
$db->query("UPDATE {$tablepre}sessions SET groupid='6' WHERE ('$ip1new'='-1' OR ip1='$ip1new') AND ('$ip2new'='-1' OR ip2='$ip2new') AND ('$ip3new'='-1' OR ip3='$ip3new') AND ('$ip4new'='-1' OR ip4='$ip4new')");
$db->query("INSERT INTO {$tablepre}banned (ip1, ip2, ip3, ip4, admin, dateline, expiration)
VALUES ('$ip1new', '$ip2new', '$ip3new', '$ip4new', '$discuz_user', '$timestamp', '$expiration')");
}
if(is_array($expirationnew)) {
foreach($expirationnew as $id => $expiration) {
$db->query("UPDATE {$tablepre}banned SET expiration='".strtotime($expiration)."' WHERE id='$id' AND ('$adminid'='1' OR admin='$discuz_user')");
}
}
updatecache('ipbanned');
cpmsg('members_ipban_succeed', $BASESCRIPT.'?action=members&operation=ipban', 'succeed');
}
}
function searchmembers($operation = '') {
global $db, $tablepre, $usergroupid, $username, $srchemail, $lower, $higher, $extcredits, $submit, $lang;
$groupselect = '';
$usergroupid = isset($usergroupid) && is_array($usergroupid) ? $usergroupid : array();
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE groupid NOT IN ('6', '7') ORDER BY (creditshigher<>'0' || creditslower<>'0'), creditslower");
while($group = $db->fetch_array($query)) {
$groupselect .= "<option value=\"$group[groupid]\" ".(in_array($group['groupid'], $usergroupid) ? 'selected' : '').">$group[grouptitle]</option>\n";
}
$monthselect = $dayselect = '';
for($m=1; $m<=12; $m++) {
$m = sprintf("%02d", $m);
$monthselect .= "<option value=\"$m\" ".($birthmonth == $m ? 'selected' : '').">$m</option>\n";
}
for($d=1; $d<=31; $d++) {
$d = sprintf("%02d", $d);
$dayselect .= "<option value=\"$d\" ".($birthday == $d ? 'selected' : '').">$d</option>\n";
}
showtagheader('div', 'searchmembers', !$submit);
echo '<script src="include/js/calendar.js" type="text/javascript"></script>';
showformheader("members&operation=$operation", "onSubmit=\"if($('updatecredittype1') && $('updatecredittype1').checked && !window.confirm('$lang[members_reward_clean_alarm]')){return false;} else {return true;}\"");
showtableheader();
showsetting('members_search_user', 'username', $username, 'text');
showsetting('members_search_uid', 'uid', $uid, 'text');
showsetting('members_search_group', '', '', '<select name="usergroupid[]" multiple="multiple" size="10"><option value="all"'.(in_array('all', $usergroupid) ? ' selected' : '').'>'.lang('unlimited').'</option>'.$groupselect.'</select>');
showtagheader('tbody', 'advanceoption');
showsetting('members_search_email', 'srchemail', $srchemail, 'text');
showsetting("$lang[credits] $lang[members_search_between]", array("higher[credits]", "lower[credits]"), array($higher[credits], $lower[credits]), 'range');
if(!empty($extcredits)) {
foreach($extcredits as $id => $credit) {
showsetting("$credit[title] $lang[members_search_between]", array("higher[extcredits$id]", "lower[extcredits$id]"), array($higher['extcredits'.$id], $lower['extcredits'.$id]), 'range');
}
}
showsetting('members_search_postsrange', array('postshigher', 'postslower'), array($postshigher, $postslower), 'range');
showsetting('members_search_regip', 'regip', $regip, 'text');
showsetting('members_search_lastip', 'lastip', $lastip, 'text');
showsetting('members_search_regdaterange', array('regdateafter', 'regdatebefore'), array($regdateafter, $regdatebefore), 'daterange');
showsetting('members_search_lastvisitrange', array('lastvisitafter', 'lastvisitbefore'), array($lastvisitafter, $lastvisitbefore), 'daterange');
showsetting('members_search_lastpostrange', array('lastpostafter', 'lastpostbefore'), array($lastpostafter, $lastpostbefore), 'daterange');
showsetting('members_search_birthday', '', '', '<input type="text" class="txt" name="birthyear" style="width:86px; margin-right:0" value="'.dhtmlspecialchars($year).'"> '.$lang['year'].' <input type="text" class="txt" name="birthmonth" style="width:45px; margin-right:0" value="'.dhtmlspecialchars($month).'"> '.$lang['month'].' <input type="text" class="txt" name="birthday" style="width:45px; margin-right:0" value="'.dhtmlspecialchars($day).'"> '.$lang['day']);
showtagfooter('tbody');
showsubmit('submit', $operation == 'clean' ? 'members_delete' : 'search', '', 'more_options');
showtablefooter();
showformfooter();
showtagfooter('div');
}
function countmembers() {
extract($GLOBALS, EXTR_SKIP);
global $memberperpage, $page, $start_limit, $membernum, $conditions, $urladd;
$memberperpage = 100;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $memberperpage;
$dateoffset = date('Z') - ($timeoffset * 3600);
$username = trim($username);
$conditions = '';
if($username != '') {
$usernames = explode(',', $username);
foreach($usernames as $u) {
$usernameary[] = " username LIKE '".str_replace(array('%', '*', '_'), array('\%', '%', '\_'), $u)."'";
}
$conditions .= " AND (".implode(' OR ', $usernameary).")";
}
$conditions .= intval($uid) ? " AND uid='".intval($uid)."'" : '';
$conditions .= $srchemail != '' ? " AND email LIKE '".str_replace('*', '%', $srchemail)."'" : '';
$conditions .= !empty($usergroupid) && !in_array('all', $usergroupid) != '' ? " AND groupid IN ('".implode('\',\'', $usergroupid)."')" : '';
if(is_array($higher)) {
foreach($higher as $credit => $value) {
$credit = intval(substr($credit, 10));
if($value != '' && $credit > 0 && $credit < 9) {
$value = intval($value);
$conditions .= " AND extcredits$credit>'$value'";
}
}
}
if(is_array($lower)) {
foreach($lower as $credit => $value) {
$credit = intval(substr($credit, 10));
if($value != '' && $credit > 0 && $credit < 9) {
$value = intval($value);
$conditions .= " AND extcredits$credit<'$value'";
}
}
}
$conditions .= $postshigher != '' ? " AND posts>'$postshigher'" : '';
$conditions .= $postslower != '' ? " AND posts<'$postslower'" : '';
$conditions .= $higher['credits'] != '' ? " AND credits>'$higher[credits]'" : '';
$conditions .= $lower['credits'] != '' ? " AND credits<'$lower[credits]'" : '';
$conditions .= $regip != '' ? " AND regip LIKE '$regip%'" : '';
$conditions .= $lastip != '' ? " AND lastip LIKE '$lastip%'" : '';
$conditions .= $regdatebefore != '' ? " AND regdate<'".strtotime($regdatebefore)."'" : '';
$conditions .= $regdateafter != '' ? " AND regdate>'".strtotime($regdateafter)."'" : '';
$conditions .= $lastvisitafter != '' ? " AND lastvisit>'".strtotime($lastvisitafter)."'" : '';
$conditions .= $lastvisitbefore != '' ? " AND lastvisit<'".strtotime($lastvisitbefore)."'" : '';
$conditions .= $lastpostafter != '' ? " AND lastpost>'".strtotime($lastpostafter)."'" : '';
$conditions .= $lastpostbefore != '' ? " AND lastpost<'".strtotime($lastpostbefore)."'" : '';
$conditions .= $birthyear != '' || $birthmonth != '' || $birthday != '' ? " AND bday LIKE '".(($birthyear ? $birthyear : '%').'-'.($birthmonth? $birthmonth : '%').'-'.($birthday ? $birthday : '%'))."'" : '';
$conditions .= $operation == 'newsletter' && (submitcheck('submit') || submitcheck('sendsubmit', 1) || submitcheck('newslettersubmit', 1)) ? " AND newsletter='1'" : '';
if(!$conditions && !$uidarray && $operation == 'clean') {
cpmsg('members_search_invalid', '', 'error');
} else {
$conditions = '1'.$conditions;
}
$urladd = "&username=".rawurlencode($username)."&uid=".intval($uid)."&srchemail=".rawurlencode($srchemail)."®datebefore=".rawurlencode($regdatebefore)."®dateafter=".rawurlencode($regdateafter)."&postshigher=".rawurlencode($postshigher)."&postslower=".rawurlencode($postslower)."®ip=".rawurlencode($regip)."&lastip=".rawurlencode($lastip)."&lastvisitafter=".rawurlencode($lastvisitafter)."&lastvisitbefore=".rawurlencode($lastvisitbefore)."&lastpostafter=".rawurlencode($lastpostafter)."&lastpostbefore=".rawurlencode($lastpostbefore)."&birthyear=".rawurlencode($birthyear)."&birthmonth=".rawurlencode($birthmonth)."&birthday=".rawurlencode($birthday);
if(is_array($usergroupid)) {
foreach($usergroupid as $gid => $value) {
if($value != '') {
$urladd .= '&usergroupid[]='.rawurlencode($value);
}
}
}
foreach(array('lower', 'higher') as $key) {
if(is_array($$key)) {
foreach($$key as $column => $value) {
$urladd .= '&'.$key.'['.$column.']='.rawurlencode($value);
}
}
}
$membernum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}members WHERE $conditions");
}
function shownewsletter() {
extract($GLOBALS, EXTR_SKIP);
$subject = $message = '';
if($settings = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='$variable'")) {
$settings = unserialize($settings);
$subject = $settings['subject'];
$message = $settings['message'];
}
showtablerow('', array('class="th11"', 'class="longtxt"'), array(
$lang['members_newsletter_subject'],
'<input type="text" class="txt" name="subject" size="80" value='.dhtmlspecialchars($subject).'>'
));
showtablerow('', array('class="th12"', ''), array(
$lang['members_newsletter_message'],
'<textarea name="message" class="tarea" cols="80" rows="10">'.dhtmlspecialchars($message).'</textarea>'
));
showtablerow('', array('', 'class="td12"'), array(
'',
'<ul><li><input class="radio" type="radio" value="email" name="sendvia" id="viaemail" /><label for="viaemail"> '.$lang['email'].'</label></li><li><input class="radio" type="radio" value="pm" checked="checked" name="sendvia" id="viapm" /><label for="viapm"> '.$lang['pm'].'</label></li><li><span class="diffcolor2">'.$lang['members_newsletter_num'].'</span><input type="text" class="txt" name="pertask" value="100" size="10"></li></ul>'
));
}
function notifymembers($operation, $variable) {
extract($GLOBALS, EXTR_SKIP);
if(!empty($current)) {
$subject = $message = '';
if($settings = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='$variable'")) {
$settings = unserialize($settings);
$subject = $settings['subject'];
$message = $settings['message'];
}
} else {
$current = 0;
$subject = trim($subject);
$message = trim(str_replace("\t", ' ', $message));
if($notifymembers && !($subject && $message)) {
cpmsg('members_newsletter_sm_invalid', '', 'error');
}
if($operation == 'reward') {
$updatesql = '';
if($updatecredittype == 0) {
if(is_array($addextcredits) && !empty($addextcredits)) {
foreach($addextcredits as $key => $value) {
$value = intval($value);
if(isset($extcredits[$key]) && !empty($value)) {
$updatesql .= ", extcredits{$key}=extcredits{$key}+($value)";
}
}
}
} else {
if(is_array($resetextcredits) && !empty($resetextcredits)) {
foreach($resetextcredits as $key => $value) {
$value = intval($value);
if(isset($extcredits[$key]) && !empty($value)) {
$updatesql .= ", extcredits{$key}=0";
}
}
}
}
if(!empty($updatesql)) {
$db->query("UPDATE {$tablepre}members set uid=uid $updatesql WHERE $conditions", 'UNBUFFTERED');
} else {
cpmsg('members_reward_invalid', '', 'error');
}
if(!$notifymembers) {
cpmsg('members_reward_succeed', '', 'succeed');
}
} elseif ($operation == 'confermedal') {
$medals = $_POST['medals'];
if(!empty($medals)) {
$medalids = $comma = '';
foreach($medals as $key=> $medalid) {
$medalids .= "$comma'$key'";
$comma = ',';
}
$medalsnew = $comma = '';
$medalsnewarray = $medalidarray = array();
$query = $db->query("SELECT medalid, expiration FROM {$tablepre}medals WHERE medalid IN ($medalids)");
while($medal = $db->fetch_array($query)) {
$medal['status'] = empty($medal['expiration']) ? 0 : 1;
$medal['expiration'] = empty($medal['expiration'])? 0 : $timestamp + $medal['expiration'] * 86400;
$medal['medal'] = $medal['medalid'].(empty($medal['expiration']) ? '' : '|'.$medal['expiration']);
$medalsnew .= $comma.$medal['medal'];
$medalsnewarray[] = $medal;
$medalidarray[] = $medal['medalid'];
$comma = "\t";
}
$uids = array();
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE $conditions");
while ($medaluid = $db->fetch_array($query)) {
$uids[] = $medaluid['uid'];
}
$query = $db->query("SELECT uid, medals FROM {$tablepre}memberfields WHERE uid IN (".implode(',', $uids).")");
while($medalnew = $db->fetch_array($query)) {
$addmedalnew = '';
if(empty($medalnew['medals'])) {
$addmedalnew = $medalsnew;
} else {
foreach($medalidarray as $medalid) {
if(!in_array($medalid, explode("\t", $medalnew['medals']))){
$addmedalnew .= $medalid."\t";
}
}
$addmedalnew .= $medalnew['medals'];
}
$db->query("UPDATE {$tablepre}memberfields SET medals='".$addmedalnew."' WHERE uid='".$medalnew['uid']."'", 'UNBUFFTERED');
foreach($medalsnewarray as $medalnewarray) {
$db->query("INSERT INTO {$tablepre}medallog (uid, medalid, type, dateline, expiration, status) VALUES ('".$medalnew['uid']."', '".$medalnewarray['medalid']."', '0', '$timestamp', '".$medalnewarray['expiration']."', '".$medalnewarray['status']."')");
}
}
}
if(!$notifymembers) {
cpmsg('members_confermedal_succeed', '', 'succeed');
}
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('$variable', '".
addslashes(serialize(array('subject' => $subject, 'message' => $message)))."')");
}
$pertask = intval($pertask);
$current = intval($current);
$continue = FALSE;
if(in_array($sendvia, array('pm', 'email'))) {
$query = $db->query("SELECT uid, username, groupid, email FROM {$tablepre}members WHERE $conditions LIMIT $current, $pertask");
while($member = $db->fetch_array($query)) {
$sendvia == 'pm' ? sendpm($member['uid'], $subject, $message, 0) : sendmail("$member[username] <$member[email]>", $subject, $message);
$continue = TRUE;
}
}
if($continue) {
$next = $current + $pertask;
eval("\$lang[members_newsletter_processing] = \"".$lang['members_newsletter_processing']."\";");
cpmsg("$lang[members_newsletter_send]: $lang[members_newsletter_processing]", "$BASESCRIPT?action=members&operation=$operation&{$operation}submit=yes¤t=$next&pertask=$pertask&sendvia=".rawurlencode($sendvia).$urladd, 'loading');
} else {
cpmsg('members'.($operation ? '_'.$operation : '').'_notify_succeed', '', 'succeed');
}
}
function banlog($username, $origgroupid, $newgroupid, $expiration, $reason) {
global $discuz_userss, $groupid, $onlineip, $timestamp, $forum, $reason;
writelog('banlog', dhtmlspecialchars("$timestamp\t$discuz_userss\t$groupid\t$onlineip\t$username\t$origgroupid\t$newgroupid\t$expiration\t$reason"));
}
function selectday($varname, $dayarray) {
global $timestamp, $dateformat, $timeformat, $timeoffset, $lang;
$selectday = '<select name="'.$varname.'">';
if($dayarray && is_array($dayarray)) {
foreach($dayarray as $day) {
$langday = $day.'_day';
$daydate = $day ? '('.gmdate("$dateformat $timeformat", ($timestamp + $day * 86400) + $timeoffset * 3600).')' : '';
$selectday .= '<option value='.$day.'>'.$lang[$langday].' '.$daydate.'</option>';
}
}
$selectday .= '</select>';
return $selectday;
}
function accessimg($access) {
return $access == -1 ? '<img src="images/common/access_disallow.gif" />' :
($access == 1 ? '<img src="images/common/access_allow.gif" />' : '<img src="images/common/access_normal.gif" />');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/members.inc.php
|
PHP
|
asf20
| 78,458
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: magics.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$operation = $operation ? $operation : 'admin';
if($operation == 'admin') {
if(!submitcheck('magicsubmit')) {
shownav('extended', 'magics', 'admin');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 0),
array('admin', 'magics&operation=admin', 1),
array('nav_magics_market', 'magics&operation=market', 0)
));
showtips('magics_tips');
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,''],
[1,'<input type="text" class="txt" size="3" name="newdisplayorder[]">'],
[1,''],
[1,'<input type="text" class="txt" size="10" name="newname[]">'],
[1,'<input type="text" class="txt" size="25" name="newdescription[]">'],
[1,'<input type="text" class="txt" size="5" name="newprice[]">'],
[1,'<input type="text" class="txt" size="5" name="newnum[]">'],
[1,'<select name="newtype[]"><option value="1" selected>$lang[magics_type_1]</option><option value="2">$lang[magics_type_2]</option><option value="3">$lang[magics_type_3]</option></select>'],
[1,'<input type="text" class="txt" size="5" name="newidentifier[]">'],
[1,'']
]
];
</script>
EOT;
showformheader('magics&operation=admin');
showtableheader('magics_edit');
showsubtitle(array('', 'display_order', 'available', 'name', 'description', 'price', 'num', 'type', 'magics_identifier'));
$magiclist = '';
$addtype = $typeid ? "WHERE type='".intval($typeid)."'" : '';
$query = $db->query("SELECT * FROM {$tablepre}magics $addtype ORDER BY displayorder");
while($magic = $db->fetch_array($query)) {
$magictype = $lang['magics_type_'.$magic['type']];
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td28"', '', 'class="td28"', 'class="td28"', 'class="td23"', 'class="td25"', 'class="td25"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$magic[magicid]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$magic[magicid]]\" value=\"$magic[displayorder]\">",
"<input type=\"checkbox\" class=\"checkbox\" name=\"available[$magic[magicid]]\" value=\"1\" ".(!$magic['name'] || !$magic['identifier'] || !$magic['filename'] ? 'disabled' : ($magic['available'] ? 'checked' : '')).">",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"name[$magic[magicid]]\" value=\"$magic[name]\">",
"<input type=\"text\" class=\"txt\" size=\"25\" name=\"description[$magic[magicid]]\" value=\"$magic[description]\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"price[$magic[magicid]]\" value=\"$magic[price]\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"num[$magic[magicid]]\" value=\"$magic[num]\">",
"<a href=\"$BASESCRIPT?action=magics&operation=admin&typeid=$magic[type]\">$magictype</a>",
"<input type=\"hidden\" name=\"identifier[$magic[magicid]]\" value=\"$magic[identifier]\">$magic[identifier]",
"<a href=\"$BASESCRIPT?action=magics&operation=edit&magicid=$magic[magicid]\" class=\"act\">$lang[detail]</a>"
));
}
echo '<tr><td></td><td colspan="9"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['magics_add'].'</a></div></td></tr>';
showsubmit('magicsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}magics WHERE magicid IN ($ids)");
$db->query("DELETE FROM {$tablepre}membermagics WHERE magicid IN ($ids)");
$db->query("DELETE FROM {$tablepre}magicmarket WHERE magicid IN ($ids)");
$db->query("DELETE FROM {$tablepre}magiclog WHERE magicid IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}magics SET available='$available[$id]', name='$name[$id]', identifier='$identifier[$id]', description='$description[$id]', displayorder='$displayorder[$id]', price='$price[$id]', num='$num[$id]' WHERE magicid='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
$value = dhtmlspecialchars(trim($value));
$newidentifier = dhtmlspecialchars(trim(strtoupper($newidentifier[$key])));
if($value) {
$query = $db->query("SELECT magicid FROM {$tablepre}magics WHERE identifier='$newidentifier[$key]'");
if($db->num_rows($query)) {
cpmsg('magics_identifier_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}magics (type, name, identifier, description, displayorder, price, num) VALUES ('$newtype[$key]', '$value', '$newidentifier', '$newdescription[$key]', '$newdisplayorder[$key]', '$newprice[$key]', '$newnum[$key]')");
}
}
}
updatecache('magics');
cpmsg('magics_data_succeed', $BASESCRIPT.'?action=magics&operation=admin', 'succeed');
}
} elseif($operation == 'config') {
if(!submitcheck('magicsubmit')) {
$settings = array();
$query = $db->query("SELECT variable, value FROM {$tablepre}settings WHERE variable IN ('magicstatus', 'magicmarket', 'maxmagicprice', 'magicdiscount')");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
shownav('extended', 'magics', 'config');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 1),
array('admin', 'magics&operation=admin', 0),
array('nav_magics_market', 'magics&operation=market', 0)
));
showformheader('magics&operation=config');
showtableheader();
showsetting('magics_config_open', 'settingsnew[magicstatus]', $settings['magicstatus'], 'radio');
showsetting('magics_config_market_open', 'settingsnew[magicmarket]', $settings['magicmarket'], 'radio');
showsetting('magics_config_market_percent', 'settingsnew[maxmagicprice]', $settings['maxmagicprice'], 'text');
showsetting('magics_config_discount', 'settingsnew[magicdiscount]', $settings['magicdiscount'], 'text');
showtablerow('', 'colspan="2"', '<input type="submit" class="btn" name="magicsubmit" value="'.$lang['submit'].'" />');
showtablefooter();
showformfooter();
} else {
if(is_array($settingsnew)) {
foreach($settingsnew as $variable => $value) {
$db->query("UPDATE {$tablepre}settings SET value='$value' WHERE variable='$variable'");
}
}
updatecache('settings');
cpmsg('magics_config_succeed', $BASESCRIPT.'?action=magics&operation=config', 'succeed');
}
} elseif($operation == 'edit') {
if(!submitcheck('magiceditsubmit')) {
$magicid = intval($magicid);
$magic = $db->fetch_first("SELECT * FROM {$tablepre}magics WHERE magicid='$magicid'");
$magicperm = unserialize($magic['magicperm']);
$groups = $fourms = array();
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$groups[$group['groupid']] = $group['grouptitle'];
}
$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE type NOT IN ('group') AND status>0");
while($forum = $db->fetch_array($query)) {
$forums[$forum['fid']] = $forum['name'];
}
$typeselect = array($magic['type'] => 'selected');
shownav('extended', 'magics', 'admin');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 0),
array('admin', 'magics&operation=admin', 1),
array('nav_magics_market', 'magics&operation=market', 0)
));
showtips('magics_edit_tips');
showformheader('magics&operation=edit&magicid='.$magicid);
showtableheader();
showtitle($lang['magics_edit'].' - '.$magic['name']);
showsetting('magics_edit_name', 'namenew', $magic['name'], 'text');
showsetting('magics_edit_identifier', 'identifiernew', $magic['identifier'], 'text');
showsetting('magics_edit_type', '', '', '<select name="typenew"><option value="1" '.$typeselect[1].'>'.$lang['magics_type_1'].'</option><option value="2" '.$typeselect[2].'>'.$lang['magics_type_2'].'</option><option value="3" '.$typeselect[3].'>'.$lang['magics_type_3'].'</option></select>');
showsetting('magics_edit_price', 'pricenew', $magic['price'], 'text');
showsetting('magics_edit_num', 'numnew', $magic['num'], 'text');
showsetting('magics_edit_weight', 'weightnew', $magic['weight'], 'text');
showsetting('magics_edit_supplytype', array('supplytypenew', array(
array(0, $lang['magics_goods_stack_none']),
array(1, $lang['magics_goods_stack_day']),
array(2, $lang['magics_goods_stack_week']),
array(3, $lang['magics_goods_stack_month']),
)), $magic['supplytype'], 'mradio');
showsetting('magics_edit_supplynum', 'supplynumnew', $magic['supplynum'], 'text');
showsetting('magics_edit_filename', 'filenamenew', $magic['filename'], 'text');
showsetting('magics_edit_description', 'descriptionnew', $magic['description'], 'textarea');
showtitle('magics_edit_perm');
showtablerow('', 'class="td27"', $lang['magics_edit_usergroupperm'].':<input class="checkbox" type="checkbox" name="chkall1" onclick="checkAll(\'prefix\', this.form, \'usergroupsperm\', \'chkall1\', true)" id="chkall1" /><label for="chkall1"> '.lang('select_all').'</label>');
showtablerow('', 'colspan="2"', mcheckbox('usergroupsperm', $groups, explode("\t", $magicperm['usergroups'])));
if($magic['type'] == 2 || $magic['type'] == 3) {
showtablerow('', 'class="td27"', $lang['magics_edit_targetgroupperm'].':<input class="checkbox" type="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'targetgroupsperm\', \'chkall2\', true)" id="chkall2" /><label for="chkall2"> '.lang('select_all').'</label>');
showtablerow('', 'colspan="2"', mcheckbox('targetgroupsperm', $groups, explode("\t", $magicperm['targetgroups'])));
}
if($magic['type'] == 1) {
showtablerow('', 'class="td27"', $lang['magics_edit_forumperm'].':<input class="checkbox" type="checkbox" name="chkall3" onclick="checkAll(\'prefix\', this.form, \'forumperm\', \'chkall3\', true)" id="chkall3" /><label for="chkall3"> '.lang('select_all').'</label>');
showtablerow('', 'colspan="2"', mcheckbox('forumperm', $forums, explode("\t", $magicperm['forum'])));
}
showsubmit('magiceditsubmit');
showtablefooter();
showformfooter();
} else {
$namenew = dhtmlspecialchars(trim($namenew));
$identifiernew = dhtmlspecialchars(trim(strtoupper($identifiernew)));
$descriptionnew = dhtmlspecialchars($descriptionnew);
$filenamenew = dhtmlspecialchars($filenamenew);
$typenew = ($typenew > 0 && $typenew <= 3) ? $typenew : 1;
$availablenew = !$identifiernew || !$filenamenew ? 0 : 1;
$magicperm['usergroups'] = is_array($usergroupsperm) && !empty($usergroupsperm) ? "\t".implode("\t",$usergroupsperm)."\t" : '';
$magicperm['targetgroups'] = is_array($targetgroupsperm) && !empty($targetgroupsperm) ? "\t".implode("\t",$targetgroupsperm)."\t" : '';
$magicperm['forum'] = is_array($forumperm) && !empty($forumperm) ? "\t".implode("\t",$forumperm)."\t" : '';
$magicpermnew = addslashes(serialize($magicperm));
$supplytypenew = intval($supplytypenew);
$supplynumnew = $supplytypenew ? intval($supplynumnew) : 0;
if(!$namenew) {
cpmsg('magics_parameter_invalid', '', 'error');
}
$query = $db->query("SELECT magicid FROM {$tablepre}magics WHERE identifier='$identifiernew' AND magicid!='$magicid'");
if($db->num_rows($query)) {
cpmsg('magics_identifier_invalid', '', 'error');
}
if(preg_match("/[\\\\\/\:\*\?\"\<\>\|]+/", $filenamenew)) {
cpmsg('magics_filename_illegal', '', 'error');
} elseif(!is_readable(DISCUZ_ROOT.($magicfile = "./include/magic/$filenamenew"))) {
cpmsg('magics_filename_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}magics SET available='$availablenew', type='$typenew', name='$namenew', identifier='$identifiernew', description='$descriptionnew', price='$pricenew', num='$numnew', supplytype='$supplytypenew', supplynum='$supplynumnew', weight='$weightnew', filename='$filenamenew', magicperm='$magicpermnew' WHERE magicid='$magicid'");
updatecache('magics');
cpmsg('magics_data_succeed', $BASESCRIPT.'?action=magics&operation=admin', 'succeed');
}
} elseif($operation == 'market') {
if(!submitcheck('marketsubmit')) {
shownav('extended', 'magics', 'nav_magics_market');
showsubmenu('nav_magics', array(
array('config', 'magics&operation=config', 0),
array('admin', 'magics&operation=admin', 0),
array('nav_magics_market', 'magics&operation=market', 1)
));
showformheader('magics&operation=market');
showtableheader('magics_market');
showsubtitle(array('', 'name', 'description', 'magics_market_seller', 'price', 'num', 'weight'));
$marketlist = '';
$query = $db->query("SELECT ma.*, m.name, m.description, m.weight FROM {$tablepre}magicmarket ma, {$tablepre}magics m WHERE m.magicid=ma.magicid");
while($market = $db->fetch_array($query)) {
$market['weight'] = $market['weight'] * $market['num'];
showtablerow('', array('class="td25"', 'class="bold"', '', 'class="td28"', 'class="td28"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$market[mid]\">",
$market[name],
$market[description],
$market[username],
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"price[$market[mid]]\" value=\"$market[price]\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"num[$market[mid]]\" value=\"$market[num]\">",
$market[weight]
));
}
showsubmit('marketsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}magicmarket WHERE mid IN ($ids)");
}
if(is_array($price)) {
foreach($price as $id => $val) {
$db->query("UPDATE {$tablepre}magicmarket SET price='$price[$id]', num='$num[$id]' WHERE mid='$id'");
}
}
cpmsg('magics_data_succeed', $BASESCRIPT.'?action=magics&operation=market', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/magics.inc.php
|
PHP
|
asf20
| 14,347
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tradelog.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./include/trade.func.php';
include_once language('misc');
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$filter = !isset($filter) ? -1 : $filter;
$sqlfilter = $filter >= 0 ? "WHERE status='$filter'" : '';
$count = $db->fetch_first("SELECT sum(price) AS pricesum, sum(tax) AS taxsum FROM {$tablepre}tradelog status $sqlfilter");
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}tradelog $sqlfilter");
$multipage = multi($num, $tpp, $page, "$BASESCRIPT?action=tradelog&filter=$filter");
$query = $db->query("SELECT * FROM {$tablepre}tradelog $sqlfilter ORDER BY lastupdate DESC LIMIT $start_limit, $tpp");
shownav('extended', 'nav_ec');
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 0),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 1)
));
showtableheader();
showsubtitle(array('tradelog_trade_no', 'tradelog_trade_name', 'tradelog_buyer', 'tradelog_seller', 'tradelog_money', 'tradelog_fee', 'tradelog_order_status'));
while($tradelog = $db->fetch_array($query)) {
$tradelog['status'] = trade_getstatus($tradelog['status']);
$tradelog['lastupdate'] = gmdate("$dateformat $timeformat", $tradelog['lastupdate'] + $timeoffset * 3600);
$tradelog['tradeno'] = $tradelog['offline'] ? $lang['tradelog_offline'] : $tradelog['tradeno'];
showtablerow('', '', array(
$tradelog['tradeno'],
'<a target="_blank" href="viewthread.php?do=tradeinfo&tid='.$tradelog['tid'].'&pid='.$tradelog['pid'].'">'.$tradelog['subject'].'</a>',
'<a target="_blank" href="space.php?uid='.$tradelog['buyerid'].'">'.$tradelog['buyer'].'</a>',
'<a target="_blank" href="space.php?uid='.$tradelog['sellerid'].'">'.$tradelog['seller'].'</a>',
$tradelog['price'],
$tradelog['tax'],
'<a target="_blank" href="trade.php?orderid='.$tradelog['orderid'].'">'.$tradelog['status'].'<br />'.$tradelog['lastupdate']
));
}
$statusselect = $lang['tradelog_order_status'].': <select onchange="location.href=\''.$BASESCRIPT.'?action=tradelog&filter=\' + this.value"><option value="-1">'.$lang['tradelog_all_order'].'</option>';
$statuss = trade_getstatus(0, -1);
foreach($statuss as $key => $value) {
$statusselect .= "<option value=\"$key\" ".($filter == $key ? 'selected' : '').">$value</option>";
}
$statusselect .= '</select>';
showsubmit('', '', "$lang[tradelog_order_count] $num".($count['pricesum'] ? ", $lang[tradelog_trade_total] $count[pricesum] $lang[rmb_yuan], $lang[tradelog_fee_total] $count[taxsum] $lang[rmb_yuan]" : ''), '', $multipage.$statusselect);
showtablefooter();
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/tradelog.inc.php
|
PHP
|
asf20
| 3,099
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: prune.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$page = max(1, intval($page));
require_once DISCUZ_ROOT.'./include/misc.func.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
if(!submitcheck('prunesubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
if($adminid == 1 || $adminid == 2) {
$forumselect = '<select name="forums"><option value=""> > '.$lang['select'].'</option>'.
'<option value=""> </option>'.forumselect().'</select>';
if($forums) {
$forumselect = preg_replace("/(\<option value=\"$forums\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
}
} else {
$forumselect = $comma = '';
$query = $db->query("SELECT f.name FROM {$tablepre}moderators m, {$tablepre}forums f WHERE m.uid='$discuz_uid' AND m.fid=f.fid");
while($forum = $db->fetch_array($query)) {
$forumselect .= $comma.$forum['name'];
$comma = ', ';
}
$forumselect = $forumselect ? $forumselect : $lang['none'];
}
$starttime = !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $starttime) ? gmdate('Y-n-j', $timestamp + $timeoffset * 3600 - 86400 * 7) : $starttime;
$endtime = $adminid == 3 || !preg_match("/^(0|\d{4}\-\d{1,2}\-\d{1,2})$/", $endtime) ? gmdate('Y-n-j', $timestamp + $timeoffset * 3600) : $endtime;
shownav('topic', 'nav_prune');
showsubmenusteps('nav_prune', array(
array('prune_search', !$searchsubmit),
array('nav_prune', $searchsubmit)
));
showtips('prune_tips');
echo <<<EOT
<script type="text/javascript" src="include/js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('pruneforum').page.value=number;
$('pruneforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'searchposts', !$searchsubmit);
showformheader("prune", '', 'pruneforum');
showhiddenfields(array('page' => $page));
showtableheader();
showsetting('prune_search_detail', 'detail', $detail, 'radio');
showsetting('prune_search_forum', '', '', $forumselect);
showsetting('prune_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
showsetting('prune_search_user', 'users', $users, 'text');
showsetting('prune_search_ip', 'useip', $useip, 'text');
showsetting('prune_search_keyword', 'keywords', $keywords, 'text');
showsetting('prune_search_lengthlimit', 'lengthlimit', $lengthlimit, 'text');
showsubmit('searchsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
$tidsdelete = $pidsdelete = '0';
$pids = authcode($pids, 'DECODE');
$pidsadd = $pids ? 'pid IN ('.$pids.')' : 'pid IN ('.implodeids($pidarray).')';
$query = $db->query("SELECT fid, tid, pid, first, authorid FROM {$tablepre}posts WHERE $pidsadd");
while($post = $db->fetch_array($query)) {
$prune['forums'][] = $post['fid'];
$prune['thread'][$post['tid']]++;
$pidsdelete .= ",$post[pid]";
$tidsdelete .= $post['first'] ? ",$post[tid]" : '';
}
if($pidsdelete) {
require_once DISCUZ_ROOT.'./include/post.func.php';
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE pid IN ($pidsdelete) OR tid IN ($tidsdelete)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if(!$donotupdatemember) {
$postsarray = $tuidarray = $ruidarray = array();
$query1 = $db->query("SELECT pid, first, authorid FROM {$tablepre}posts WHERE pid IN ($pidsdelete)");
$query2 = $db->query("SELECT pid, first, authorid FROM {$tablepre}posts WHERE tid IN ($tidsdelete)");
while(($post = $db->fetch_array($query1)) || ($post = $db->fetch_array($query2))) {
$postsarray[$post['pid']] = $post;
}
foreach($postsarray as $post) {
if($post['first']) {
$tuidarray[] = $post['authorid'];
} else {
$ruidarray[] = $post['authorid'];
}
}
if($tuidarray) {
updatepostcredits('-', $tuidarray, $creditspolicy['post']);
}
if($ruidarray) {
updatepostcredits('-', $ruidarray, $creditspolicy['reply']);
}
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($tidsdelete)");
$deletedthreads = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pidsdelete)");
$deletedposts = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($tidsdelete)");
$deletedposts += $db->affected_rows();
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activities WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activityapplies WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE tid IN ($tidsdelete)", 'UNBUFFERED');
if(count($prunt['thread']) < 50) {
foreach($prune['thread'] as $tid => $decrease) {
updatethreadcount($tid);
}
} else {
$repliesarray = array();
foreach($prune['thread'] as $tid => $decrease) {
$repliesarray[$decrease][] = $tid;
}
foreach($repliesarray as $decrease => $tidarray) {
$db->query("UPDATE {$tablepre}threads SET replies=replies-$decrease WHERE tid IN (".implode(',', $tidarray).")");
}
}
if($globalstick) {
updatecache('globalstick');
}
foreach(array_unique($prune['forums']) as $fid) {
updateforumcount($fid);
}
}
$deletedthreads = intval($deletedthreads);
$deletedposts = intval($deletedposts);
updatemodworks('DLP', $deletedposts);
eval("\$cpmsg = \"".lang('prune_succeed')."\";");
?>
<script type="text/JavaScript">alert('<?=$cpmsg?>');parent.$('pruneforum').searchsubmit.click();</script>
<?
}
if(submitcheck('searchsubmit')) {
$pids = $postcount = '0';
$sql = $error = '';
$keywords = trim($keywords);
$users = trim($users);
if(($starttime == '0' && $endtime == '0') || ($keywords == '' && $useip == '' && $users == '')) {
$error = 'prune_condition_invalid';
}
if($adminid == 1 || $adminid == 2) {
if($forums) {
$sql .= " AND p.fid='$forums'";
}
} else {
$forums = '0';
$query = $db->query("SELECT fid FROM {$tablepre}moderators WHERE uid='$discuz_uid'");
while($forum = $db->fetch_array($query)) {
$forums .= ','.$forum['fid'];
}
$sql .= " AND p.fid IN ($forums)";
}
if($users != '') {
$uids = '-1';
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE username IN ('".str_replace(',', '\',\'', str_replace(' ', '', $users))."')");
while($member = $db->fetch_array($query)) {
$uids .= ",$member[uid]";
}
$sql .= " AND p.authorid IN ($uids)";
}
if($useip != '') {
$sql .= " AND p.useip LIKE '".str_replace('*', '%', $useip)."'";
}
if($keywords != '') {
$sqlkeywords = '';
$or = '';
$keywords = explode(',', str_replace(' ', '', $keywords));
for($i = 0; $i < count($keywords); $i++) {
if(preg_match("/\{(\d+)\}/", $keywords[$i])) {
$keywords[$i] = preg_replace("/\\\{(\d+)\\\}/", ".{0,\\1}", preg_quote($keywords[$i], '/'));
$sqlkeywords .= " $or p.subject REGEXP '".$keywords[$i]."' OR p.message REGEXP '".$keywords[$i]."'";
} else {
$sqlkeywords .= " $or p.subject LIKE '%".$keywords[$i]."%' OR p.message LIKE '%".$keywords[$i]."%'";
}
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
if($lengthlimit != '') {
$lengthlimit = intval($lengthlimit);
$sql .= " AND LENGTH(p.message) < $lengthlimit";
}
if($starttime != '0') {
$starttime = strtotime($starttime);
$sql .= " AND p.dateline>'$starttime'";
}
if($adminid == 1 && $endtime != gmdate('Y-n-j', $timestamp + $timeoffset * 3600)) {
if($endtime != '0') {
$endtime = strtotime($endtime);
$sql .= " AND p.dateline<'$endtime'";
}
} else {
$endtime = $timestamp;
}
if(($adminid == 2 && $endtime - $starttime > 86400 * 16) || ($adminid == 3 && $endtime - $starttime > 86400 * 8)) {
$error = 'prune_mod_range_illegal';
}
if(!$error) {
if($detail) {
$pagetmp = $page;
do{
$query = $db->query("SELECT p.fid, p.tid, p.pid, p.author, p.authorid, p.dateline, t.subject, p.message FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE t.digest>=0 $sql LIMIT ".(($pagetmp - 1) * $ppp).",$ppp");
$pagetmp--;
} while(!$db->num_rows($query) && $pagetmp);
$posts = '';
while($post = $db->fetch_array($query)) {
$post['dateline'] = gmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['subject'] = cutstr($post['subject'], 30);
$post['message'] = dhtmlspecialchars(cutstr($post['message'], 50));
$posts .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"pidarray[]\" value=\"$post[pid]\" checked />",
"<a href=\"redirect.php?goto=findpost&pid=$post[pid]&ptid=$post[tid]\" target=\"_blank\">$post[subject]</a>",
$post['message'],
"<a href=\"forumdisplay.php?fid=$post[fid]\" target=\"_blank\">{$_DCACHE[forums][$post[fid]][name]}</a>",
"<a href=\"space.php?uid=$post[authorid]\" target=\"_blank\">$post[author]</a>",
$post['dateline']
), TRUE);
}
$postcount = $db->result_first("SELECT count(*) FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE t.digest>=0 $sql");
$multi = multi($postcount, $ppp, $page, "$BASESCRIPT?action=prune");
$multi = preg_replace("/href=\"$BASESCRIPT\?action=prune&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location=$BASESCRIPT.'?action=prune&page='+this.value", "page(this.value)", $multi);
} else {
$postcount = 0;
$query = $db->query("SELECT pid FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE t.digest>=0 $sql");
while($post = $db->fetch_array($query)) {
$pids .= ','.$post['pid'];
$postcount++;
}
$multi = '';
}
if(!$postcount) {
$error = 'prune_post_nonexistence';
}
}
showtagheader('div', 'postlist', $searchsubmit);
showformheader('prune&frame=no', 'target="pruneframe"');
showhiddenfields(array('pids' => authcode($pids, 'ENCODE')));
showtableheader(lang('prune_result').' '.$postcount.' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';" class="act lightlink normal">'.lang('research').'</a>', 'fixpadding');
if($error) {
echo "<tr><td class=\"lineheight\">$lang[$error]</td></tr>";
} else {
if($detail) {
showsubtitle(array('', 'subject', 'message', 'forum', 'author', 'time'));
echo $posts;
}
}
showsubmit('prunesubmit', 'submit', $detail ? 'del' : '', '<input class="checkbox" type="checkbox" name="donotupdatemember" id="donotupdatemember" value="1" checked="checked" /><label for="donotupdatemember"> '.lang('prune_no_update_member').'</label>', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="pruneframe" style="display:none"></iframe>';
showtagfooter('div');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/prune.inc.php
|
PHP
|
asf20
| 12,041
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: ranks.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!submitcheck('ranksubmit')) {
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" size="12" name="newranktitle[]">'],
[1,'<input type="text" class="txt" size="6" name="newpostshigher[]">'],
[1,'<input type="text" class="txt" size="2" name="newstars[]">', 'td28'],
[1,'<input type="text" class="txt" size="6" name="newcolor[]">']
]
];
</script>
EOT;
shownav('user', 'nav_ranks');
showsubmenu('nav_ranks');
showtips('ranks_tips');
showformheader('ranks');
showtableheader();
showsubtitle(array('', 'ranks_title', 'ranks_postshigher', 'ranks_stars', 'ranks_color'));
$query = $db->query("SELECT * FROM {$tablepre}ranks ORDER BY postshigher");
while($rank = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', '', '', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[{$rank[rankid]}]\" value=\"$rank[rankid]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"ranktitlenew[{$rank[rankid]}]\" value=\"$rank[ranktitle]\">",
"<input type=\"text\" class=\"txt\" size=\"6\" name=\"postshighernew[{$rank[rankid]}]\" value=\"$rank[postshigher]\">",
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"starsnew[{$rank[rankid]}]\" value=\"$rank[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"colornew[{$rank[rankid]}]\" value=\"$rank[color]\">",
));
}
echo '<tr><td></td><td colspan="4"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['usergroups_level_add'].'</a></div></td></tr>';
showsubmit('ranksubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($delete) {
$ids = implode('\',\'', $delete);
$db->query("DELETE FROM {$tablepre}ranks WHERE rankid IN ('$ids')");
}
foreach($ranktitlenew as $id => $value) {
$db->query("UPDATE {$tablepre}ranks SET ranktitle='$ranktitlenew[$id]', postshigher='$postshighernew[$id]', stars='$starsnew[$id]', color='$colornew[$id]' WHERE rankid='$id'");
}
if(is_array($newranktitle)) {
foreach($newranktitle as $key => $value) {
if($value = trim($value)) {
$db->query("INSERT INTO {$tablepre}ranks (ranktitle, postshigher, stars, color)
VALUES ('$value', '$newpostshigher[$key]', '$newstars[$key]', '$newcolor[$key]')");
}
}
}
updatecache('ranks');
cpmsg('ranks_succeed', $BASESCRIPT.'?action=ranks', 'succeed');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/ranks.inc.php
|
PHP
|
asf20
| 2,756
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: main.inc.php 17386 2008-12-17 05:10:00Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
include language('admincp.menu');
$lang = array_merge($lang, $menulang);
echo <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>Discuz! Administrator's Control Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=$charset">
<meta content="Comsenz Inc." name="Copyright" />
<link rel="stylesheet" href="images/admincp/admincp.css" type="text/css" media="all" />
<script src="include/js/common.js" type="text/javascript"></script>
</head>
<body style="margin: 0px" scroll="no">
<div id="append_parent"></div>
<table cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td colspan="2" height="90">
<div class="mainhd">
<div class="logo">Discuz! Administrator's Control Panel</div>
<div class="uinfo">
<p>$lang[header_welcome], <em>$discuz_userss</em> [ <a href="$BASESCRIPT?action=logout&sid=$sid" target="_top">$lang[header_logout]</a> ]</p>
<p class="btnlink"><a href="$indexname" target="_blank">$lang[header_bbs]</a></p>
</div>
<div class="navbg"></div>
<div class="nav">
<ul id="topmenu">
EOT;
showheader('index', 'home');
showheader('global', 'settings&operation=basic');
showheader('style', 'settings&operation=styles');
showheader('forum', 'forums');
showheader('user', 'members');
showheader('topic', 'moderate&operation=threads');
showheader('extended', 'tasks');
showheader('adv', 'adv');
showheader('tool','tools&operation=updatecache');
if($isfounder) {
echo '<li><em><a id="header_uc" hidefocus="true" href="'.UC_API.'/admin.php?m=frame&a=main&iframe=1" onclick="javascript:uc_login=1;toggleMenu(\'uc\', \'\');" target="main">'.$lang['header_uc'].'</a></em></li>';
}
echo <<<EOT
</ul>
<div class="currentloca">
<p id="admincpnav"></p>
</div>
<div class="navbd"></div>
<div class="sitemapbtn">
<div style="float: left; margin:-5px 10px 0 0"><form name="search" method="post" action="$BASESCRIPT?action=search" target="main"><input type="text" name="keywords" value="" class="txt" /> <input type="hidden" name="searchsubmit" value="yes" class="btn" /><input type="submit" name="searchsubmit" value="$lang[search]" class="btn" style="margin-top: 5px;vertical-align:middle" /></form></div>
<span id="add2custom"></span>
<a href="###" id="cpmap" onclick="showMap();return false;"><img src="images/admincp/btn_map.gif" title="$lang[admincp_sitemap]" width="72" height="18" /></a>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td valign="top" width="160" class="menutd">
<div id="leftmenu" class="menu">
EOT;
require_once DISCUZ_ROOT.'./admin/menu.inc.php';
$uc_api_url = UC_API;
$ucadd = $isfounder ? ", 'uc'" : '';
echo <<<EOT
</div>
</td>
<td valign="top" width="100%"class="mask"><iframe src="$BASESCRIPT?$extra&sid=$sid" name="main" width="100%" height="100%" frameborder="0"scrolling="yes" style="overflow: visible;"></iframe></td>
</tr>
</table>
<div class="copyright">
<p>Powered by <a href="http://www.discuz.net/" target="_blank">Discuz!</a> $version</p>
<p>© 2001-2009, <a href="http://www.comsenz.com/" target="_blank">Comsenz Inc.</a></p>
</div>
<div id="cpmap_menu" class="custom" style="display:none">
<div class="cside">
<h3><span class="ctitle1">$lang[custommenu]</span><a href="javascript:;" onclick="toggleMenu('tool', 'misc&operation=custommenu');hideMenu();" class="cadmin">$lang[admin]</a></h3>
<ul class="cslist" id="custommenu"></ul>
</div>
<div class="cmain" id="cmain"></div>
<div class="cfixbd"></div>
</div>
<script type="text/JavaScript">
var headers = new Array('index', 'global', 'style', 'forum', 'user', 'topic', 'extended', 'adv', 'tool'$ucadd);
var admincpfilename = '$BASESCRIPT';
function toggleMenu(key, url) {
if(key == 'index' && url == 'home') {
if(is_ie) {
doane(event);
}
parent.location.href = admincpfilename + '?frames=yes';
return false;
}
for(var k in headers) {
if($('menu_' + headers[k])) {
$('menu_' + headers[k]).style.display = headers[k] == key ? '' : 'none';
}
}
var lis = $('topmenu').getElementsByTagName('li');
for(var i = 0; i < lis.length; i++) {
if(lis[i].className == 'navon') lis[i].className = '';
}
$('header_' + key).parentNode.parentNode.className = 'navon';
if(url) {
parent.main.location = admincpfilename + '?action=' + url;
var hrefs = $('menu_' + key).getElementsByTagName('a');
for(var j = 0; j < hrefs.length; j++) {
hrefs[j].className = hrefs[j].href.substr(hrefs[j].href.indexOf(admincpfilename + '?action=') + 19) == url ? 'tabon' : (hrefs[j].className == 'tabon' ? '' : hrefs[j].className);
}
}
return false;
}
function initCpMenus(menuContainerid) {
var key = '';
var hrefs = $(menuContainerid).getElementsByTagName('a');
for(var i = 0; i < hrefs.length; i++) {
if(menuContainerid == 'leftmenu' && !key && '$extra'.indexOf(hrefs[i].href.substr(hrefs[i].href.indexOf(admincpfilename + '?action=') + 12)) != -1) {
key = hrefs[i].parentNode.parentNode.id.substr(5);
hrefs[i].className = 'tabon';
}
if(!hrefs[i].getAttribute('ajaxtarget')) hrefs[i].onclick = function() {
if(menuContainerid != 'custommenu') {
var lis = $(menuContainerid).getElementsByTagName('li');
for(var k = 0; k < lis.length; k++) {
if(lis[k].firstChild.className != 'menulink') lis[k].firstChild.className = '';
}
if(this.className == '') this.className = menuContainerid == 'leftmenu' ? 'tabon' : 'bold';
}
if(menuContainerid != 'leftmenu') {
var hk, currentkey;
var leftmenus = $('leftmenu').getElementsByTagName('a');
for(var j = 0; j < leftmenus.length; j++) {
hk = leftmenus[j].parentNode.parentNode.id.substr(5);
if(this.href.indexOf(leftmenus[j].href) != -1) {
leftmenus[j].className = 'tabon';
if(hk != 'index') currentkey = hk;
} else {
leftmenus[j].className = '';
}
}
if(currentkey) toggleMenu(currentkey);
hideMenu();
}
}
}
return key;
}
var header_key = initCpMenus('leftmenu');
toggleMenu(header_key ? header_key : 'index');
function initCpMap() {
var ul, hrefs, s;
s = '<ul class="cnote"><li><img src="images/admincp/btn_map.gif" /></li><li> $lang[custommenu_tips]</li></ul><table class="cmlist" id="mapmenu"><tr>';
for(var k in headers) {
if(headers[k] != 'index' && headers[k] != 'uc') {
s += '<td valign="top"><ul class="cmblock"><li><h4>' + $('header_' + headers[k]).innerHTML + '</h4></li>';
ul = $('menu_' + headers[k]);
hrefs = ul.getElementsByTagName('a');
for(var i = 0; i < hrefs.length; i++) {
s += '<li><a href="' + hrefs[i].href + '" target="' + hrefs[i].target + '" k="' + headers[k] + '">' + hrefs[i].innerHTML + '</a></li>';
}
s += '</ul></td>';
}
}
s += '</tr></table>';
return s;
}
$('cmain').innerHTML = initCpMap();
initCpMenus('mapmenu');
var cmcache = false;
function showMap() {
showMenu('cpmap', true, 3, 3);
if(!cmcache) ajaxget(admincpfilename + '?action=misc&operation=custommenu&' + Math.random(), 'custommenu', '');
}
function resetEscAndF5(e) {
e = e ? e : window.event;
actualCode = e.keyCode ? e.keyCode : e.charCode;
if(actualCode == 27) {
if($('cpmap_menu').style.display == 'none') {
showMap();
} else {
hideMenu();
}
}
if(actualCode == 116 && parent.main) {
parent.main.location.reload();
if(document.all) {
e.keyCode = 0;
e.returnValue = false;
} else {
e.cancelBubble = true;
e.preventDefault();
}
}
}
_attachEvent(document.documentElement, 'keydown', resetEscAndF5);
function uc_left_menu(uc_menu_data) {
var leftmenu = $('menu_uc');
leftmenu.innerHTML = '';
var html_str = '';
for(var i=0;i<uc_menu_data.length;i+=2) {
html_str += '<li><a href="'+uc_menu_data[(i+1)]+'" hidefocus="true" onclick="uc_left_switch(this)" target="main">'+uc_menu_data[i]+'</a></li>';
}
leftmenu.innerHTML = html_str;
toggleMenu('uc', '');
$('admincpnav').innerHTML = 'UCenter';
}
var uc_left_last = null;
function uc_left_switch(obj) {
if(uc_left_last) {
uc_left_last.className = '';
}
obj.className = 'tabon';
uc_left_last = obj;
}
function uc_modify_sid(sid) {
$('header_uc').href = '$uc_api_url/admin.php?m=frame&a=main&iframe=1&sid=' + sid;
}
</script>
</body>
</html>
EOT;
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/main.inc.php
|
PHP
|
asf20
| 8,795
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: attach.inc.php 17404 2008-12-18 02:24:12Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!submitcheck('deletesubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$anchor = in_array($anchor, array('search', 'admin')) ? $anchor : 'search';
shownav('topic', 'nav_attaches');
showsubmenusteps('nav_attaches', array(
array('search', !$searchsubmit),
array('admin', $searchsubmit),
));
showtips('attach_tips', 'attach_tips', $searchsubmit);
showtagheader('div', 'search', !$searchsubmit);
showformheader('attach');
showtableheader();
showsetting('attach_nomatched', 'nomatched', 0, 'radio');
showsetting('attach_forum', '', '', '<select name="inforum"><option value="all"> >'.lang('all').'</option><option value=""> </option>'.forumselect().'</select>');
showsetting('attach_sizerange', array('sizeless', 'sizemore'), array('', ''), 'range');
showsetting('attach_dlcountrange', array('dlcountless', 'dlcountmore'), array('', ''), 'range');
showsetting('attach_daysold', 'daysold', '', 'text');
showsetting('filename', 'filename', '', 'text');
showsetting('attach_keyword', 'keywords', '', 'text');
showsetting('attach_author', 'author', '', 'text');
showsubmit('searchsubmit', 'search');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$sql = "a.pid=p.pid";
$ppp = 100;
if($inforum != 'all') {
$inforum = intval($inforum);
}
$sql .= is_numeric($inforum) ? " AND p.fid='$inforum'" : '';
$sql .= $daysold ? " AND p.dateline<='".($timestamp - (86400 * $daysold))."'" : '';
$sql .= $author ? " AND p.author='$author'" : '';
$sql .= $filename ? " AND a.filename LIKE '%$filename%'" : '';
if($keywords) {
$sqlkeywords = $or = '';
foreach(explode(',', str_replace(' ', '', $keywords)) as $keyword) {
$sqlkeywords .= " $or a.description LIKE '%$keyword%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
$sql .= $sizeless ? " AND a.filesize<'$sizeless'" : '';
$sql .= $sizemore ? " AND a.filesize>'$sizemore' " : '';
$sql .= $dlcountless ? " AND a.downloads<'$dlcountless'" : '';
$sql .= $dlcountmore ? " AND a.downloads>'$dlcountmore'" : '';
$attachments = '';
$page = max(1, intval($page));
$query = $db->query("SELECT a.*, p.fid, p.author, t.tid, t.tid, t.subject, f.name AS fname
FROM {$tablepre}attachments a, {$tablepre}posts p, {$tablepre}threads t, {$tablepre}forums f
WHERE t.tid=a.tid AND f.fid=p.fid AND t.displayorder>='0' AND p.invisible='0' AND $sql LIMIT ".(($page - 1) * $ppp).','.$ppp);
while($attachment = $db->fetch_array($query)) {
if(!$attachment['remote']) {
$matched = file_exists($attachdir.'/'.$attachment['attachment']) ? '' : lang('attach_lost');
$attachment['url'] = $attachurl;
} else {
@set_time_limit(0);
if(@fclose(@fopen($ftp['attachurl'].'/'.$attachment['attachment'], 'r'))) {
$matched = '';
} else {
$matched = lang('attach_lost');
}
$attachment['url'] = $ftp['attachurl'];
}
$attachsize = sizecount($attachment['filesize']);
if(!$nomatched || ($nomatched && $matched)) {
$attachments .= showtablerow('', array('class="td25"', 'title="'.$attachment['description'].'" class="td21"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$attachment[aid]\" />",
$attachment['remote'] ? "<span class=\"diffcolor3\">$attachment[filename]" : $attachment['filename'],
"<a href=\"$attachment[url]/$attachment[attachment]\" class=\"smalltxt\" target=\"_blank\">".cutstr($attachment['attachment'], 30)."</a>",
$attachment['author'],
"<a href=\"viewthread.php?tid=$attachment[tid]\" target=\"_blank\">".cutstr($attachment['subject'], 20)."</a>",
$attachsize,
$attachment['downloads'],
$matched ? "<em class=\"error\">$matched<em>" : "<a href=\"attachment.php?aid=$attachment[aid]&k=".md5($attachment[aid].md5($authkey).$timestamp)."&t=$timestamp&sid=$sid\" target=\"_blank\" class=\"act nomargin\">$lang[download]</a>"
), TRUE);
}
}
$attachmentcount = $db->result_first("SELECT count(*) FROM {$tablepre}attachments a, {$tablepre}posts p, {$tablepre}threads t, {$tablepre}forums f
WHERE t.tid=a.tid AND f.fid=p.fid AND t.displayorder>='0' AND p.invisible='0' AND $sql");
$multipage = multi($attachmentcount, $ppp, $page, "$BASESCRIPT?action=attachments");
$multipage = preg_replace("/href=\"$BASESCRIPT\?action=attachments&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multipage);
$multipage = str_replace("window.location=$BASESCRIPT.'?action=attachments&page='+this.value", "page(this.value)", $multipage);
echo <<<EOT
<script type="text/JavaScript">
function page(number) {
$('attachmentforum').page.value=number;
$('attachmentforum').searchsubmit.click();
}
</script>
EOT;
showtagheader('div', 'admin', $searchsubmit);
showformheader('attach', '', 'attachmentforum');
showhiddenfields(array(
'page' => $page,
'nomatched' => $nomatched,
'inforum' => $inforum,
'sizeless' => $sizeless,
'sizemore' => $sizemore,
'dlcountless' => $dlcountless,
'dlcountmore' => $dlcountmore,
'daysold' => $daysold,
'filename' => $filename,
'keywords' => $keywords,
'author' => $author,
));
echo '<input type="submit" name="searchsubmit" value="'.lang('submit').'" class="btn" style="display: none" />';
showformfooter();
showformheader('attach&frame=no', 'target="attachmentframe"');
showtableheader();
showsubtitle(array('', 'filename', 'attach_path', 'author', 'attach_thread', 'size', 'attach_downloadnums', ''));
echo $attachments;
showsubmit('deletesubmit', 'submit', 'del', '<a href="###" onclick="$(\'admin\').style.display=\'none\';$(\'search\').style.display=\'\';" class="act lightlink normal">'.lang('research').'</a>', $multipage);
showtablefooter();
showformfooter();
echo '<iframe name="attachmentframe" style="display:none"></iframe>';
showtagfooter('div');
}
} else {
if($ids = implodeids($delete)) {
$tids = $pids = 0;
$query = $db->query("SELECT tid, pid, attachment, thumb, remote FROM {$tablepre}attachments WHERE aid IN ($ids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
$tids .= ','.$attach['tid'];
$pids .= ','.$attach['pid'];
}
$db->query("DELETE FROM {$tablepre}attachments WHERE aid IN ($ids)");
$attachtids = 0;
$query = $db->query("SELECT tid FROM {$tablepre}attachments WHERE tid IN ($tids) GROUP BY tid ORDER BY pid DESC");
while($attach = $db->fetch_array($query)) {
$attachtids .= ','.$attach['tid'];
}
$db->query("UPDATE {$tablepre}threads SET attachment='0' WHERE tid IN ($tids)".($attachtids ? " AND tid NOT IN ($attachtids)" : NULL));
$attachpids = 0;
$query = $db->query("SELECT pid FROM {$tablepre}attachments WHERE pid IN ($pids) GROUP BY pid ORDER BY pid DESC");
while($attach = $db->fetch_array($query)) {
$attachpids .= ','.$attach['pid'];
}
$db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE pid IN ($pids)".($attachpids ? " AND pid NOT IN ($attachpids)" : NULL));
eval("\$cpmsg = \"".lang('attach_edit_succeed')."\";");
} else {
eval("\$cpmsg = \"".lang('attach_edit_invalid')."\";");
}
echo "<script type=\"text/JavaScript\">alert('$cpmsg');parent.\$('attachmentforum').searchsubmit.click();</script>";
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/attach.inc.php
|
PHP
|
asf20
| 7,834
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: admingroups.inc.php 17415 2008-12-19 04:34:58Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(submitcheck('groupsubmit') && $ids = implodeids($delete)) {
$gids = array();
$query = $db->query("SELECT groupid FROM {$tablepre}usergroups WHERE groupid IN ($ids) AND type='special' AND radminid>'0'");
while($g = $db->fetch_array($query)) {
$gids[] = $g['groupid'];
}
if($ids = implodeids($gids)) {
$db->query("DELETE FROM {$tablepre}usergroups WHERE groupid IN ($ids)");
$db->query("DELETE FROM {$tablepre}admingroups WHERE admingid IN ($ids)");
$db->query("DELETE FROM {$tablepre}adminactions WHERE admingid IN ($ids)");
$newgroupid = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditslower>'0' ORDER BY creditslower LIMIT 1");
$db->query("UPDATE {$tablepre}members SET groupid='$newgroupid', adminid='0' WHERE groupid IN ($ids)", 'UNBUFFERED');
deletegroupcache($gids);
}
}
$grouplist = array();
$query = $db->query("SELECT a.*, u.groupid, u.radminid, u.grouptitle, u.stars, u.color, u.groupavatar, u.type FROM {$tablepre}admingroups a
LEFT JOIN {$tablepre}usergroups u ON u.groupid=a.admingid
ORDER BY u.type, u.radminid, a.admingid");
while ($group = $db->fetch_array($query)) {
$grouplist[$group['groupid']] = $group;
}
if(!submitcheck('groupsubmit')) {
shownav('user', 'nav_admingroups');
showsubmenu('nav_admingroups');
showtips('admingroups_tips');
showformheader('admingroups');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'name', 'type', 'admingroups_level', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', '', ''));
foreach ($grouplist as $gid => $group) {
showtablerow('', array('', '', 'class="td25"', '', 'class="td25"'), array(
$group['type'] == 'system' ? '' : "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$group[groupid]\">",
$group['grouptitle'],
$group['type'] == 'system' ? lang('inbuilt') : lang('costom'),
$lang['usergroups_system_'.$group['radminid']],
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_avatar[$group[groupid]]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id={$group[admingid]}&return=admin\">$lang[admingroups_settings_user]</a>",
"<a href=\"$BASESCRIPT?action=admingroups&operation=edit&id=$group[admingid]\">$lang[admingroups_settings_admin]</a>"
));
}
showtablerow('', array('class="td25"', '', '', 'colspan="6"'), array(
lang('add_new'),
'<input type="text" class="txt" size="12" name="grouptitlenew">',
lang('costom'),
"<select name=\"radminidnew\"><option value=\"1\">$lang[usergroups_system_1]</option><option value=\"2\">$lang[usergroups_system_2]</option><option value=\"3\" selected=\"selected\">$lang[usergroups_system_3]</option>",
));
showsubmit('groupsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
foreach ($grouplist as $gid => $group) {
$stars = intval($group_stars[$gid]);
$color = dhtmlspecialchars($group_color[$gid]);
$avatar = dhtmlspecialchars($group_avatar[$gid]);
if($group['color'] != $color || $group['stars'] != $stars || $group['groupavatar'] != $avatar) {
$db->query("UPDATE {$tablepre}usergroups SET stars='$stars', color='$color', groupavatar='$avatar' WHERE groupid='$gid'");
}
}
$grouptitlenew = dhtmlspecialchars(trim($grouptitlenew));
$radminidnew = intval($radminidnew);
if($grouptitlenew && in_array($radminidnew, array(1, 2, 3))) {
$ufields = '';
$usergroup = $db->fetch_first("SELECT * FROM {$tablepre}usergroups WHERE groupid='$radminidnew'");
foreach ($usergroup as $key => $val) {
if(!in_array($key, array('groupid', 'radminid', 'type', 'system', 'grouptitle'))) {
$val = addslashes($val);
$ufields .= ", `$key`='$val'";
}
}
$afields = '';
$admingroup = $db->fetch_first("SELECT * FROM {$tablepre}admingroups WHERE admingid='$radminidnew'");
foreach ($admingroup as $key => $val) {
if(!in_array($key, array('admingid'))) {
$val = addslashes($val);
$afields .= ", `$key`='$val'";
}
}
$db->query("INSERT INTO {$tablepre}usergroups SET radminid='$radminidnew', type='special', grouptitle='$grouptitlenew' $ufields");
if($newgroupid = $db->insert_id()) {
$db->query("REPLACE INTO {$tablepre}admingroups SET admingid='$newgroupid' $afields");
if($radminidnew == 1) {
$dactionarray = array('members_edit', 'members_group', 'db_runquery', 'db_import', 'usergroups', 'admingroups', 'templates', 'plugins');
$db->query("REPLACE INTO {$tablepre}adminactions (admingid, disabledactions)
VALUES ('$newgroupid', '".addslashes(serialize($dactionarray))."')");
}
}
}
cpmsg('admingroups_edit_succeed', $BASESCRIPT.'?action=admingroups', 'succeed');
}
} elseif($operation == 'edit') {
$actionarray = array(
'settings' => array('basic', 'access', 'seo', 'functions', 'permissions', 'credits', 'mail', 'sec', 'datetime', 'attach', 'wap', 'uc', 'uchome'),
'forums' => array('edit', 'moderators', 'delete', 'merge', 'copy'),
'threadtypes' => array(),
'members' => array('add', 'group', 'access', 'credit', 'medal', 'edit', 'ban', 'ipban', 'reward', 'newsletter', 'confermedal', 'clean'),
'profilefields' => array(),
'usergroups' => array(),
'admingroups' => array(),
'ranks' => array(),
'styles' => array(),
'templates' => array('add', 'edit'),
'moderate' => array('members', 'threads', 'replies'),
'threads' => array(),
'prune' => array(),
'recyclebin' => array(),
'announce' => array(),
'smilies' => array(),
'misc' => array('link', 'onlinelist', 'censor', 'bbcode', 'tag', 'icon', 'attachtype', 'cron'),
'adv' => array('config', 'advadd'),
'db' => array('runquery', 'optimize', 'export', 'import', 'dbcheck'),
'tools' => array('updatecache', 'fileperms', 'relatedtag'),
'attach' => array(),
'counter' => array(),
'jswizard' => array(),
'creditwizard' => array(),
'google' => array('config'),
'qihoo' => array('config', 'topics'),
'tasks' => array(),
'ec' => array('alipay', 'orders', 'credit'),
'medals' => array(),
'plugins' => array('config', 'edit', 'hooks', 'vars'),
'logs' => array('illegal', 'rate', 'mods', 'medals', 'ban', 'cp', 'credits', 'error')
);
if(!submitcheck('groupsubmit')) {
$id = isset($id) ? intval($id) : 0;
if(empty($id)) {
$grouplist = "<select name=\"id\" style=\"width: 150px\">\n";
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE radminid>'1' OR (radminid='1' AND type='special')");
while($group = $db->fetch_array($query)) {
$grouplist .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
}
$grouplist .= '</select>';
cpmsg('admingroups_edit_nonexistence', $BASESCRIPT.'?action=admingroups&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $grouplist);
}
$group = $db->fetch_first("SELECT a.*, aa.disabledactions, u.radminid, u.grouptitle FROM {$tablepre}admingroups a
LEFT JOIN {$tablepre}usergroups u ON u.groupid=a.admingid
LEFT JOIN {$tablepre}adminactions aa ON aa.admingid=a.admingid
WHERE a.admingid='$id'");
if(!$group) {
cpmsg('undefined_action', '', 'error');
}
showsubmenu($lang['admingroups_edit'].' - '.$group['grouptitle']);
showformheader("admingroups&operation=edit&id=$id");
showtableheader();
if($group['radminid'] == 1) {
$group['disabledactions'] = $group['disabledactions'] ? unserialize($group['disabledactions']) : array();
foreach($actionarray as $actionstr => $operationstr) {
showsetting('admingroups_edit_action_'.$actionstr, 'disabledactionnew['.$actionstr.']', !in_array($actionstr, $group['disabledactions']), 'radio', $id == 1, $operationstr);
foreach($operationstr as $opstr) {
$str = $actionstr.'_'.$opstr;
showsetting('admingroups_edit_action_'.$str, 'disabledactionnew['.$str.']', !in_array($str, $group['disabledactions']), 'radio', $id == 1);
}
$operationstr && showtagfooter('tbody');
}
} else {
$checkstick = array($group['allowstickthread'] => 'checked');
showsetting('admingroups_edit_edit_post', 'alloweditpostnew', $group['alloweditpost'], 'radio');
showsetting('admingroups_edit_edit_poll', 'alloweditpollnew', $group['alloweditpoll'], 'radio');
showsetting('admingroups_edit_stick_thread', '', '', '<input class="radio" type="radio" name="allowstickthreadnew" value="0" '.$checkstick[0].'> '.$lang['admingroups_edit_stick_thread_none'].'<br /><input class="radio" type="radio" name="allowstickthreadnew" value="1" '.$checkstick[1].'> '.$lang['admingroups_edit_stick_thread_1'].'<br /><input class="radio" type="radio" name="allowstickthreadnew" value="2" '.$checkstick[2].'> '.$lang['admingroups_edit_stick_thread_2'].'<br /><input class="radio" type="radio" name="allowstickthreadnew" value="3" '.$checkstick[3].'> '.$lang['admingroups_edit_stick_thread_3'].'');
showsetting('admingroups_edit_mod_post', 'allowmodpostnew', $group['allowmodpost'], 'radio');
showsetting('admingroups_edit_del_post', 'allowdelpostnew', $group['allowdelpost'], 'radio');
showsetting('admingroups_edit_mass_prune', 'allowmassprunenew', $group['allowmassprune'], 'radio');
showsetting('admingroups_edit_ban_post', 'allowbanpostnew', $group['allowbanpost'], 'radio');
showsetting('admingroups_edit_refund', 'allowrefundnew', $group['allowrefund'], 'radio');
showsetting('admingroups_edit_view_ip', 'allowviewipnew', $group['allowviewip'], 'radio');
showsetting('admingroups_edit_ban_ip', 'allowbanipnew', $group['allowbanip'], 'radio');
showsetting('admingroups_edit_edit_user', 'alloweditusernew', $group['allowedituser'], 'radio');
showsetting('admingroups_edit_mod_user', 'allowmodusernew', $group['allowmoduser'], 'radio');
showsetting('admingroups_edit_ban_user', 'allowbanusernew', $group['allowbanuser'], 'radio');
showsetting('admingroups_edit_post_announce', 'allowpostannouncenew', $group['allowpostannounce'], 'radio');
showsetting('admingroups_edit_disable_postctrl', 'disablepostctrlnew', $group['disablepostctrl'], 'radio');
}
if($id > 1) {
showsubmit('groupsubmit');
}
showtablefooter();
showformfooter();
} else {
$group = $db->fetch_first("SELECT groupid, radminid FROM {$tablepre}usergroups WHERE groupid='$id'");
if(!$group) {
cpmsg('undefined_action', '', 'error');
}
if($group['radminid'] == 1) {
$actions = array();
foreach ($actionarray as $key => $val) {
$actions[] = $key;
if(!empty($val) && is_array($val)) {
foreach ($val as $temp) {
$actions[] = "{$key}_{$temp}";
}
}
}
$dactionarray = array();
if(is_array($disabledactionnew)) {
foreach($disabledactionnew as $key => $value) {
if(in_array($key, $actions) && !$value) {
$dactionarray[] = $key;
}
}
}
$db->query("REPLACE INTO {$tablepre}adminactions (admingid, disabledactions)
VALUES ('$group[groupid]', '".addslashes(serialize($dactionarray))."')");
} else {
$db->query("UPDATE {$tablepre}admingroups SET alloweditpost='$alloweditpostnew', alloweditpoll='$alloweditpollnew',
allowstickthread='$allowstickthreadnew', allowmodpost='$allowmodpostnew', allowbanpost='$allowbanpostnew', allowdelpost='$allowdelpostnew',
allowmassprune='$allowmassprunenew', allowrefund='$allowrefundnew', allowcensorword='$allowcensorwordnew',
allowviewip='$allowviewipnew', allowbanip='$allowbanipnew', allowedituser='$alloweditusernew', allowbanuser='$allowbanusernew',
allowmoduser='$allowmodusernew', allowpostannounce='$allowpostannouncenew', allowviewlog='$allowviewlognew',
disablepostctrl='$disablepostctrlnew' WHERE admingid='$group[groupid]' AND admingid<>'1'");
}
updatecache('usergroups');
updatecache('admingroups');
cpmsg('admingroups_edit_succeed', $BASESCRIPT.'?action=admingroups', 'succeed');
}
}
function deletegroupcache($groupidarray) {
if(!empty($groupidarray) && is_array($groupidarray)) {
foreach ($groupidarray as $id) {
if(is_numeric($id) && $id = intval($id)) {
@unlink(DISCUZ_ROOT.'./forumdata/cache/usergroup_'.$id.'.php');
@unlink(DISCUZ_ROOT.'./forumdata/cache/admingroup_'.$id.'.php');
}
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/admingroups.inc.php
|
PHP
|
asf20
| 13,040
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: quickqueries.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$simplequeries = array(
array('comment' => '快速开启论坛版块功能', 'sql' => ''),
array('comment' => '开启 所有版块 主题回收站', 'sql' => 'UPDATE {tablepre}forums SET recyclebin=\'1\''),
array('comment' => '开启 所有版块 Discuz! 代码”', 'sql' => 'UPDATE {tablepre}forums SET allowbbcode=\'1\''),
array('comment' => '开启 所有版块 [IMG] 代码”', 'sql' => 'UPDATE {tablepre}forums SET allowimgcode=\'1\''),
array('comment' => '开启 所有版块 Smilies 代码', 'sql' => 'UPDATE {tablepre}forums SET allowsmilies=\'1\''),
array('comment' => '开启 所有版块 内容干扰码', 'sql' => 'UPDATE {tablepre}forums SET jammer=\'1\''),
array('comment' => '开启 所有版块 允许匿名发贴”', 'sql' => 'UPDATE {tablepre}forums SET allowanonymous=\'1\''),
array('comment' => '快速关闭论坛版块功能', 'sql' => ''),
array('comment' => '关闭 所有版块 主题回收站', 'sql' => 'UPDATE {tablepre}forums SET recyclebin=\'0\''),
array('comment' => '关闭 所有版块 HTML 代码', 'sql' => 'UPDATE {tablepre}forums SET allowhtml=\'0\''),
array('comment' => '关闭 所有版块 Discuz! 代码', 'sql' => 'UPDATE {tablepre}forums SET allowbbcode=\'0\''),
array('comment' => '关闭 所有版块 [IMG] 代码', 'sql' => 'UPDATE {tablepre}forums SET allowimgcode=\'0\''),
array('comment' => '关闭 所有版块 Smilies 代码', 'sql' => 'UPDATE {tablepre}forums SET allowsmilies=\'0\''),
array('comment' => '关闭 所有版块 内容干扰码', 'sql' => 'UPDATE {tablepre}forums SET jammer=\'0\''),
array('comment' => '关闭 所有版块 允许匿名发贴', 'sql' => 'UPDATE {tablepre}forums SET allowanonymous=\'0\''),
array('comment' => '会员操作相关', 'sql' => ''),
array('comment' => '清除 所有会员 自定义风格', 'sql' => 'UPDATE {tablepre}members SET styleid=\'0\''),
array('comment' => '清空 所有会员 积分交易记录', 'sql' => 'TRUNCATE {tablepre}creditslog;'),
array('comment' => '清空 所有会员 收藏夹', 'sql' => 'TRUNCATE {tablepre}favorites;'),
);
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/quickqueries.inc.php
|
PHP
|
asf20
| 2,372
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: creditwizard.inc.php 17513 2009-01-07 03:54:07Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$step = in_array($step, array(1, 2, 3)) ? $step : 1;
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN ('extcredits', 'initcredits', 'creditspolicy', 'creditsformula', 'creditsformulaexp', 'creditstrans', 'creditstax', 'transfermincredits', 'exchangemincredits', 'maxincperthread', 'maxchargespan')");
while($setting = $db->fetch_array($query)) {
$$setting['variable'] = $setting['value'];
}
$extcredits = unserialize($extcredits);
$initcredits = explode(',', $initcredits);
$creditspolicy = unserialize($creditspolicy);
cpheader();
if($step == 1) {
if($resetcredit >= 1 && $resetcredit <= 8) {
$initcredits[$resetcredit] = intval($initcredits[$resetcredit]);
if(!submitcheck('confirmed')) {
cpmsg('creditwizard_resetusercredit_warning', $BASESCRIPT.'?action=creditwizard&step=1&resetcredit='.$resetcredit, 'form');
} else {
$db->query("UPDATE {$tablepre}members SET extcredits$resetcredit = $initcredits[$resetcredit]", 'UNBUFFERED');
cpmsg('creditwizard_resetusercredit_ok', $BASESCRIPT.'?action=creditwizard&step=1', 'succeed');
}
exit;
}
if(!$credit) {
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', $step == 1),
array('creditwizard_step_menu_2', 'creditwizard&step=2', $step == 2),
array('creditwizard_step_menu_3', 'creditwizard&step=3', $step == 3),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
));
showtableheader();
showsubtitle(array('credits_id', 'credits_title', 'creditwizard_status', ''));
for($i = 1; $i <= 8; $i++) {
showtablerow('', array('class="td21"'), array(
'extcredits'.$i,
$extcredits[$i]['title'].($i == $creditstrans ? $lang['creditwizard_iscreditstrans'] : ''),
$extcredits[$i]['available'] ? '<div class="staton">√</div>' : '<div class="statoff">-</div>',
'<a href="'.$BASESCRIPT.'?action=creditwizard&step=1&credit='.$i.'" class="act">'.$lang['detail'].'</a><a href="'.$BASESCRIPT.'?action=creditwizard&step=1&resetcredit='.$i.'" class="act">'.$lang['reset'].'</a>'
));
}
showtablefooter();
} else {
if(!submitcheck('settingsubmit')) {
$credit = $credit >=1 && $credit <= 8 ? $credit : 1;
$type = $type >=1 && $type <= 3 ? $type : 1;
$typeselected = array($type => ' selected="selected"');
$typeselect = '<select onchange="location.href=\''.$BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=\' + this.value"><option value="1"'.$typeselected[1].'>'.$lang['creditwizard_settingtype_global'].'</option><option value="2"'.$typeselected[2].'>'.$lang['creditwizard_settingtype_forum'].'</option><option value="3"'.$typeselected[3].'>'.$lang['creditwizard_settingtype_usergroup'].'</option></select>';
$creditselect = '<select onchange="location.href=\''.$BASESCRIPT.'?action=creditwizard&step=1&type='.$type.'&credit=\' + this.value">';
for($i = 1;$i <= 8;$i++) {
$creditselect .= '<option value="'.$i.'"'.($credit == $i ? ' selected="selected"' : '').'>extcredits'.$i.($extcredits[$i]['title'] ? ' ('.$extcredits[$i]['title'].')' : '').'</option>';
}
$creditselect .= '</select>';
$tips = 'creditwizard_settingtype_'.(empty($type) || $type == 1 ? 'global' : ($type == 2 ? 'forum' : ($type == 3 ? 'usergroup' : 'global'))).'_tips';
shownav('tools', 'nav_creditwizard');
showsubmenu('<a href="'.$BASESCRIPT.'?action=creditwizard&step=1">'.$lang['creditwizard_step_menu_1'].'</a> - extcredits'.$credit.($extcredits[$credit]['title'] ? '('.$extcredits[$credit]['title'].')' : ''));
showtips($tips);
showformheader("creditwizard&step=1&credit=$credit&type=$type");
showtableheader();
showtablerow('', 'class="lineheight" colspan="15"', "$lang[select]: $creditselect $typeselect");
if($type == 1) {
showtitle('settings_credits_extended');
showsetting('creditwizard_credit_title', 'settingsnew[title]', $extcredits[$credit]['title'], 'text');
showsetting('creditwizard_credits_unit', 'settingsnew[unit]', $extcredits[$credit]['unit'], 'text');
showsetting('creditwizard_credits_ratio', 'settingsnew[ratio]', $extcredits[$credit]['ratio'], 'text');
showsetting('creditwizard_credits_init', 'settingsnew[init]', intval($initcredits[$credit]), 'text');
showsetting('creditwizard_credits_available', 'settingsnew[available]', intval($extcredits[$credit]['available']), 'radio');
showsetting('creditwizard_credits_show_in_thread', 'settingsnew[showinthread]', intval($extcredits[$credit]['showinthread']), 'radio');
showsetting('settings_credits_export', 'settingsnew[allowexchangeout]', intval($extcredits[$credit]['allowexchangeout']), 'radio');
showsetting('settings_credits_import', 'settingsnew[allowexchangein]', intval($extcredits[$credit]['allowexchangein']), 'radio');
showtitle('settings_credits_policy');
showsetting('settings_credits_policy_post', 'settingsnew[policy_post]', intval($creditspolicy['post'][$credit]), 'text');
showsetting('settings_credits_policy_reply', 'settingsnew[policy_reply]', intval($creditspolicy['reply'][$credit]), 'text');
showsetting('settings_credits_policy_digest', 'settingsnew[policy_digest]', intval($creditspolicy['digest'][$credit]), 'text');
showsetting('settings_credits_policy_postattach', 'settingsnew[policy_postattach]', intval($creditspolicy['postattach'][$credit]), 'text');
showsetting('settings_credits_policy_getattach', 'settingsnew[policy_getattach]', intval($creditspolicy['getattach'][$credit]), 'text');
showsetting('settings_credits_policy_search', 'settingsnew[policy_search]', intval($creditspolicy['search'][$credit]), 'text');
showsetting('settings_credits_policy_promotion_visit', 'settingsnew[policy_promotion_visit]', intval($creditspolicy['promotion_visit'][$credit]), 'text');
showsetting('settings_credits_policy_promotion_register', 'settingsnew[policy_promotion_register]', intval($creditspolicy['promotion_register'][$credit]), 'text');
showsetting('settings_credits_policy_tradefinished', 'settingsnew[policy_tradefinished]', intval($creditspolicy['tradefinished'][$credit]), 'text');
showsetting('settings_credits_policy_votepoll', 'settingsnew[policy_votepoll]', intval($creditspolicy['votepoll'][$credit]), 'text');
showsetting('settings_credits_policy_lowerlimit', 'settingsnew[lowerlimit]', intval($extcredits[$credit]['lowerlimit']), 'text');
showtablerow('', 'class="lineheight" colspan="2"', $lang['settings_credits_policy_comment']);
showsubmit('settingsubmit', 'submit', '<input type="reset" class="btn" name="settingsubmit" value="'.$lang['reset'].'" />');
showtablefooter();
showformfooter();
} elseif($type == 2) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$fids = implode(',', array_keys($_DCACHE['forums']));
$query = $db->query("SELECT fid, postcredits, replycredits, getattachcredits, postattachcredits, digestcredits
FROM {$tablepre}forumfields WHERE fid in ($fids)");
while($forumcredit = $db->fetch_array($query)) {
$forumcredit['postcreditsstatus'] = $forumcredit['postcredits'] ? 'checked' : '';
$forumcredit['postcredits'] = $forumcredit['postcredits'] ? unserialize($forumcredit['postcredits']) : array();
$forumcredit['postcredits'] = intval($forumcredit['postcredits'][$credit]);
$forumcredit['replycreditsstatus'] = $forumcredit['replycredits'] ? 'checked' : '';
$forumcredit['replycredits'] = $forumcredit['replycredits'] ? unserialize($forumcredit['replycredits']) : array();
$forumcredit['replycredits'] = intval($forumcredit['replycredits'][$credit]);
$forumcredit['getattachcreditsstatus'] = $forumcredit['getattachcredits'] ? 'checked' : '';
$forumcredit['getattachcredits'] = $forumcredit['getattachcredits'] ? unserialize($forumcredit['getattachcredits']) : array();
$forumcredit['getattachcredits'] = intval($forumcredit['getattachcredits'][$credit]);
$forumcredit['postattachcreditsstatus'] = $forumcredit['postattachcredits'] ? 'checked' : '';
$forumcredit['postattachcredits'] = $forumcredit['postattachcredits'] ? unserialize($forumcredit['postattachcredits']) : array();
$forumcredit['postattachcredits'] = intval($forumcredit['postattachcredits'][$credit]);
$forumcredit['digestcreditsstatus'] = $forumcredit['digestcredits'] ? 'checked' : '';
$forumcredit['digestcredits'] = $forumcredit['digestcredits'] ? unserialize($forumcredit['digestcredits']) : array();
$forumcredit['digestcredits'] = intval($forumcredit['digestcredits'][$credit]);
$forumcredits[$forumcredit['fid']] = $forumcredit;
}
$credittable = '';
foreach($_DCACHE['forums'] as $fid => $forum) {
if($forum['type'] != 'group') {
$credittable .= showtablerow('', array('', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), array(
"<input class=\"checkbox\" title=\"$lang[select_all]\" type=\"checkbox\" name=\"chkallv$fid\" onclick=\"checkAll('value', this.form, $fid, 'chkallv$fid')\">".
($forum['type'] == 'forum' ? '' : ' ').
" <a href=\"$BASESCRIPT?frames=yes&action=forums&operation=edit&fid=$fid&anchor=credits\" target=\"_blank\">$forum[name]</a>",
"<input class=\"checkbox\" type=\"checkbox\" name=\"postcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][postcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"postcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][postcredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"replycreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][replycreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"replycredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][replycredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"digestcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][digestcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"digestcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][digestcredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"postattachcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][postattachcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"postattachcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][postattachcredits]}\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"getattachcreditsstatus[$fid]\" value=\"$fid\" chkvalue=\"$fid\" {$forumcredits[$fid][getattachcreditsstatus]}> <input type=\"text\" class=\"txt\" name=\"getattachcredits[$fid]\" size=\"2\" value=\"{$forumcredits[$fid][getattachcredits]}\">"
), TRUE);
}
}
showtitle('creditwizard_forum_creditspolicy');
?>
<tr ><td><?=$lang['forum']?></td>
<td><input class="checkbox" type="checkbox" name="chkall1" id="chkall1" onclick="checkAll('prefix', this.form, 'postcreditsstatus', 'chkall1')" /><label for="chkall1"> <?=$lang['settings_credits_policy_post']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall2" id="chkall2" onclick="checkAll('prefix', this.form, 'replycreditsstatus', 'chkall2')" /><label for="chkall2"> <?=$lang['settings_credits_policy_reply']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall3" id="chkall3" onclick="checkAll('prefix', this.form, 'digestcreditsstatus', 'chkall3')" /><label for="chkall3"> <?=$lang['settings_credits_policy_digest']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall4" id="chkall4" onclick="checkAll('prefix', this.form, 'postattachcreditsstatus', 'chkall4')" /><label for="chkall4"> <?=$lang['settings_credits_policy_postattach']?></label></td>
<td><input class="checkbox" type="checkbox" name="chkall5" id="chkall5" onclick="checkAll('prefix', this.form, 'getattachcreditsstatus', 'chkall5')" /><label for="chkall5"> <?=$lang['settings_credits_policy_getattach']?></label></td></tr>
<?
echo $credittable;
showsubmit('settingsubmit', 'submit', '<input type="button" class="btn" value="'.$lang['creditwizard_return'].'" onclick="location.href=\''.$BASESCRIPT.'?action=creditwizard&step=1\'" /> <input type="reset" class="btn" name="settingsubmit" value="'.$lang['reset'].'" />');
showtablefooter();
showformfooter();
} else {
$query = $db->query("SELECT groupid, grouptitle, raterange FROM {$tablepre}usergroups ORDER BY type DESC, groupid");
$raterangetable = '';
while($group = $db->fetch_array($query)) {
$ratemin = $ratemax = $ratemrpd = '';
foreach(explode("\n", $group['raterange']) as $range) {
$range = explode("\t", $range);
if($range[0] == $credit) {
$ratemin = $range[1];$ratemax = $range[2];$ratemrpd = $range[3];break;
}
}
$raterangetable .= showtablerow('', array('', 'class="td28"', 'class="td28"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"raterangestatus[$group[groupid]]\" value=\"1\" ".($ratemin && $ratemax && $ratemax ? 'checked' : '')."> <a href=\"$BASESCRIPT?frames=yes&action=groups&operation=user&do=edit&id=$group[groupid]&anchor=exempt\" target=\"_blank\">$group[grouptitle]</a>",
"<input type=\"text\" class=\"txt\" name=\"ratemin[$group[groupid]]\" size=\"3\" value=\"$ratemin\">",
"<input type=\"text\" class=\"txt\" name=\"ratemax[$group[groupid]]\" size=\"3\" value=\"$ratemax\">",
"<input type=\"text\" class=\"txt\" name=\"ratemrpd[$group[groupid]]\" size=\"3\" value=\"$ratemrpd\">"
), TRUE);
}
showtitle('creditwizard_forum_groupraterange');
showsubtitle(array('forum', 'usergroups_edit_raterange_min', 'usergroups_edit_raterange_max', 'usergroups_edit_raterange_mrpd'));
echo $raterangetable;
showsubmit('settingsubmit', 'submit', '<input type="reset" class="btn" name="settingsubmit" value="'.$lang['reset'].'" />');
showtablefooter();
showformfooter();
}
} else {
if($type == 1) {
if($creditstrans == $credit && empty($settingsnew['available'])) {
cpmsg('settings_creditstrans_invalid', '', 'error');
}
$initcredits[$credit] = $settingsnew['init'];
$initcredits = implode(',', $initcredits);
$extcredits[$credit] = array(
'title' => dhtmlspecialchars(stripslashes($settingsnew['title'])),
'unit' => dhtmlspecialchars(stripslashes($settingsnew['unit'])),
'ratio' => ($settingsnew['ratio'] > 0 ? (float)$settingsnew['ratio'] : 0),
'available' => $settingsnew['available'],
'showinthread' => $settingsnew['showinthread'],
'allowexchangeout' => $settingsnew['allowexchangeout'],
'allowexchangein' => $settingsnew['allowexchangein'],
'lowerlimit' => intval($settingsnew['lowerlimit']));
$extcredits = addslashes(serialize($extcredits));
$creditspolicy['post'][$credit] = intval($settingsnew['policy_post']);
$creditspolicy['reply'][$credit] = intval($settingsnew['policy_reply']);
$creditspolicy['digest'][$credit] = intval($settingsnew['policy_digest']);
$creditspolicy['postattach'][$credit] = intval($settingsnew['policy_postattach']);
$creditspolicy['getattach'][$credit] = intval($settingsnew['policy_getattach']);
$creditspolicy['pm'][$credit] = intval($settingsnew['policy_pm']);
$creditspolicy['search'][$credit] = intval($settingsnew['policy_search']);
$creditspolicy['promotion_visit'][$credit] = intval($settingsnew['policy_promotion_visit']);
$creditspolicy['promotion_register'][$credit] = intval($settingsnew['policy_promotion_register']);
$creditspolicy['tradefinished'][$credit] = intval($settingsnew['policy_tradefinished']);
$creditspolicy['votepoll'][$credit] = intval($settingsnew['policy_votepoll']);
$creditspolicy = serialize($creditspolicy);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('initcredits', '$initcredits')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('extcredits', '$extcredits')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditspolicy', '$creditspolicy')");
updatecache('settings');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=1', 'succeed');
} elseif($type == 2) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$fids = implode(',', array_keys($_DCACHE['forums']));
$query = $db->query("SELECT fid, postcredits, replycredits, getattachcredits, postattachcredits, digestcredits
FROM {$tablepre}forumfields WHERE fid in ($fids)");
$sqls = array();
while($forumcredit = $db->fetch_array($query)) {
$forumcredit['postcredits'] = $forumcredit['postcredits'] ? unserialize($forumcredit['postcredits']) : array();
$forumcredit['postcredits'][$credit] = intval($postcredits[$forumcredit['fid']]);
$forumcredit['postcredits'][$credit] = $forumcredit['postcredits'][$credit] < -99 ? -99 : $forumcredit['postcredits'][$credit];
$forumcredit['postcredits'][$credit] = $forumcredit['postcredits'][$credit] > 99 ? 99 : $forumcredit['postcredits'][$credit];
$sql = "postcredits='".($postcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['postcredits'])) : '')."'";
$forumcredit['replycredits'] = $forumcredit['replycredits'] ? unserialize($forumcredit['replycredits']) : array();
$forumcredit['replycredits'][$credit] = intval($replycredits[$forumcredit['fid']]);
$forumcredit['replycredits'][$credit] = $forumcredit['replycredits'][$credit] < -99 ? -99 : $forumcredit['replycredits'][$credit];
$forumcredit['replycredits'][$credit] = $forumcredit['replycredits'][$credit] > 99 ? 99 : $forumcredit['replycredits'][$credit];
$sql .= ",replycredits='".($replycreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['replycredits'])) : '')."'";
$forumcredit['getattachcredits'] = $forumcredit['getattachcredits'] ? unserialize($forumcredit['getattachcredits']) : array();
$forumcredit['getattachcredits'][$credit] = intval($getattachcredits[$forumcredit['fid']]);
$forumcredit['getattachcredits'][$credit] = $forumcredit['getattachcredits'][$credit] < -99 ? -99 : $forumcredit['getattachcredits'][$credit];
$forumcredit['getattachcredits'][$credit] = $forumcredit['getattachcredits'][$credit] > 99 ? 99 : $forumcredit['getattachcredits'][$credit];
$sql .= ",getattachcredits='".($getattachcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['getattachcredits'])) : '')."'";
$forumcredit['postattachcredits'] = $forumcredit['postattachcredits'] ? unserialize($forumcredit['postattachcredits']) : array();
$forumcredit['postattachcredits'][$credit] = intval($postattachcredits[$forumcredit['fid']]);
$forumcredit['postattachcredits'][$credit] = $forumcredit['postattachcredits'][$credit] < -99 ? -99 : $forumcredit['postattachcredits'][$credit];
$forumcredit['postattachcredits'][$credit] = $forumcredit['postattachcredits'][$credit] > 99 ? 99 : $forumcredit['postattachcredits'][$credit];
$sql .= ",postattachcredits='".($postattachcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['postattachcredits'])) : '')."'";
$forumcredit['digestcredits'] = $forumcredit['digestcredits'] ? unserialize($forumcredit['digestcredits']) : array();
$forumcredit['digestcredits'][$credit] = intval($digestcredits[$forumcredit['fid']]);
$forumcredit['digestcredits'][$credit] = $forumcredit['digestcredits'][$credit] < -99 ? -99 : $forumcredit['digestcredits'][$credit];
$forumcredit['digestcredits'][$credit] = $forumcredit['digestcredits'][$credit] > 99 ? 99 : $forumcredit['digestcredits'][$credit];
$sql .= ",digestcredits='".($digestcreditsstatus[$forumcredit['fid']] ? addslashes(serialize($forumcredit['digestcredits'])) : '')."'";
$db->query("UPDATE {$tablepre}forumfields SET $sql WHERE fid=$forumcredit[fid]", 'UNBUFFERED');
}
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=2', 'succeed');
} else {
$query = $db->query("SELECT groupid, grouptitle, raterange FROM {$tablepre}usergroups");
$raterangetable = '';
while($group = $db->fetch_array($query)) {
$raterangenew = '';
$rangearray = array();
foreach(explode("\n", $group['raterange']) as $range) {
$ranges = explode("\t", $range);
$rangearray[$ranges[0]] = $range;
}
$range = array();
if($raterangestatus[$group['groupid']]) {
$range[0] = $credit;
$range[1] = intval($ratemin[$group['groupid']] < -999 ? -999 : $ratemin[$group['groupid']]);
$range[2] = intval($ratemax[$group['groupid']] > 999 ? 999 : $ratemax[$group['groupid']]);
$range[3] = intval($ratemrpd[$group['groupid']] > 99999 ? 99999 : $ratemrpd[$group['groupid']]);
if(!$range[3] || $range[2] <= $range[1] || $range[3]< max(abs($range[1]), abs($range[2]))) {
cpmsg('creditwizard_edit_rate_invalid', '', 'error');
}
$rangearray[$credit] = implode("\t", $range);
} else {
unset($rangearray[$credit]);
}
$raterangenew = $rangearray ? implode("\n", $rangearray) : '';
$db->query("UPDATE {$tablepre}usergroups SET raterange='$raterangenew' WHERE groupid=$group[groupid]", 'UNBUFFERED');
}
updatecache('usergroups');
updatecache('admingroups');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=1&credit='.$credit.'&type=3', 'succeed');
}
}
}
} elseif($step == 2) {
if(!submitcheck('settingsubmit')) {
$formulareplace .= '\'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\',\'<u>'.$lang['settings_credits_formula_posts'].'</u>\',\'<u>'.$lang['settings_credits_formula_oltime'].'</u>\',\'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\'';
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, textend) {
$('creditsformulanew').focus();
textend = isUndefined(textend) ? '' : textend;
if(!isUndefined($('creditsformulanew').selectionStart)) {
var opn = $('creditsformulanew').selectionStart + 0;
if(textend != '') {
text = text + $('creditsformulanew').value.substring($('creditsformulanew').selectionStart, $('creditsformulanew').selectionEnd) + textend;
}
$('creditsformulanew').value = $('creditsformulanew').value.substr(0, $('creditsformulanew').selectionStart) + text + $('creditsformulanew').value.substr($('creditsformulanew').selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$('creditsformulanew').value += text;
}
formulaexp();
}
var formulafind = new Array('digestposts', 'posts', 'oltime', 'pageviews');
var formulareplace = new Array(<?=$formulareplace?>);
function formulaexp() {
var result = $('creditsformulanew').value;
<?
$extcreditsbtn = '';
for($i = 1; $i <= 8; $i++) {
$extcredittitle = $extcredits[$i]['available'] ? $extcredits[$i]['title'] : $lang['settings_credits_formula_extcredits'].$i;
echo 'result = result.replace(/extcredits'.$i.'/g, \'<u>'.$extcredittitle.'</u>\');';
$extcreditsbtn .= '<a href="###" onclick="insertunit(\'extcredits'.$i.'\')">'.$extcredittitle.'</a> ';
}
echo 'result = result.replace(/digestposts/g, \'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\');';
echo 'result = result.replace(/posts/g, \'<u>'.$lang['settings_credits_formula_posts'].'</u>\');';
echo 'result = result.replace(/oltime/g, \'<u>'.$lang['settings_credits_formula_oltime'].'</u>\');';
echo 'result = result.replace(/pageviews/g, \'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\');';
?>
$('creditsformulaexp').innerHTML = '<u><?=$lang['settings_credits_formula_credits']?></u>=' + result;
}
</script>
<?
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', $step == 1),
array('creditwizard_step_menu_2', 'creditwizard&step=2', $step == 2),
array('creditwizard_step_menu_3', 'creditwizard&step=3', $step == 3),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
));
showtips('creditwizard_tips_formula');
showformheader('creditwizard&step=2');
showtableheader();
showtitle('settings_credits_formula');
showtablerow('', 'colspan="2"', '<div class="extcredits">'.$extcreditsbtn.'<br /><a href="###" onclick="insertunit(\'digestposts\')">'.$lang['settings_credits_formula_digestposts'].'</a> <a href="###" onclick="insertunit(\'posts\')">'.$lang['settings_credits_formula_posts'].'</a> <a href="###" onclick="insertunit(\'oltime\')">'.$lang['settings_credits_formula_oltime'].'</a> <a href="###" onclick="insertunit(\'pageviews\')">'.$lang['settings_credits_formula_pageviews'].'</a> <a href="###" onclick="insertunit(\'+\')"> + </a> <a href="###" onclick="insertunit(\'-\')"> - </a> <a href="###" onclick="insertunit(\'*\')"> * </a> <a href="###" onclick="insertunit(\'/\')"> / </a> <a href="###" onclick="insertunit(\'(\', \')\')"> ( ) </a></div><div id="creditsformulaexp" class="marginbot diffcolor2">'.$creditsformulaexp.'</div><textarea name="creditsformulanew" id="creditsformulanew" style="width: 80%" rows="3" onkeyup="formulaexp()">'.dhtmlspecialchars($creditsformula).'</textarea>');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
} else {
if(!preg_match("/^([\+\-\*\/\.\d\(\)]|((extcredits[1-8]|digestposts|posts|pageviews|oltime)([\+\-\*\/\(\)]|$)+))+$/", $creditsformulanew) || !is_null(@eval(preg_replace("/(digestposts|posts|pageviews|oltime|extcredits[1-8])/", "\$\\1", $creditsformulanew).';'))) {
cpmsg('settings_creditsformula_invalid', '', 'error');
}
$creditsformulaexpnew = $creditsformulanew;
foreach(array('digestposts', 'posts', 'oltime', 'pageviews', 'extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8') as $var) {
if($extcredits[$creditsid = preg_replace("/^extcredits(\d{1})$/", "\\1", $var)]['available']) {
$replacement = $extcredits[$creditsid]['title'];
} else {
$replacement = $lang['settings_credits_formula_'.$var];
}
$creditsformulaexpnew = str_replace($var, '<u>'.$replacement.'</u>', $creditsformulaexpnew);
}
$creditsformulaexpnew = addslashes('<u>'.$lang['settings_credits_formula_credits'].'</u>='.$creditsformulaexpnew);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditsformula', '".addslashes($creditsformulanew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditsformulaexp', '".addslashes($creditsformulaexpnew)."')");
updatecache('settings');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=2', 'succeed');
}
} else {
if(!submitcheck('settingsubmit')) {
$creditstransselect = '';
$creditstrans = explode(',', $creditstrans);
for($i = 0; $i <= 8; $i++) {
if($i == 0 || $extcredits[$i]['available']) {
$creditstransselect .= '<option value="'.$i.'" '.($i == intval($creditstrans[0]) ? 'selected' : '').'>'.($i ? 'extcredits'.$i.' ('.$extcredits[$i]['title'].')' : $lang['none']).'</option>';
}
}
function showtextradio($textname, $textvalue, $radioname, $radioes = array()) {
$a = '<input type="text" class="txt marginbot" name="'.$textname.'" id="'.$textname.'" value="'.$textvalue.'" /><ul style="width: 340px;" onmouseover="altStyle(this);">';
if(is_array($radioes)) {
foreach($radioes as $radio) {
$a .= '<li><input type="radio" name="'.$radioname.'" value="'.$radio[1].'" class="radio" onclick="$(\''.$textname.'\').value = this.value"'.($radio[2] ? ' checked="checked"' : '').' /> '.$radio[0].'</li>';
}
}
$a .= '</ul>';
return $a;
}
shownav('tools', 'nav_creditwizard');
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', $step == 1),
array('creditwizard_step_menu_2', 'creditwizard&step=2', $step == 2),
array('creditwizard_step_menu_3', 'creditwizard&step=3', $step == 3),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 0),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
));
showtips('creditwizard_tips_creditsuse');
showformheader('creditwizard&step=3');
showtableheader('creditwizard_step_menu_3');
showsetting('settings_credits_trans', '', '', '<select onchange="$(\'allowcreditstrans\').style.display = this.value != 0 ? \'\' : \'none\'" name="creditstransnew">'.$creditstransselect.'</select>');
showsetting('settings_credits_tax', '', '', showtextradio('creditstaxnew', $creditstax, 'creditstaxradio', array(
array($lang['low'].' (0.01)', '0.01', $creditstax == '0.01'),
array($lang['middle'].' (0.1)', '0.1', $creditstax == '0.1'),
array($lang['high'].' (0.5)', '0.5', $creditstax == '0.5')
)));
showsetting('settings_credits_minexchange', '', '', showtextradio('exchangemincreditsnew', $exchangemincredits, 'exchangemincreditsradio', array(
array($lang['low'].' (100)', 100, $exchangemincredits == 100),
array($lang['middle'].' (1000)', 1000, $exchangemincredits == 1000),
array($lang['high'].' (5000)', 5000, $exchangemincredits == 5000)
)));
showtagheader('tbody', 'allowcreditstrans', $creditstrans);
showtitle('creditwizard_allowcreditstrans');
showsetting('settings_credits_mintransfer', '', '', showtextradio('transfermincreditsnew', $transfermincredits, 'transfermincreditsradio', array(
array($lang['low'].' (100)', 100, $transfermincredits == 100),
array($lang['middle'].' (1000)', 1000, $transfermincredits == 1000),
array($lang['high'].' (5000)', 5000, $transfermincredits == 5000)
)));
showsetting('settings_credits_maxincperthread', '', '', showtextradio('maxincperthreadnew', $maxincperthread, 'maxincperthreadradio', array(
array($lang['nolimit'].' (0)', 0, $maxincperthread == 0),
array($lang['low'].' (10)', 10, $maxincperthread == 10),
array($lang['middle'].' (50)', 50, $maxincperthread == 50),
array($lang['high'].' (100)', 100, $maxincperthread == 100)
)));
showsetting('settings_credits_maxchargespan', '', '', showtextradio('maxchargespannew', $maxchargespan, 'maxchargespanradio', array(
array($lang['nolimit'].' (0)', 0, $maxchargespan == 0),
array($lang['low'].' (5)', 5, $maxchargespan == 5),
array($lang['middle'].' (24)', 24, $maxchargespan == 24),
array($lang['high'].' (48)', 48, $maxchargespan == 48)
)));
showtagfooter('tbody');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
} else {
if($creditstaxnew < 0 || $creditstaxnew >= 1) {
$creditstaxnew = 0;
}
$creditstrans = explode(',', $creditstrans);
$creditstrans[0] = (float)$creditstransnew;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditstrans', '".implode(',', $creditstrans)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('creditstax', '".((float)$creditstaxnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('transfermincredits', '".((float)$transfermincreditsnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('exchangemincredits', '".((float)$exchangemincreditsnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('maxincperthread', '".((float)$maxincperthreadnew)."')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('maxchargespan', '".((float)$maxchargespannew)."')");
updatecache('settings');
cpmsg('creditwizard_edit_succeed', $BASESCRIPT.'?action=creditwizard&step=3', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/creditwizard.inc.php
|
PHP
|
asf20
| 33,087
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: qihoo.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='qihoo'");
$qihoo = ($qihoo = $db->result($query, 0)) ? unserialize($qihoo) : array();
$operation = !empty($operation) ? $operation : 'config';
if($operation == 'config') {
if(!submitcheck('qihoosubmit')) {
$checks = array();
$checkstatus = array($qihoo['status'] => 'checked');
$checklocation = array($qihoo['location'] => 'checked');
$qihoo['searchbox'] = sprintf('%03b', $qihoo['searchbox']);
for($i = 1; $i <= 3; $i++) {
$checks[$i] = $qihoo['searchbox'][3 - $i] ? 'checked' : '';
}
shownav('extended', 'nav_qihoo');
showsubmenu('nav_qihoo', array(
array('nav_qihoo_config', 'qihoo&operation=config', 1),
array('nav_qihoo_topics', 'qihoo&operation=topics', 0),
array('nav_qihoo_relatedthreads', 'qihoo&operation=relatedthreads', 0)
));
showtips('qihoo_tips');
showformheader('qihoo&operation=config');
showtableheader();
showtitle('qihoo');
showsetting('qihoo_status', '', '', '<ul class="nofloat" onmouseover="altStyle(this);"><li'.($checkstatus[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="qihoonew[status]" value="1" '.$checkstatus[1].'> '.$lang['qihoo_status_enable'].'</li><li'.($checkstatus[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="qihoonew[status]" value="2" '.$checkstatus[2].'> '.$lang['qihoo_status_enable_default'].'</li><li'.($checkstatus[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="qihoonew[status]" value="0" '.$checkstatus[0].'> '.$lang['qihoo_status_disable'].'</li></ul>');
showsetting('qihoo_searchbox', '', '', '<ul class="nofloat" onmouseover="altStyle(this);"><li'.($checks[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="qihoonew[searchbox][1]" value="1" '.$checks[1].'> '.$lang['qihoo_searchbox_index'].'</li><li'.($checks[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="qihoonew[searchbox][2]" value="1" '.$checks[2].'> '.$lang['qihoo_searchbox_forumdisplay'].'</li></ul>');
showsetting('qihoo_summary', 'qihoonew[summary]', $qihoo['summary'], 'radio');
showsetting('qihoo_jammer_allow', 'qihoonew[jammer]', $qihoo['jammer'], 'radio');
showsetting('qihoo_maxtopics', 'qihoonew[maxtopics]', $qihoo['maxtopics'], 'text');
showsetting('qihoo_keywords', 'qihoonew[keywords]', $qihoo['keywords'], 'textarea');
showsetting('qihoo_adminemail', 'qihoonew[adminemail]', $qihoo['adminemail'], 'text');
showsubmit('qihoosubmit');
showtablefooter();
showformfooter();
} else {
$qihoonew['searchbox'] = bindec(intval($qihoonew['searchbox'][3]).intval($qihoonew['searchbox'][2]).intval($qihoonew['searchbox'][1]));
$qihoonew['validity'] = $qihoonew['validity'] < 1 ? 1 : intval($qihoonew['validity']);
if($qihoonew['status'] && $qihoonew['adminemail']) {
if(!isemail($qihoonew['adminemail'])) {
cpmsg('qihoo_adminemail_invalid', '', 'error');
}
if($qihoonew['adminemail'] != $qihoo['adminemail']) {
dfopen('http://search.qihoo.com/corp/discuz.html?site='.site().'&key='.md5(site().'qihoo_discuz'.gmdate("Ymd", $timestamp)).'&email='.$qihoonew['adminemail']);
}
}
foreach((array)$qihoonew as $key => $value) {
$qihoo[$key] = in_array($key, array('keywords', 'adminemail')) ? $value : intval($value);
}
$db->query("UPDATE {$tablepre}settings SET value='".addslashes(serialize($qihoo))."' WHERE variable='qihoo'");
updatecache('settings');
cpmsg('qihoo_succeed', $BASESCRIPT.'?action=qihoo&operation=config', 'succeed');
}
} elseif($operation == 'relatedthreads') {
if(!submitcheck('qihoosubmit')) {
$checktype = array();
$settings = is_array($qihoo['relatedthreads']) ? $qihoo['relatedthreads'] : array();
foreach((array)$settings['type'] as $type) {
$checktype[$type] = 'checked';
}
shownav('extended', 'nav_qihoo');
showsubmenu('nav_qihoo', array(
array('nav_qihoo_config', 'qihoo&operation=config', 0),
array('nav_qihoo_topics', 'qihoo&operation=topics', 0),
array('nav_qihoo_relatedthreads', 'qihoo&operation=relatedthreads', 1)
));
showtips('qihoo_tips');
showformheader('qihoo&operation=relatedthreads');
showtableheader();
showsetting('qihoo_relatedthreads', 'settingsnew[bbsnum]', $settings['bbsnum'], 'text');
showsetting('qihoo_relatedthreads_web', 'settingsnew[webnum]', $settings['webnum'], 'radio');
showsetting('qihoo_relatedthreads_type', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">'.
'<li'.($checktype['news'] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="settingsnew[type][news]" value="news" '.$checktype['news'].'> '.$lang['qihoo_relatedthreads_type_news'].'</li>'.
'<li'.($checktype['bbs'] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="settingsnew[type][bbs]" value="bbs" '.$checktype['bbs'].'> '.$lang['qihoo_relatedthreads_type_bbs']).'</li></ul>';
showsetting('qihoo_relatedthreads_banurl', 'settingsnew[banurl]', $settings['banurl'], 'textarea');
showsetting('qihoo_relatedthreads_position', array('settingsnew[position]', array(
array(0, $lang['qihoo_relatedthreads_position_mode_top']),
array(1, $lang['qihoo_relatedthreads_position_mode_under'])
)), $settings['position'], 'mradio');
//showsetting('qihoo_relatedthreads_validity', 'settingsnew[validity]', $settings['validity'], 'text');
showsubmit('qihoosubmit');
showtablefooter();
showformfooter();
} else {
$qihoo['relatedthreads'] = array();
foreach((array)$settingsnew as $key => $value) {
$qihoo['relatedthreads'][$key] = in_array($key, array('bbsnum', 'webnum', 'position', 'order', 'validity')) ? intval($value) : $value;
}
$db->query("UPDATE {$tablepre}settings SET value='".addslashes(serialize($qihoo))."' WHERE variable='qihoo'");
updatecache('settings');
cpmsg('qihoo_succeed', $BASESCRIPT.'?action=qihoo&operation=relatedthreads', 'succeed');
}
} elseif($operation == 'topics') {
if(!submitcheck('topicsubmit')) {
showsubmenu('nav_qihoo', array(
array('nav_qihoo_config', 'qihoo&operation=config', 0),
array('nav_qihoo_topics', 'qihoo&operation=topics', 1),
array('nav_qihoo_relatedthreads', 'qihoo&operation=relatedthreads', 0)
));
showtips('qihoo_topics_tips');
showformheader('qihoo&operation=topics');
showtableheader('qihoo_topics_list');
showsubtitle(array('', 'qihoo_topics_name', 'qihoo_topics_keywords', 'qihoo_topics_length', 'qihoo_topics_type', 'qihoo_topics_orderby', ''));
foreach((is_array($qihoo['topics']) ? $qihoo['topics'] : array()) as $key => $value) {
$checkstype = array($value['stype'] => 'selected="selected"');
$checkrelate = array($value['relate'] => 'selected="selected"');
showtablerow('', array('class="td25"', '', 'class="td29"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$key]\" value=\"".$value['topic']."\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"qihoo_topics[$key][topic]\" id=\"qihoo_topics[$key][topic]\" value=\"$value[topic]\">",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"qihoo_topics[$key][keyword]\" id=\"qihoo_topics[$key][keyword]\" value=\"$value[keyword]\">",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"qihoo_topics[$key][length]\" id=\"qihoo_topics[$key][length]\" value=\"$value[length]\">",
"<select name=\"qihoo_topics[$key][stype]\" id=\"qihoo_topics[$key][stype]\"><option value=\"0\" $checkstype[0]>$lang[qihoo_topics_type_fulltext]</option><option value=\"title\" $checkstype[title]>$lang[qihoo_topics_type_title]</option></select>",
"<select name=\"qihoo_topics[$key][relate]\" id=\"qihoo_topics[$key][relate]\"><option value=\"score\" $checkrelate[score]>$lang[qihoo_topics_orderby_relation]</option><option value=\"pdate\" $checkrelate[pdate]>$lang[qihoo_topics_orderby_dateline]</option><option value=\"rdate\" $checkrelate[rdate]>$lang[qihoo_topics_orderby_lastpost]</option></select>",
"<a href=\"###\" onClick=\"window.open('topic.php?topic='+$('qihoo_topics[$key][topic]').value+'&keyword='+$('qihoo_topics[$key][keyword]').value+'&stype='+$('qihoo_topics[$key][stype]').value+'&length='+$('qihoo_topics[$key][length]').value+'&relate='+$('qihoo_topics[$key][relate]').value+'');\" class=\"act\">".lang('preview')."</a>"
));
}
showtablerow('', array('class="td25"', '', 'class="td29"'), array(
lang('add_new'),
'<input type="text" class="txt" size="20" name="newtopic" id="newtopic">',
'<input type="text" class="txt" size="30" name="newkeyword" id="newkeyword">',
'<input type="text" class="txt" size="10" name="newlength" id="newlength" value="0">',
'<select name="newstype" id="newstype"><option value="0" selected>'.lang('qihoo_topics_type_fulltext').'</option><option value="1">'.lang('qihoo_topics_type_title').'</option></select>',
'<select name="newrelate" id="newrelate"><option value="score">'.lang('qihoo_topics_orderby_relation').'</option><option value="pdate">'.lang('qihoo_topics_orderby_dateline').'</option><option value="rdate">'.lang('qihoo_topics_orderby_lastpost').'</option></select>',
'<a href="###" onClick="window.open(\'topic.php?topic=\'+$(\'newtopic\').value+\'&keyword=\'+$(\'newkeyword\').value+\'&stype=\'+$(\'newstype\').value+\'&length=\'+$(\'newlength\').value+\'&relate=\'+$(\'newrelate\').value);" class="act">'.lang('preview').'</a>'
));
showsubmit('topicsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$qihoo['topics'] = array();
foreach((array)$qihoo_topics as $key => $value) {
if(isset($delete[$key])) {
unset($qihoo['topics'][$key]);
} else {
$qihoo['topics'][$key] = array(
'topic' => dhtmlspecialchars(stripslashes($value['topic'])),
'keyword' => $value['keyword'] = trim($value['keyword']) ? dhtmlspecialchars(stripslashes($value['keyword'])) : $value['topic'],
'length' => intval($value['length']),
'stype' => $value['stype'],
'relate' => $value['relate']
);
}
}
if($newtopic) {
$qihoo['topics'][] = array(
'topic' => dhtmlspecialchars(stripslashes($newtopic)),
'keyword' => $newkeyword = trim($newkeyword) ? dhtmlspecialchars(stripslashes($newkeyword)) : $newtopic,
'length' => intval($newlength),
'stype' => $newstype > 1 ? 1 : intval($newstype),
'relate' => $newrelate
);
}
$db->query("UPDATE {$tablepre}settings SET value='".addslashes(serialize($qihoo))."' WHERE variable='qihoo'");
updatecache('settings');
cpmsg('qihoo_topics_succeed', $BASESCRIPT.'?action=qihoo&operation=topics', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/qihoo.inc.php
|
PHP
|
asf20
| 11,080
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: usergroups.inc.php 17521 2009-01-12 02:22:54Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(!submitcheck('groupsubmit')) {
$sgroups = $smembers = array();
$sgroupids = '0';
$smembernum = $membergroup = $specialgroup = $sysgroup = $membergroupoption = $specialgroupoption = '';
$insenz = ($insenz = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='insenz'")) ? unserialize($insenz) : array();
$conditions = !empty($insenz['groupid']) ? "WHERE groupid<>$insenz[groupid]" : '';
$query = $db->query("SELECT groupid, radminid, type, grouptitle, creditshigher, creditslower, stars, color, groupavatar FROM {$tablepre}usergroups $conditions ORDER BY creditshigher");
while($group = $db->fetch_array($query)) {
if($group['type'] == 'member') {
$membergroupoption .= "<option value=\"g{$group[groupid]}\">$group[grouptitle]</option>";
$membergroup .= showtablerow('', array('class="td25"', '', 'class="td28"', 'class=td28'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$group[groupid]]\" value=\"$group[groupid]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"groupnew[$group[groupid]][grouptitle]\" value=\"$group[grouptitle]\">",
"<input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][creditshigher]\" value=\"$group[creditshigher]\" /> ~ <input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][creditslower]\" value=\"$group[creditslower]\" disabled />",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"groupnew[$group[groupid]][stars]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\" name=\"groupnew[$group[groupid]][color]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"groupnew[$group[groupid]][groupavatar]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
} elseif($group['type'] == 'system') {
$sysgroup .= showtablerow('', array('', '', 'class="td28"'), array(
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_title[$group[groupid]]\" value=\"$group[grouptitle]\">",
$lang['usergroups_system_'.$group['groupid']],
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_avatar[$group[groupid]]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
} elseif($group['type'] == 'special' && $group['radminid'] == '0') {
$specialgroupoption .= "<option value=\"g{$group[groupid]}\">$group[grouptitle]</option>";
$sgroups[] = $group;
$sgroupids .= ','.$group['groupid'];
}
}
$projectselect = $membergroupoption.'<option value=""> ------------ </option>';
$specialprojectselect = $specialgroupoption.'<option value=""> ------------ </option>';
$project = array();
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='group'");
while($project = $db->fetch_array($query)) {
$projectselect = $specialprojectselect .= '<option value="'.$project['id'].'">'.$project['name'].'</option>';
}
foreach($sgroups as $group) {
if(is_array($smembers[$group['groupid']])) {
$num = count($smembers[$group['groupid']]);
$specifiedusers = implode('', $smembers[$group['groupid']]).($num > $smembernum[$group['groupid']] ? '<br /><div style="float: right; clear: both; margin:5px"><a href="'.$BASESCRIPT.'?action=members&submit=yes&usergroupid[]='.$group['groupid'].'" style="text-align: right;">'.$lang['more'].'»</a> </div>' : '<br /><br/>');
unset($smembers[$group['groupid']]);
} else {
$specifiedusers = '';
$num = 0;
}
$specifiedusers = "<style>#specifieduser span{width: 9em; height: 2em; float: left; overflow: hidden; margin: 2px;}</style><div id=\"specifieduser\">$specifiedusers</div>";
$specialgroup .= showtablerow('', array('class="td25"', '', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$group[groupid]]\" value=\"$group[groupid]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_title[$group[groupid]]\" value=\"$group[grouptitle]\">",
"<input type=\"text\" class=\"txt\" size=\"2\"name=\"group_stars[$group[groupid]]\" value=\"$group[stars]\">",
"<input type=\"text\" class=\"txt\" size=\"6\"name=\"group_color[$group[groupid]]\" value=\"$group[color]\">",
"<input type=\"text\" class=\"txt\" size=\"12\" name=\"group_avatar[$group[groupid]]\" value=\"$group[groupavatar]\">",
"<a href=\"$BASESCRIPT?action=usergroups&operation=viewsgroup&sgroupid=$group[groupid]\" onclick=\"ajaxget(this.href, 'sgroup_$group[groupid]', 'sgroup_$group[groupid]', 'auto');doane(event);\" class=\"act\">$lang[view]</a>",
"<a href=\"$BASESCRIPT?action=usergroups&operation=edit&id=$group[groupid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
$specialgroup .= showtablerow('', array('', 'colspan="6" id="sgroup_'.$group['groupid'].'" style="display: none"'), array(
'',
''
), TRUE);
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" size="12" name="groupnewadd[grouptitle][]">'],
[1,'<input type="text" class="txt" size="6" name="groupnewadd[creditshigher][]">', 'td28'],
[1,'<input type="text" class="txt" size="2" name="groupnewadd[stars][]">', 'td28'],
[4,'<select name="groupnewadd[projectid][]"><option value="">$lang[usergroups_project]</option><option value="0">------------</option>$projectselect</select>']
],
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" size="12" name="grouptitlenewadd[]">'],
[1,'<input type="text" class="txt" size="2" name="starsnewadd[]">', 'td28'],
[1,'<input type="text" class="txt" size="6" name="colornewadd[]">'],
[1,'<select name="groupnewaddproject[]"><option value="">$lang[usergroups_project]</option><option value="0">------------</option>$specialprojectselect</select>'],
[2, '']
]
];
</script>
EOT;
shownav('user', 'nav_usergroups');
showsubmenuanchors('nav_usergroups', array(
array('usergroups_member', 'membergroups', !$type || $type == 'member'),
array('usergroups_system', 'systemgroups', $type == 'system'),
array('usergroups_special', 'specialgroups', $type == 'special')
));
showtips('usergroups_tips');
showformheader('usergroups&type=member');
showtableheader('usergroups_member', 'fixpadding', 'id="membergroups"'.($type && $type != 'member' ? ' style="display: none"' : ''));
showsubtitle(array('', 'usergroups_title', 'usergroups_creditsrange', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', ''));
echo $membergroup;
echo '<tr><td> </td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['usergroups_add'].'</a></div></td></tr>';
showsubmit('groupsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showformheader('usergroups&type=special');
showtableheader('usergroups_special', 'fixpadding', 'id="specialgroups"'.($type != 'special' ? ' style="display: none"' : ''));
showsubtitle(array('', 'usergroups_title', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', '', ''));
echo $specialgroup;
echo '<tr><td> </td><td colspan="8"><div><a href="###" onclick="addrow(this, 1)" class="addtr">'.$lang['usergroups_sepcial_add'].'</a></div></td></tr>';
showsubmit('groupsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showformheader('usergroups&type=system');
showtableheader('usergroups_system', 'fixpadding', 'id="systemgroups"'.($type != 'system' ? ' style="display: none"' : ''));
showsubtitle(array('usergroups_title', 'usergroups_status', 'usergroups_stars', 'usergroups_color', 'usergroups_avatar', ''));
echo $sysgroup;
showsubmit('groupsubmit');
showtablefooter();
showformfooter();
} else {
if(empty($type) || !in_array($type, array('member', 'special', 'system'))) {
cpmsg('usergroups_type_nonexistence');
}
$oldgroups = $extadd = array();
$query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE `type`='$type'");
while ($gp = $db->fetch_array($query)) {
$oldgroups[$gp['groupid']] = $gp;
}
$sqladd = '';
$query = $db->query("SELECT * FROM {$tablepre}projects WHERE type='group'");
while($project = $db->fetch_array($query)) {
$sqladd = '';
$project['value'] = unserialize($project['value']);
foreach($project['value'] as $k=>$v) {
$v = addslashes($v);
$k = addslashes($k);
$sqladd .= ",`$k`='$v'";
}
$project['sqladd'] = $sqladd;
$extadd[$project['id']] = $project['sqladd'];
}
foreach($oldgroups as $id => $vals) {
$sqladd = '';
foreach($vals as $k => $v) {
$v = addslashes($v);
if(!in_array($k, array('groupid', 'radminid', 'type', 'system', 'grouptitle', 'creditshigher', 'creditslower', 'stars', 'color', 'groupavatar'))) {
$sqladd .= ",`$k`='$v'";
}
}
$extadd['g'.$id] = $sqladd;
}
if($type == 'member') {
$groupnewadd = array_flip_keys($groupnewadd);
foreach($groupnewadd as $k => $v) {
if(!$v['grouptitle'] || !$v['creditshigher']) {
unset($groupnewadd[$k]);
}
}
$groupnewkeys = array_keys($groupnew);
$maxgroupid = max($groupnewkeys);
foreach($groupnewadd as $k=>$v) {
$groupnew[$k+$maxgroupid+1] = $v;
}
$orderarray = array();
if(is_array($groupnew)) {
foreach($groupnew as $id => $group) {
if((is_array($delete) && in_array($id, $delete)) || ($id == 0 && (!$group['grouptitle'] || $group['creditshigher'] == ''))) {
unset($groupnew[$id]);
} else {
$orderarray[$group['creditshigher']] = $id;
}
}
}
if(empty($orderarray[0]) || min(array_flip($orderarray)) >= 0) {
cpmsg('usergroups_update_credits_invalid', '', 'error');
}
ksort($orderarray);
$rangearray = array();
$lowerlimit = array_keys($orderarray);
for($i = 0; $i < count($lowerlimit); $i++) {
$rangearray[$orderarray[$lowerlimit[$i]]] = array
(
'creditshigher' => isset($lowerlimit[$i - 1]) ? $lowerlimit[$i] : -999999999,
'creditslower' => isset($lowerlimit[$i + 1]) ? $lowerlimit[$i + 1] : 999999999
);
}
foreach($groupnew as $id => $group) {
$creditshighernew = $rangearray[$id]['creditshigher'];
$creditslowernew = $rangearray[$id]['creditslower'];
if($creditshighernew == $creditslowernew) {
cpmsg('usergroups_update_credits_duplicate', '', 'error');
}
if(in_array($id, $groupnewkeys)) {
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$group[grouptitle]', creditshigher='$creditshighernew', creditslower='$creditslowernew', stars='$group[stars]', color='$group[color]', groupavatar='$group[groupavatar]' WHERE groupid='$id' AND type='member'");
} elseif($group['grouptitle'] && $group['creditshigher'] != '') {
$sqladd = !empty($group['projectid']) && !empty($extadd[$group['projectid']]) ? $extadd[$group['projectid']] : '';
$db->query("INSERT INTO {$tablepre}usergroups SET grouptitle='$group[grouptitle]', creditshigher='$creditshighernew', creditslower='$creditslowernew', stars='$group[stars]' $sqladd");
}
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}usergroups WHERE groupid IN ($ids) AND type='member'");
deletegroupcache($delete);
}
} elseif($type == 'special') {
if(is_array($grouptitlenewadd)) {
foreach($grouptitlenewadd as $k => $v) {
if($v) {
$sqladd = !empty($groupnewaddproject[$k]) && !empty($extadd[$groupnewaddproject[$k]]) ? $extadd[$groupnewaddproject[$k]] : '';
$db->query("INSERT INTO {$tablepre}usergroups SET type='special', grouptitle='$grouptitlenewadd[$k]', color='$colornewadd[$k]', stars='$starsnewadd[$k]' $sqladd");
}
}
}
if(is_array($group_title)) {
foreach($group_title as $id => $title) {
if(!$delete[$id]) {
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$group_title[$id]', stars='$group_stars[$id]', color='$group_color[$id]', groupavatar='$group_avatar[$id]' WHERE groupid='$id'");
}
}
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}usergroups WHERE groupid IN ($ids) AND type='special'");
$db->query("DELETE FROM {$tablepre}admingroups WHERE admingid IN ($ids)");
$db->query("DELETE FROM {$tablepre}adminactions WHERE admingid IN ($ids)");
$newgroupid = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE type='member' AND creditslower>'0' ORDER BY creditslower LIMIT 1");
$db->query("UPDATE {$tablepre}members SET groupid='$newgroupid', adminid='0' WHERE groupid IN ($ids)", 'UNBUFFERED');
deletegroupcache($delete);
}
} elseif($type == 'system') {
if(is_array($group_title)) {
foreach($group_title as $id => $title) {
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$group_title[$id]', stars='$group_stars[$id]', color='$group_color[$id]', groupavatar='$group_avatar[$id]' WHERE groupid='$id'");
}
}
}
updatecache('usergroups');
cpmsg('usergroups_update_succeed', $BASESCRIPT.'?action=usergroups&type='.$type, 'succeed');
}
} elseif($operation == 'viewsgroup') {
$num = $db->result_first("SELECT COUNT(*) FROM {$tablepre}members WHERE groupid='$sgroupid'");
$query = $db->query("SELECT uid, username FROM {$tablepre}members WHERE groupid='$sgroupid' LIMIT 80");
$sgroups = '';
while($member = $db->fetch_array($query)) {
$sgroups .= '<li><a href="space.php?uid='.$member['uid'].'" target="_blank">'.$member['username'].'</a></li>';
}
ajaxshowheader();
echo '<ul class="userlist"><li class="unum">'.$lang['usernum'].$num.($num > 80 ? ' <a href="'.$BASESCRIPT.'?action=members&submit=yes&usergroupid[]='.$sgroupid.'">'.$lang['more'].'»</a>' : '').'</li>'.$sgroups.'</ul>';
ajaxshowfooter();
exit;
} elseif($operation == 'edit') {
$return = isset($return) && $return ? 'admin' : '';
if(empty($id)) {
$grouplist = "<select name=\"id\" style=\"width: 150px\">\n";
$conditions = !empty($anchor) && $anchor == 'system' ? "WHERE type='special'" : '';
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups $conditions");
while($group = $db->fetch_array($query)) {
$grouplist .= "<option value=\"$group[groupid]\">$group[grouptitle]</option>\n";
}
$grouplist .= '</select>';
cpmsg('usergroups_edit_nonexistence', $BASESCRIPT.'?action=usergroups&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : '').(!empty($highlight) ? "&anchor=$anchor" : ''), 'form', $grouplist);
}
$group = $db->fetch_first("SELECT * FROM {$tablepre}usergroups WHERE groupid='$id'");
if($group['radminid'] > 0 && !isfounder()) {
if(!checkacpaction('admingroups', '', false)) {
cpmsg('usergroups_edit_fail', '', 'error');
}
}
if(!submitcheck('detailsubmit') && !submitcheck('saveconfigsubmit')) {
$projectselect = "<select name=\"projectid\" onchange=\"window.location='$BASESCRIPT?action=usergroups&operation=edit&id=$id&projectid='+this.options[this.options.selectedIndex].value\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='group'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>";
}
$projectselect .= '</select>';
if(!empty($projectid)) {
$group = @array_merge($group, unserialize($db->result_first("SELECT value FROM {$tablepre}projects WHERE id='$projectid'")));
}
$group['exempt'] = strrev(sprintf('%0'.strlen($group['exempt']).'b', $group['exempt']));
$anchor = in_array($anchor, array('basic', 'system', 'special', 'post', 'attach', 'magic', 'invite', 'credit')) ? $anchor : 'basic';
showsubmenuanchors(lang('usergroups_edit').' - '.$group['grouptitle'], array(
array('usergroups_edit_basic', 'basic', $anchor == 'basic'),
$group['type'] == 'special' && $group['radminid'] < 1 ? array('usergroups_edit_system', 'system', $anchor == 'system') : array(),
array('usergroups_edit_special', 'special', $anchor == 'special'),
array('usergroups_edit_post', 'post', $anchor == 'post'),
array('usergroups_edit_attach', 'attach', $anchor == 'attach'),
array('usergroups_edit_magic', 'magic', $anchor == 'magic'),
array('usergroups_edit_invite', 'invite', $anchor == 'invite'),
array('usergroups_edit_credit', 'credit', $anchor == 'credit')
));
if($group['type'] == 'special' && $group['radminid'] < 1) {
showtips('usergroups_edit_system_tips', 'system_tips', $anchor == 'system');
}
showtips('usergroups_edit_magic_tips', 'magic_tips', $anchor == 'magic');
showtips('usergroups_edit_invite_tips', 'invite_tips', $anchor == 'invite');
showformheader("usergroups&operation=edit&id=$id&return=$return");
showtableheader();
if($group['type'] == 'special' && $group['radminid'] < 1) {
showtagheader('tbody', 'system', $anchor == 'system');
if($group['system'] == 'private') {
$system = array('public' => 0, 'dailyprice' => 0, 'minspan' => 0);
} else {
$system = array('public' => 1, 'dailyprice' => 0, 'minspan' => 0);
list($system['dailyprice'], $system['minspan']) = explode("\t", $group['system']);
}
showsetting('usergroups_edit_system_public', 'system_publicnew', $system['public'], 'radio');
showsetting('usergroups_edit_system_dailyprice', 'system_dailypricenew', $system['dailyprice'], 'text');
showsetting('usergroups_edit_system_minspan', 'system_minspannew', $system['minspan'], 'text');
showtagfooter('tbody');
}
showtagheader('tbody', 'basic', $anchor == 'basic');
showsetting('usergroups_edit_basic_title', 'grouptitlenew', $group['grouptitle'], 'text');
showsetting('usergroups_edit_basic_scheme', '', '', $projectselect);
if(in_array($group['groupid'], array(1, 7))) {
echo '<input type="hidden" name="allowvisitnew" value="1">';
} else {
showsetting('usergroups_edit_basic_visit', 'allowvisitnew', $group['allowvisit'], 'radio');
}
showsetting('usergroups_edit_basic_read_access', 'readaccessnew', $group['readaccess'], 'text');
showsetting('usergroups_edit_basic_view_profile', 'allowviewpronew', $group['allowviewpro'], 'radio');
showsetting('usergroups_edit_basic_view_stats', 'allowviewstatsnew', $group['allowviewstats'], 'radio');
showsetting('usergroups_edit_basic_invisible', 'allowinvisiblenew', $group['allowinvisible'], 'radio');
showsetting('usergroups_edit_basic_multigroups', 'allowmultigroupsnew', $group['allowmultigroups'], 'radio');
showsetting('usergroups_edit_basic_allowtransfer', 'allowtransfernew', $group['allowtransfer'], 'radio');
showsetting('usergroups_edit_basic_allowsendpm', 'allowsendpmnew', $group['allowsendpm'], 'radio');
showsetting('usergroups_edit_basic_search', array('allowsearchnew', array(
array(0, $lang['usergroups_edit_basic_search_disable']),
array(1, $lang['usergroups_edit_basic_search_thread']),
array(2, $lang['usergroups_edit_basic_search_post'])
)), $group['allowsearch'], 'mradio');
showsetting('usergroups_edit_basic_reasonpm', array('reasonpmnew', array(
array(0, $lang['usergroups_edit_basic_reasonpm_none']),
array(1, $lang['usergroups_edit_basic_reasonpm_reason']),
array(2, $lang['usergroups_edit_basic_reasonpm_pm']),
array(3, $lang['usergroups_edit_basic_reasonpm_both'])
)), $group['reasonpm'], 'mradio');
showsetting('usergroups_edit_basic_nickname', 'allownicknamenew', $group['allownickname'], 'radio');
showsetting('usergroups_edit_basic_cstatus', 'allowcstatusnew', $group['allowcstatus'], 'radio');
showsetting('usergroups_edit_basic_disable_periodctrl', 'disableperiodctrlnew', $group['disableperiodctrl'], 'radio');
showsetting('usergroups_edit_basic_hour_posts', 'maxpostsperhournew', $group['maxpostsperhour'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'special', $anchor == 'special');
showsetting('usergroups_edit_special_activity', 'allowpostactivitynew', $group['allowpostactivity'], 'radio');
showsetting('usergroups_edit_special_poll', 'allowpostpollnew', $group['allowpostpoll'], 'radio');
showsetting('usergroups_edit_special_vote', 'allowvotenew', $group['allowvote'], 'radio');
showsetting('usergroups_edit_special_reward', 'allowpostrewardnew', $group['allowpostreward'], 'radio');
showsetting('usergroups_edit_special_reward_min', 'minrewardpricenew', $group['minrewardprice'], "text");
showsetting('usergroups_edit_special_reward_max', 'maxrewardpricenew', $group['maxrewardprice'], "text");
showsetting('usergroups_edit_special_trade', 'allowposttradenew', $group['allowposttrade'], 'radio');
showsetting('usergroups_edit_special_trade_min', 'mintradepricenew', $group['mintradeprice'], "text");
showsetting('usergroups_edit_special_trade_max', 'maxtradepricenew', $group['maxtradeprice'], "text");
showsetting('usergroups_edit_special_trade_stick', 'tradesticknew', $group['tradestick'], "text");
showsetting('usergroups_edit_special_debate', 'allowpostdebatenew', $group['allowpostdebate'], "radio");
$videoopen && showsetting('usergroups_edit_special_video', 'allowpostvideonew', $group['allowpostvideo'], "radio");
showtagfooter('tbody');
showtagheader('tbody', 'post', $anchor == 'post');
showsetting('usergroups_edit_post_new', 'allowpostnew', $group['allowpost'], 'radio');
showsetting('usergroups_edit_post_reply', 'allowreplynew', $group['allowreply'], 'radio');
showsetting('usergroups_edit_post_direct', array('allowdirectpostnew', array(
array(0, $lang['usergroups_edit_post_direct_none']),
array(1, $lang['usergroups_edit_post_direct_reply']),
array(2, $lang['usergroups_edit_post_direct_thread']),
array(3, $lang['usergroups_edit_post_direct_all'])
)), $group['allowdirectpost'], 'mradio');
showsetting('usergroups_edit_post_anonymous', 'allowanonymousnew', $group['allowanonymous'], 'radio');
showsetting('usergroups_edit_post_set_read_perm', 'allowsetreadpermnew', $group['allowsetreadperm'], 'radio');
showsetting('usergroups_edit_post_maxprice', 'maxpricenew', $group['maxprice'], 'text');
showsetting('usergroups_edit_post_hide_code', 'allowhidecodenew', $group['allowhidecode'], 'radio');
showsetting('usergroups_edit_post_html', 'allowhtmlnew', $group['allowhtml'], 'radio');
showsetting('usergroups_edit_post_custom_bbcode', 'allowcusbbcodenew', $group['allowcusbbcode'], 'radio');
showsetting('usergroups_edit_post_bio_bbcode', 'allowbiobbcodenew', $group['allowbiobbcode'], 'radio');
showsetting('usergroups_edit_post_bio_img_code', 'allowbioimgcodenew', $group['allowbioimgcode'], 'radio');
showsetting('usergroups_edit_post_max_bio_size', 'maxbiosizenew', $group['maxbiosize'], 'text');
showsetting('usergroups_edit_post_sig_bbcode', 'allowsigbbcodenew', $group['allowsigbbcode'], 'radio');
showsetting('usergroups_edit_post_sig_img_code', 'allowsigimgcodenew', $group['allowsigimgcode'], 'radio');
showsetting('usergroups_edit_post_max_sig_size', 'maxsigsizenew', $group['maxsigsize'], 'text');
showtagfooter('tbody');
$group['maxattachsize'] = intval($group['maxattachsize'] / 1024);
$group['maxsizeperday'] = intval($group['maxsizeperday'] / 1024);
showtagheader('tbody', 'attach', $anchor == 'attach');
showsetting('usergroups_edit_attach_get', 'allowgetattachnew', $group['allowgetattach'], 'radio');
showsetting('usergroups_edit_attach_post', 'allowpostattachnew', $group['allowpostattach'], 'radio');
showsetting('usergroups_edit_attach_set_perm', 'allowsetattachpermnew', $group['allowsetattachperm'], 'radio');
showsetting('usergroups_edit_attach_max_size', 'maxattachsizenew', $group['maxattachsize'], 'text');
showsetting('usergroups_edit_attach_max_size_per_day', 'maxsizeperdaynew', $group['maxsizeperday'], 'text');
showsetting('usergroups_edit_attach_ext', 'attachextensionsnew', $group['attachextensions'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'magic', $anchor == 'magic');
showsetting('usergroups_edit_magic_permission', array('allowmagicsnew', array(
array(0, $lang['usergroups_edit_magic_unallowed']),
array(1, $lang['usergroups_edit_magic_allow']),
array(2, $lang['usergroups_edit_magic_allow_and_pass'])
)), $group['allowmagics'], 'mradio');
showsetting('usergroups_edit_magic_discount', 'magicsdiscountnew', $group['magicsdiscount'], 'text');
showsetting('usergroups_edit_magic_max', 'maxmagicsweightnew', $group['maxmagicsweight'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'invite', $anchor == 'invite');
showsetting('usergroups_edit_invite_permission', 'allowinvitenew', $group['allowinvite'], 'radio');
showsetting('usergroups_edit_invite_send_permission', 'allowmailinvitenew', $group['allowmailinvite'], 'radio');
showsetting('usergroups_edit_invite_price', 'invitepricenew', $group['inviteprice'], 'text');
showsetting('usergroups_edit_invite_buynum', 'maxinvitenumnew', $group['maxinvitenum'], 'text');
showsetting('usergroups_edit_invite_maxinviteday', 'maxinvitedaynew', $group['maxinviteday'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'credit', $anchor == 'credit');
showsetting('usergroups_edit_credit_exempt_sendpm', 'exemptnew[0]', $group['exempt'][0], 'radio');
showsetting('usergroups_edit_credit_exempt_search', 'exemptnew[1]', $group['exempt'][1], 'radio');
if($group['radminid']) {
if($group['radminid'] == 3) {
showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[2]', $group['exempt'][2], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_getattch'], 'exemptnew[5]', $group['exempt'][5], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[3]', $group['exempt'][3], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_attachpay'], 'exemptnew[6]', $group['exempt'][6], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_outperm'].$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[4]', $group['exempt'][4], 'radio');
showsetting($lang['usergroups_edit_credit_exempt_inperm'].$lang['usergroups_edit_credit_exempt_threadpay'], 'exemptnew[7]', $group['exempt'][7], 'radio');
} else {
echo '<input name="exemptnew[2]" type="hidden" value="1" /><input name="exemptnew[3]" type="hidden" value="1" /><input name="exemptnew[4]" type="hidden" value="1" />'.
'<input name="exemptnew[5]" type="hidden" value="1" /><input name="exemptnew[6]" type="hidden" value="1" /><input name="exemptnew[7]" type="hidden" value="1" />';
}
} else {
showsetting('usergroups_edit_credit_exempt_getattch', 'exemptnew[2]', $group['exempt'][2], 'radio');
showsetting('usergroups_edit_credit_exempt_attachpay', 'exemptnew[3]', $group['exempt'][3], 'radio');
showsetting('usergroups_edit_credit_exempt_threadpay', 'exemptnew[4]', $group['exempt'][4], 'radio');
}
echo '<tr><td colspan="2">'.$lang['usergroups_edit_credit_exempt_comment'].'</td></tr>';
$raterangearray = array();
foreach(explode("\n", $group['raterange']) as $range) {
$range = explode("\t", $range);
$raterangearray[$range[0]] = array('min' => $range[1], 'max' => $range[2], 'mrpd' => $range[3]);
}
echo '<tr><td colspan="2">';
showtableheader('usergroups_edit_credit_allowrate', 'noborder');
showsubtitle(array('', 'credits_id', 'credits_title', 'usergroups_edit_credit_rate_min', 'usergroups_edit_credit_rate_max', 'usergroups_edit_credit_rate_mrpd'));
for($i = 1; $i <= 8; $i++) {
if(isset($extcredits[$i])) {
echo '<tr><td><input class="checkbox" type="checkbox" name="raterangenew['.$i.'][allowrate]" value="1" '.(empty($raterangearray[$i]) ? '' : 'checked').'></td>'.
'<td>extcredits'.$i.'</td>'.
'<td>'.$extcredits[$i]['title'].'</td>'.
'<td><input type="text" class="txt" name="raterangenew['.$i.'][min]" size="3" value="'.$raterangearray[$i]['min'].'"></td>'.
'<td><input type="text" class="txt" name="raterangenew['.$i.'][max]" size="3" value="'.$raterangearray[$i]['max'].'"></td>'.
'<td><input type="text" class="txt" name="raterangenew['.$i.'][mrpd]" size="3" value="'.$raterangearray[$i]['mrpd'].'"></td></tr>';
}
}
echo '<tr><td colspan="6">'.$lang['usergroups_edit_credit_allowrate_comment'].'</td></tr></td></tr>';
showtablefooter();
echo '</td></tr>';
showtagfooter('tbody');
showsubmit('detailsubmit', 'submit', '', "<input type=\"submit\" class=\"btn\" name=\"saveconfigsubmit\" value=\"".$lang['saveconf']."\">");
showtablefooter();
showformfooter();
} else {
$systemnew = 'private';
if($group['type'] == 'special' && $group['radminid'] > 0) {
$radminidnew = $group['radminid'];
} elseif($group['type'] == 'special') {
$radminidnew = '0';
if($system_publicnew) {
if($system_dailypricenew > 0) {
if(!$creditstrans) {
cpmsg('usergroups_edit_creditstrans_disabled', '', 'error');
} else {
$system_minspannew = $system_minspannew <= 0 ? 1 : $system_minspannew;
$systemnew = intval($system_dailypricenew)."\t".intval($system_minspannew);
}
} else {
$systemnew = "0\t0";
}
}
} else {
$radminidnew = in_array($group['groupid'], array(1, 2, 3)) ? $group['groupid'] : 0;
}
if(is_array($raterangenew)) {
foreach($raterangenew as $key => $rate) {
if($key >= 1 && $key <= 8 && $rate['allowrate']) {
$rate['min'] = intval($rate['min'] < -999 ? -999 : $rate['min']);
$rate['max'] = intval($rate['max'] > 999 ? 999 : $rate['max']);
$rate['mrpd'] = intval($rate['mrpd'] > 99999 ? 99999 : $rate['mrpd']);
if(!$rate['mrpd'] || $rate['max'] <= $rate['min'] || $rate['mrpd'] < max(abs($rate['min']), abs($rate['max']))) {
cpmsg('usergroups_edit_rate_invalid', '', 'error');
} else {
$raterangenew[$key] = implode("\t", array($key, $rate['min'], $rate['max'], $rate['mrpd']));
}
} else {
unset($raterangenew[$key]);
}
}
}
if(in_array($group['groupid'], array(1, 7))) {
$allowvisitnew = 1;
}
$raterangenew = $raterangenew ? implode("\n", $raterangenew) : '';
$maxpricenew = $maxpricenew < 0 ? 0 : intval($maxpricenew);
$maxpostsperhournew = $maxpostsperhournew > 255 ? 255 : intval($maxpostsperhournew);
$extensionarray = array();
foreach(explode(',', $attachextensionsnew) as $extension) {
if($extension = trim($extension)) {
$extensionarray[] = $extension;
}
}
$attachextensionsnew = implode(', ', $extensionarray);
if($maxtradepricenew == $mintradepricenew || $maxtradepricenew < 0 || $mintradepricenew <= 0 || ($maxtradepricenew && $maxtradepricenew < $mintradepricenew)) {
cpmsg('trade_fee_error', '', 'error');
} elseif(($maxrewardpricenew != 0 && $minrewardpricenew >= $maxrewardpricenew) || $minrewardpricenew < 1 || $minrewardpricenew< 0 || $maxrewardpricenew < 0) {
cpmsg('reward_credits_error', '', 'error');
}
$exemptnewbin = '';
for($i = 0;$i < 8;$i++) {
$exemptnewbin = intval($exemptnew[$i]).$exemptnewbin;
}
$exemptnew = bindec($exemptnewbin);
$tradesticknew = $tradesticknew > 0 ? intval($tradesticknew) : 0;
$maxinvitedaynew = $maxinvitedaynew > 0 ? intval($maxinvitedaynew) : 10;
$maxattachsizenew = $maxattachsizenew > 0 ? intval($maxattachsizenew * 1024) : 0;
$maxsizeperdaynew = $maxsizeperdaynew > 0 ? intval($maxsizeperdaynew * 1024) : 0;
$db->query("UPDATE {$tablepre}usergroups SET grouptitle='$grouptitlenew', radminid='$radminidnew', system='$systemnew', allowvisit='$allowvisitnew',
readaccess='$readaccessnew', allowmultigroups='$allowmultigroupsnew', allowtransfer='$allowtransfernew', allowsendpm='$allowsendpmnew', allowviewpro='$allowviewpronew',
allowviewstats='$allowviewstatsnew', allowinvisible='$allowinvisiblenew', allowsearch='$allowsearchnew',
reasonpm='$reasonpmnew', allownickname='$allownicknamenew', allowcstatus='$allowcstatusnew',
disableperiodctrl='$disableperiodctrlnew', maxpostsperhour='$maxpostsperhournew', maxinvitenum='$maxinvitenumnew', maxinviteday='$maxinvitedaynew', allowpost='$allowpostnew', allowreply='$allowreplynew',
allowanonymous='$allowanonymousnew', allowsetreadperm='$allowsetreadpermnew', maxprice='$maxpricenew', allowhidecode='$allowhidecodenew',
allowhtml='$allowhtmlnew', allowpostpoll='$allowpostpollnew', allowdirectpost='$allowdirectpostnew', allowvote='$allowvotenew',
allowcusbbcode='$allowcusbbcodenew', allowsigbbcode='$allowsigbbcodenew', allowsigimgcode='$allowsigimgcodenew', allowinvite='$allowinvitenew', allowmailinvite='$allowmailinvitenew', raterange='$raterangenew',
maxsigsize='$maxsigsizenew', allowgetattach='$allowgetattachnew', allowpostattach='$allowpostattachnew',
allowsetattachperm='$allowsetattachpermnew', allowpostreward='$allowpostrewardnew', maxrewardprice='$maxrewardpricenew', minrewardprice='$minrewardpricenew', inviteprice='$invitepricenew',
maxattachsize='$maxattachsizenew', maxsizeperday='$maxsizeperdaynew', attachextensions='$attachextensionsnew',
allowbiobbcode='$allowbiobbcodenew', allowbioimgcode='$allowbioimgcodenew', maxbiosize='$maxbiosizenew', exempt='$exemptnew',
maxtradeprice='$maxtradepricenew', mintradeprice='$mintradepricenew', tradestick='$tradesticknew', allowposttrade='$allowposttradenew', allowpostactivity='$allowpostactivitynew', ".($videoopen ? "allowpostvideo='$allowpostvideonew', " :'')."allowmagics='$allowmagicsnew', maxmagicsweight='$maxmagicsweightnew', magicsdiscount='$magicsdiscountnew', allowpostdebate='$allowpostdebatenew' WHERE groupid='$id'");
if($allowinvisiblenew == 0 && $group['allowinvisible'] != $allowinvisiblenew) {
$db->query("UPDATE {$tablepre}members SET invisible='0' WHERE groupid='$id'");
}
updatecache('usergroups');
if(submitcheck('saveconfigsubmit')) {
$projectid = intval($projectid);
dheader("Location: $boardurl$BASESCRIPT?action=project&operation=add&id=$id&type=group&projectid=$projectid");
} elseif($return == 'admin') {
cpmsg('usergroups_edit_succeed', $BASESCRIPT.'?action=admingroups', 'succeed');
} else {
cpmsg('usergroups_edit_succeed', $BASESCRIPT.'?action=usergroups&operation=edit&id='.$id.'&anchor='.$anchor, 'succeed');
}
}
}
function array_flip_keys($arr) {
$arr2 = array();
$arrkeys = @array_keys($arr);
list(, $first) = @each(array_slice($arr, 0, 1));
if($first) {
foreach($first as $k=>$v) {
foreach($arrkeys as $key) {
$arr2[$k][$key] = $arr[$key][$k];
}
}
}
return $arr2;
}
function deletegroupcache($groupidarray) {
if(!empty($groupidarray) && is_array($groupidarray)) {
foreach ($groupidarray as $id) {
if(is_numeric($id) && $id = intval($id)) {
@unlink(DISCUZ_ROOT.'./forumdata/cache/usergroup_'.$id.'.php');
@unlink(DISCUZ_ROOT.'./forumdata/cache/admingroup_'.$id.'.php');
}
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/usergroups.inc.php
|
PHP
|
asf20
| 36,249
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: runwizard.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$step = in_array($step, array(1, 2, 3, 4)) ? $step : 1;
$runwizardhistory = array();
$runwizardfile = DISCUZ_ROOT.'./forumdata/logs/runwizardlog.php';
if($fp = @fopen($runwizardfile, 'r')) {
fseek($fp, 13);
$runwizardhistory = @unserialize(fread($fp, 99999));
fclose($fp);
}
cpheader();
shownav('tools', 'nav_runwizard');
showsubmenusteps('nav_runwizard', array(
array('runwizard_step_1', $step == 1),
array('runwizard_step_2', $step == 2),
array('runwizard_step_3', $step == 3),
array('runwizard_step_4', $step == 4)
));
showtips('runwizard_tips');
if($step == 1) {
$sizecheckedid = isset($runwizardhistory['step1']['size']) ? $runwizardhistory['step1']['size'] : 1;
$safecheckedid = isset($runwizardhistory['step1']['safe']) ? $runwizardhistory['step1']['safe'] : 0;
$funccheckedid = isset($runwizardhistory['step1']['func']) ? $runwizardhistory['step1']['func'] : 1;
showformheader('runwizard&step=2');
showtableheader();
showsetting('runwizard_forum_scope', array('size', array(
array(0, $lang['runwizard_forum_scope_small']),
array(1, $lang['runwizard_forum_scope_midding']),
array(2, $lang['runwizard_forum_scope_big'])
)), $sizecheckedid, 'mradio');
showsetting('runwizard_security', array('safe', array(
array(2, $lang['runwizard_security_high']),
array(1, $lang['runwizard_security_midding']),
array(0, $lang['runwizard_security_low'])
)), $safecheckedid, 'mradio');
showsetting('runwizard_hobby', array('func', array(
array(0, $lang['runwizard_hobby_concision']),
array(1, $lang['runwizard_hobby_commonly']),
array(2, $lang['runwizard_hobby_abundance'])
)), $funccheckedid, 'mradio');
showsubmit('step1submit', 'nextstep');
showtablefooter();
showformfooter();
$db->query("DELETE FROM {$tablepre}settings WHERE variable='runwizard'");
updatecache('settings');
} elseif($step == 2) {
if(submitcheck('step1submit')) {
$runwizardhistory['step1']['size'] = $size;
$runwizardhistory['step1']['safe'] = $safe;
$runwizardhistory['step1']['func'] = $func;
saverunwizardhistory();
}
$settings = &$_DCACHE['settings'];
$settings['bbname'] = empty($runwizard) && $runwizardhistory['step2']['bbname'] ? $runwizardhistory['step2']['bbname'] : $settings['bbname'];
$settings['sitename'] = empty($runwizard) && $runwizardhistory['step2']['sitename'] ? $runwizardhistory['step2']['sitename'] : $settings['sitename'];
$settings['siteurl'] = empty($runwizard) && $runwizardhistory['step2']['siteurl'] ? $runwizardhistory['step2']['siteurl'] : $settings['siteurl'];
showformheader('runwizard&step=3');
showtableheader();
showsetting('settings_basic_bbname', 'settingsnew[bbname]', $settings['bbname'], 'text');
showsetting('settings_basic_sitename', 'settingsnew[sitename]', $settings['sitename'], 'text');
showsetting('settings_basic_siteurl', 'settingsnew[siteurl]', $settings['siteurl'], 'text');
showsubmit('step2submit', 'nextstep', '<input type="button" class="btn" name="step2submit" value="'.lang('laststep').'" onclick="history.back();">');
showtablefooter();
showformfooter();
} elseif($step == 3) {
if(submitcheck('step2submit')) {
$runwizardhistory['step2']['bbname'] = $settingsnew['bbname'];
$runwizardhistory['step2']['sitename'] = $settingsnew['sitename'];
$runwizardhistory['step2']['siteurl'] = $settingsnew['siteurl'];
saverunwizardhistory();
}
showformheader('runwizard&step=4');
showtableheader('', 'fixpadding');
for($i = 1; $i < 4; $i++) {
showtablerow('', '', '<div class="parentboard"><input type="text" name="newcat['.$i.']" value="'.lang('runwizard_cat').' '.$i.'" class="txt" /></div>');
for($j = 1; $j < 4; $j++) {
showtablerow('', '', '<div class="'.($j == 3 ? 'lastboard' : 'board').'"><input type="text" name="newforum['.$i.'][]" value="'.lang('runwizard_forum').' '.$i.'.'.$j.'" class="txt" /></div>');
}
}
showsubmit('step3submit', 'nextstep', '<input type="button" class="btn" name="step2submit" value="'.$lang['laststep'].'" onclick="history.back();">');
showtablefooter();
showformfooter();
} elseif($step == 4) {
if(submitcheck('step3submit')) {
foreach($newcat as $k=>$catename) {
if(!$catename) {
unset($newcat[$k]);
unset($newforum[$k]);
} else {
foreach($newforum[$k] as $k2=>$forumname) {
if(!$forumname) {
unset($newforum[$k][$k2]);
}
}
}
}
$runwizardhistory['step3']['cates'] = $newcat ? $newcat : array();
$runwizardhistory['step3']['forums'] = $newforum ? $newforum : array();
saverunwizardhistory();
}
showtableheader('', 'nobottom fixpadding');
echo '<tr><td>';
if($confirm != 'yes') {
?>
<br /><?=$lang['runwizard_forum_initialization']?>
<ul class="tpllist">
<li><h4><?=$lang['runwizard_forum_scope']?></b> <?=$lang['runwizard_size_'.$runwizardhistory['step1']['size']]?><h4></li>
<li><h4><?=$lang['runwizard_security']?></b> <?=$lang['runwizard_safe_'.$runwizardhistory['step1']['safe']]?><h4></li>
<li><h4><?=$lang['runwizard_hobby']?></b> <?=$lang['runwizard_func_'.$runwizardhistory['step1']['func']]?><h4></li>
<li><h4><?=$lang['settings_bbname']?></b> <?=$runwizardhistory['step2']['bbname']?><h4></li>
<li><h4><?=$lang['settings_sitename']?></b> <?=$runwizardhistory['step2']['sitename']?><h4></li>
<li><h4><?=$lang['settings_siteurl']?></b> <?=$runwizardhistory['step2']['siteurl']?><h4></li>
<li><h4><?=$lang['runwizard_forum_add']?><h4>
<?
if($runwizardhistory['step3']['cates']) {
echo '<ul class="tpllist2">';
foreach($runwizardhistory['step3']['cates'] as $id=>$catename) {
echo '<li><h5>'.$catename.'</h5><ul class="tpllist3">';
foreach($runwizardhistory['step3']['forums'][$id] as $forumname) {
echo '<li>'.$forumname.'</li>';
}
echo '</ul></li>';
}
echo '</ul>';
} else {
echo $lang['none'];
}
echo '</li></ul></td></tr>';
showtablefooter();
showformheader('runwizard&step=4&confirm=yes');
showtableheader('', 'notop');
showsubmit('step4submit', 'submit', '<input type="button" class="btn" " value="'.$lang['laststep'].'" onclick="history.back();">');
showtablefooter();
showformfooter();
} else {
$sizesettings = array(
'attachsave' => array('1', '3', '4'),
'delayviewcount' => array('0', '0', '3'),
'fullmytopics' => array('1', '0', '0'),
'maxonlines' => array('500', '5000', '50000'),
'pvfrequence' => array('30', '60', '100'),
'qihoo_status' => array('0', '0', '1'),
'searchctrl' => array('10', '30', '60'),
'hottopic' => array('10', '20', '50'),
'losslessdel' => array('365', '200', '100'),
'maxmodworksmonths' => array('5', '3', '1'),
'maxsearchresults' => array('200', '500', '1000'),
'statscachelife' => array('90', '180', '360'),
'moddisplay' => array('flat', 'flat', 'selectbox'),
'topicperpage' => array('30', '20', '15'),
'postperpage' => array('20', '15', '10'),
'maxpolloptions' => array('10', '10', '15'),
'maxpostsize' => array('10000', '10000', '20000'),
'myrecorddays' => array('100', '60', '30'),
'maxfavorites' => array('500', '200', '100'),
'maxsubscriptions' => array('500', '200', '100'),
);
$safesettings = array(
'attachrefcheck' => array('', '1', '1'),
'bannedmessages' => array('', '1', '1'),
'doublee' => array('1', '0', '0'),
'dupkarmarate' => array('1', '0', '0'),
'hideprivate' => array('0', '1', '1'),
'memliststatus' => array('1', '1', '0'),
'seccodestatus' => array('0', '1', '1'),
'bbrules' => array('0', '1', '1'),
'edittimelimit' => array('0', '20', '10'),
'floodctrl' => array('0', '10', '30'),
'karmaratelimit' => array('0', '1', '4'),
'newbiespan' => array('', '1', '4'),
'showemail' => array('0', '1', '1'),
'maxchargespan' => array('0', '1', '2'),
'regctrl' => array('0', '12', '48'),
'regfloodctrl' => array('0', '100', '50'),
'regstatus' => array('1', '1', '1'),
'regverify' => array('0', '1', '2'),
);
$funcsettings = array(
'archiverstatus' => array('0', '1', '1'),
'bdaystatus' => array('0', '0', '1'),
'fastpost' => array('0', '1', '1'),
'editedby' => array('0', '1', '1'),
'forumjump' => array('0', '1', '1'),
'gzipcompress' => array('', '', '1'),
'newsletter' => array('', '', '1'),
'modworkstatus' => array('0', '0', '1'),
'reportpost' => array('0', '1', '1'),
'rewritestatus' => array('0', '0', '0'),
'rssstatus' => array('0', '1', '1'),
'wapstatus' => array('0', '1', '1'),
'maxbdays' => array('0', '100', '500'),
'statstatus' => array('0', '0', '1'),
'stylejump' => array('0', '0', '1'),
'subforumsindex' => array('0', '0', '1'),
'transsidstatus' => array('0', '0', '1'),
'visitedforums' => array('0', '10', '20'),
'vtonlinestatus' => array('0', '1', '1'),
'welcomemsg' => array('0', '0', '1'),
'jsstatus' => array('0', '0', '1'),
'watermarkstatus' => array('0', '0', '1'),
'whosonlinestatus' => array('0', '1', '1'),
'debug' => array('0', '1', '1'),
'regadvance' => array('0', '0', '1'),
'jsmenustatus' => array('0', '1', '15'),
'showsettings' => array('0', '7', '7'),
'editoroptions' => array('0', '1', '1'),
);
$safeforums = array(
'modnewposts' => array('0', '0', '1'),
'recyclebin' => array('0', '1', '1'),
'jammer' => array('0', '0', '1'),
);
$funcforums = array(
'allowsmilies' => array('0', '1', '1'),
'allowbbcode' => array('0', '1', '1'),
'allowimgcode' => array('0', '1', '1'),
'allowanonymous' => array('0', '0', '1'),
'allowpostspecial' => array('', '1', '127'),
'disablewatermark' => array('1', '0', '0'),
'threadcaches' => array('0', '0', '1'),
'allowshare' => array('0', '1', '1'),
);
$sizeforums = array(
'threadcaches' => array('0', '0', '1'),
);
$sqladd = $comma = '';
foreach($sizesettings as $fieldname=>$val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$fieldname', '{$val[$runwizardhistory[step1][size]]}')");
}
foreach($sizeforums as $fieldname=>$val) {
$sqladd .= $comma."$fieldname='".$val[$runwizardhistory['step1']['size']]."'";
$comma = ',';
}
foreach($safesettings as $fieldname=>$val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$fieldname', '{$val[$runwizardhistory[step1][safe]]}')");
}
foreach($safeforums as $fieldname=>$val) {
$sqladd .= $comma."$fieldname='".$val[$runwizardhistory['step1']['safe']]."'";
}
foreach($funcsettings as $fieldname=>$val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$fieldname', '{$val[$runwizardhistory[step1][func]]}')");
}
foreach($funcforums as $fieldname=>$val) {
$sqladd .= $comma."$fieldname='".$val[$runwizardhistory['step1']['func']]."'";
}
$db->query("UPDATE {$tablepre}forums SET $sqladd");
$maxonlines = $sizesettings['maxonlines'][$runwizardhistory['step1']['size']];
$db->query("ALTER TABLE {$tablepre}sessions MAX_ROWS=$maxonlines");
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('bbname', '{$runwizardhistory[step2][bbname]}')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('sitename', '{$runwizardhistory[step2][sitename]}')");
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('siteurl', '{$runwizardhistory[step2][siteurl]}')");
updatecache('settings');
foreach($runwizardhistory['step3']['cates'] as $id=>$catename) {
$db->query("INSERT INTO {$tablepre}forums (type, name, status)
VALUES ('group', '$catename', '1')");
$fup = $fid = $db->insert_id();
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
foreach($runwizardhistory['step3']['forums'][$id] as $forumname) {
$db->query("INSERT INTO {$tablepre}forums (fup, type, name, status, allowsmilies, allowbbcode, allowimgcode, allowshare, allowpostspecial)
VALUES ('$fup', 'forum', '$forumname', '1', '1', '1', '1', '1', '15')");
$fid = $db->insert_id();
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
}
}
updatecache('forums');
$runwizardhistory['step3']['cates'] = array();
$runwizardhistory['step3']['forums'] = array();
saverunwizardhistory();
?>
<ul class="tpllist"><li>
<h4><?=$lang['runwizard_succeed']?></h4>
<ul class="tpllist2">
<li><a href="<?=$BASESCRIPT?>?action=settings&operation=basic"><?=$lang['runwizard_particular']?></a></li>
<li><a href="<?=$BASESCRIPT?>?action=forums"><?=$lang['forums_admin_add_forum']?></a></li>
<li><a href="<?=$BASESCRIPT?>?action=tools&operation=fileperms"><?=$lang['nav_fileperms']?></a></li>
</ul>
</li>
<li>
<h4><?=$lang['runwizard_database_backup']?></h4>
<ul class="tpllist2">
<li><a href="<?=$BASESCRIPT?>?action=db&operation=export"><?=$lang['db_export']?></a></li>
<li><a href="<?=$BASESCRIPT?>?action=db&operation=import"><?=$lang['db_import']?></a></li>
</ul>
</li>
</ul>
<?}?>
</td></tr></table>
<?
}
function saverunwizardhistory() {
global $runwizardfile, $runwizardhistory;
$fp = fopen($runwizardfile, 'w');
$s = '<?php exit;?>';
$s .= serialize($runwizardhistory);
fwrite($fp, $s);
fclose($fp);
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/runwizard.inc.php
|
PHP
|
asf20
| 13,695
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: threads.inc.php 16775 2008-11-19 03:18:09Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./include/post.func.php';
cpheader();
$page = max(1, intval($page));
if(!$operation) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="inforum"><option value="all"> > '.$lang['all'].'</option>'.
'<option value=""> </option>'.forumselect().'</select>';
if(isset($inforum)) {
$forumselect = preg_replace("/(\<option value=\"$inforum\")(\>)/", "\\1 selected=\"selected\" \\2", $forumselect);
}
$typeselect = $sortselect = '';
$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
if($type['special']) {
$sortselect .= '<option value="'.$type['typeid'].'"> > '.$type['name'].'</option>';
} else {
$typeselect .= '<option value="'.$type['typeid'].'"> > '.$type['name'].'</option>';
}
}
if(isset($insort)) {
$sortselect = preg_replace("/(\<option value=\"$insort\")(\>)/", "\\1 selected=\"selected\" \\2", $sortselect);
}
if(isset($intype)) {
$typeselect = preg_replace("/(\<option value=\"$intype\")(\>)/", "\\1 selected=\"selected\" \\2", $typeselect);
}
echo <<<EOT
<script src="include/js/calendar.js"></script>
<script type="text/JavaScript">
function page(number) {
$('threadforum').page.value=number;
$('threadforum').searchsubmit.click();
}
</script>
EOT;
shownav('topic', 'nav_maint_threads');
showsubmenusteps('nav_maint_threads', array(
array('threads_search', !$searchsubmit),
array('nav_maint_threads', $searchsubmit)
));
showtips('threads_tips');
showtagheader('div', 'threadsearch', !submitcheck('searchsubmit'));
showformheader('threads', '', 'threadforum');
showhiddenfields(array('page' => $page));
showtableheader();
showsetting('threads_search_detail', 'detail', $detail, 'radio');
showsetting('threads_search_forum', '', '', $forumselect);
showsetting('threads_search_time', array('starttime', 'endtime'), array($starttime, $endtime), 'daterange');
showsetting('threads_search_user', 'users', $users, 'text');
showsetting('threads_search_keyword', 'keywords', $keywords, 'text');
showtagheader('tbody', 'advanceoption');
showsetting('threads_search_type', '', '', '<select name="intype"><option value="all"> > '.$lang['all'].'</option><option value=""> </option><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$typeselect.'</select>');
showsetting('threads_search_sort', '', '', '<select name="insort"><option value="all"> > '.$lang['all'].'</option><option value=""> </option><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$sortselect.'</select>');
showsetting('threads_search_viewrange', array('viewsmore', 'viewsless'), array($viewsmore, $viewsless), 'range');
showsetting('threads_search_replyrange', array('repliesmore', 'repliesless'), array($repliesmore, $repliesless), 'range');
showsetting('threads_search_readpermmore', 'readpermmore', $readpermmore, 'text');
showsetting('threads_search_pricemore', 'pricemore', $pricemore, 'text');
showsetting('threads_search_noreplyday', 'noreplydays', $noreplydays, 'text');
showsetting('threads_search_type', array('specialthread', array(
array(0, lang('unlimited'), array('showspecial' => 'none')),
array(1, lang('threads_search_include_yes'), array('showspecial' => '')),
array(2, lang('threads_search_include_no'), array('showspecial' => '')),
), TRUE), $specialthread, 'mradio');
showtablerow('id="showspecial" style="display:'.($specialthread ? '' : 'none').'"', 'class="sub" colspan="2"', mcheckbox('special', array(
1 => lang('thread_poll'),
2 => lang('thread_trade'),
3 => lang('thread_reward'),
4 => lang('thread_activity'),
5 => lang('thread_debate'),
6 => lang('thread_video')
), $special ? $special : array(0)));
showsetting('threads_search_sticky', array('sticky', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $sticky, 'mradio');
showsetting('threads_search_digest', array('digest', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $digest, 'mradio');
showsetting('threads_search_attach', array('attach', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $attach, 'mradio');
showsetting('threads_rate', array('rate', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $rate, 'mradio');
showsetting('threads_highlight', array('highlight', array(
array(0, lang('unlimited')),
array(1, lang('threads_search_include_yes')),
array(2, lang('threads_search_include_no')),
), TRUE), $highlight, 'mradio');
showtagfooter('tbody');
showsubmit('searchsubmit', 'submit', '', 'more_options');
showtablefooter();
showformfooter();
showtagfooter('div');
if(submitcheck('searchsubmit')) {
$sql = '';
$sql .= $inforum != '' && $inforum != 'all' ? " AND fid='$inforum'" : '';
$sql .= $intype != '' && $intype != 'all' ? " AND typeid='$intype'" : '';
$sql .= $insort != '' && $insort != 'all' ? " AND sortid='$insort'" : '';
$sql .= $viewsless != '' ? " AND views<'$viewsless'" : '';
$sql .= $viewsmore != '' ? " AND views>'$viewsmore'" : '';
$sql .= $repliesless != '' ? " AND replies<'$repliesless'" : '';
$sql .= $repliesmore != '' ? " AND replies>'$repliesmore'" : '';
$sql .= $readpermmore != '' ? " AND readperm>'$readpermmore'" : '';
$sql .= $pricemore != '' ? " AND price>'$pricemore'" : '';
$sql .= $beforedays != '' ? " AND dateline<'$timestamp'-'$beforedays'*86400" : '';
$sql .= $noreplydays != '' ? " AND lastpost<'$timestamp'-'$noreplydays'*86400" : '';
$sql .= $starttime != '' ? " AND dateline>'".strtotime($starttime)."'" : '';
$sql .= $endtime != '' ? " AND dateline<='".strtotime($endtime)."'" : '';
if(trim($keywords)) {
$sqlkeywords = '';
$or = '';
$keywords = explode(',', str_replace(' ', '', $keywords));
for($i = 0; $i < count($keywords); $i++) {
$sqlkeywords .= " $or subject LIKE '%".$keywords[$i]."%'";
$or = 'OR';
}
$sql .= " AND ($sqlkeywords)";
}
$sql .= trim($users) ? " AND author IN ('".str_replace(',', '\',\'', str_replace(' ', '', trim($users)))."')" : '';
if($sticky == 1) {
$sql .= " AND displayorder>'0'";
} elseif($sticky == 2) {
$sql .= " AND displayorder='0'";
}
if($digest == 1) {
$sql .= " AND digest>'0'";
} elseif($digest == 2) {
$sql .= " AND digest='0'";
}
if($attach == 1) {
$sql .= " AND attachment>'0'";
} elseif($attach == 2) {
$sql .= " AND attachment='0'";
}
if($rate == 1) {
$sql .= " AND rate>'0'";
} elseif($rate == 2) {
$sql .= " AND rate='0'";
}
if($highlight == 1) {
$sql .= " AND highlight>'0'";
} elseif($highlight == 2) {
$sql .= " AND highlight='0'";
}
if(!empty($special)) {
$specials = $comma = '';
foreach($special as $val) {
$specials .= $comma.'\''.$val.'\'';
$comma = ',';
}
if($specialthread == 1) {
$sql .= " AND special IN ($specials)";
} elseif($specialthread == 2) {
$sql .= " AND special NOT IN ($specials)";
}
}
$fids = array();
$tids = $threadcount = '0';
if($sql) {
$sql = "digest>='0' AND displayorder>='0' $sql";
if($detail) {
$pagetmp = $page;
do {
$query = $db->query("SELECT fid, tid, readperm, price, subject, authorid, author, views, replies, lastpost FROM {$tablepre}threads WHERE $sql LIMIT ".(($pagetmp - 1) * $tpp).",$tpp");
$pagetmp--;
} while(!$db->num_rows($query) && $pagetmp);
$threads = '';
while($thread = $db->fetch_array($query)) {
$fids[] = $thread['fid'];
$thread['lastpost'] = gmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
$threads .= showtablerow('', array('class="td25"', '', '', '', 'class="td25"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"tidarray[]\" value=\"$thread[tid]\" checked />",
"<a href=\"viewthread.php?tid=$thread[tid]\" target=\"_blank\">$thread[subject]</a>".($thread['readperm'] ? " - [$lang[threads_readperm] $thread[readperm]]" : '').($thread['price'] ? " - [$lang[threads_price] $thread[price]]" : ''),
"<a href=\"forumdisplay.php?fid=$thread[fid]\" target=\"_blank\">{$_DCACHE[forums][$thread[fid]][name]}</a>",
"<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>",
$thread['replies'],
$thread['views'],
$thread['lastpost']
), TRUE);
}
$threadcount = $db->result_first("SELECT count(*) FROM {$tablepre}threads WHERE $sql");
$multi = multi($threadcount, $tpp, $page, "$BASESCRIPT?action=threads");
$multi = preg_replace("/href=\"$BASESCRIPT\?action=threads&page=(\d+)\"/", "href=\"javascript:page(\\1)\"", $multi);
$multi = str_replace("window.location=$BASESCRIPT.'?action=threads&page='+this.value", "page(this.value)", $multi);
} else {
$query = $db->query("SELECT fid, tid FROM {$tablepre}threads WHERE $sql");
while($thread = $db->fetch_array($query)) {
$fids[] = $thread['fid'];
$tids .= ','.$thread['tid'];
}
$threadcount = $db->result_first("SELECT count(*) FROM {$tablepre}threads WHERE $sql");
$multi = '';
}
}
$fids = implode(',', array_unique($fids));
showtagheader('div', 'threadlist', TRUE);
showformheader('threads&frame=no', 'target="threadframe"');
showhiddenfields($detail ? array('fids' => $fids) : array('fids' => $fids, 'tids' => $tids));
showtableheader(lang('threads_result').' '.$threadcount.' <a href="###" onclick="$(\'threadlist\').style.display=\'none\';$(\'threadsearch\').style.display=\'\';" class="act lightlink normal">'.lang('research').'</a>', 'nobottom');
showsubtitle(array('', 'operation', 'option'));
if(!$threadcount) {
showtablerow('', 'colspan="3"', lang('threads_thread_nonexistence'));
} else {
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="moveforum" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_move_forum'],
'<select name="toforum">'.forumselect().'</select>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="movetype" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_move_type'],
'<select name="totype"><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$typeselect.'</select>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="movesort" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_move_sort'],
'<select name="tosort"><option value="0"> > '.$lang['threads_search_type_none'].'</option>'.$sortselect.'</select>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="delete" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_delete'],
'<input class="checkbox" type="checkbox" name="donotupdatemember" id="donotupdatemember" value="1" checked="checked" /><label for="donotupdatemember"> '.$lang['threads_delete_no_update_member'].'</label>'
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="stick" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_stick'],
'<input class="radio" type="radio" name="stick_level" value="0" checked> '.$lang['threads_remove'].' <input class="radio" type="radio" name="stick_level" value="1"> '.$lang['threads_stick_one'].' <input class="radio" type="radio" name="stick_level" value="2"> '.$lang['threads_stick_two'].' <input class="radio" type="radio" name="stick_level" value="3"> '.$lang['threads_stick_three']
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="adddigest" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_add_digest'],
'<input class="radio" type="radio" name="digest_level" value="0" checked> '.$lang['threads_remove'].' <input class="radio" type="radio" name="digest_level" value="1"> '.$lang['threads_digest_one'].' <input class="radio" type="radio" name="digest_level" value="2"> '.$lang['threads_digest_two'].' <input class="radio" type="radio" name="digest_level" value="3"> '.$lang['threads_digest_three']
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="addstatus" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_open_close'],
'<input class="radio" type="radio" name="status" value="0" checked> '.$lang['open'].' <input class="radio" type="radio" name="status" value="1"> '.$lang['closed']
));
showtablerow('', array('class="td25"', 'class="td24"', 'class="rowform" style="width:auto;"'), array(
'<input class="radio" type="radio" name="operation" value="deleteattach" onclick="this.form.modsubmit.disabled=false;">',
$lang['threads_delete_attach'],
''
));
if($detail) {
showtablefooter();
showtableheader('threads_list', 'notop');
showsubtitle(array('', 'subject', 'forum', 'author', 'threads_replies', 'threads_views', 'threads_lastpost'));
echo $threads;
}
}
showsubmit('modsubmit', 'submit', '<input name="chkall" id="chkall" type="checkbox" class="checkbox" checked="checked" onclick="checkAll(\'prefix\', this.form, \'tidarray\', \'chkall\')" /><label for="chkall">'.lang('select_all').'</label>', '', $multi);
showtablefooter();
showformfooter();
echo '<iframe name="threadframe" style="display:none"></iframe>';
showtagfooter('div');
}
} else {
$tidsadd = isset($tids) ? 'tid IN ('.$tids.')' : 'tid IN ('.implodeids($tidarray).')';
if($operation == 'moveforum') {
if(!$db->result_first("SELECT fid FROM {$tablepre}forums WHERE type<>'group' AND fid='$toforum'")) {
cpmsg('threads_move_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}threads SET fid='$toforum' WHERE $tidsadd");
$db->query("UPDATE {$tablepre}posts SET fid='$toforum' WHERE $tidsadd");
foreach(explode(',', $fids.','.$toforum) as $fid) {
updateforumcount(intval($fid));
}
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'movetype') {
if($totype != 0) {
if(!$db->result_first("SELECT typeid FROM {$tablepre}threadtypes WHERE typeid='$totype' AND special='0'")) {
cpmsg('threads_move_invalid', '', 'error');
}
}
$db->query("UPDATE {$tablepre}threads SET typeid='$totype' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'movesort') {
if($tosort != 0) {
if(!$db->result_first("SELECT typeid FROM {$tablepre}threadtypes WHERE typeid='$tosort' AND special='1'")) {
cpmsg('threads_move_invalid', '', 'error');
}
}
$db->query("UPDATE {$tablepre}threads SET sortid='$tosort' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'delete') {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE $tidsadd");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
if(!$donotupdatemember) {
$tuidarray = $ruidarray = array();
$query = $db->query("SELECT first, authorid FROM {$tablepre}posts WHERE $tidsadd");
while($post = $db->fetch_array($query)) {
if($post['first']) {
$tuidarray[] = $post['authorid'];
} else {
$ruidarray[] = $post['authorid'];
}
}
if($tuidarray) {
updatepostcredits('-', $tuidarray, $creditspolicy['post']);
}
if($ruidarray) {
updatepostcredits('-', $ruidarray, $creditspolicy['reply']);
}
}
$db->query("DELETE FROM {$tablepre}attachments WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}posts WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threads WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polloptions WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polls WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}rewardlog WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activities WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}activityapplies WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}debates WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}debateposts WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadsmod WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}relatedthreads WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE $tidsadd", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}videos WHERE $tidsadd", 'UNBUFFERED');
if($globalstick) {
updatecache('globalstick');
}
foreach(explode(',', $fids) as $fid) {
updateforumcount(intval($fid));
}
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'deleteattach') {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE $tidsadd");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE $tidsadd");
$db->query("UPDATE {$tablepre}threads SET attachment='0' WHERE $tidsadd");
$db->query("UPDATE {$tablepre}posts SET attachment='0' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'stick') {
$db->query("UPDATE {$tablepre}threads SET displayorder='$stick_level' WHERE $tidsadd");
if($globalstick) {
updatecache('globalstick');
}
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'adddigest') {
$query = $db->query("SELECT tid, authorid, digest FROM {$tablepre}threads WHERE $tidsadd");
while($thread = $db->fetch_array($query)) {
updatecredits($thread['authorid'], $creditspolicy['digest'], $digest_level - $thread['digest'], 'digestposts=digestposts-1');
}
$db->query("UPDATE {$tablepre}threads SET digest='$digest_level' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
} elseif($operation == 'addstatus') {
$db->query("UPDATE {$tablepre}threads SET closed='$status' WHERE $tidsadd");
eval("\$cpmsg = \"".lang('threads_succeed')."\";");
}
$tids && deletethreadcaches($tids);
$cpmsg = $cpmsg ? "alert('$cpmsg');" : '';
echo '<script type="text/JavaScript">'.$cpmsg.'parent.$(\'threadforum\').searchsubmit.click();</script>';
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/threads.inc.php
|
PHP
|
asf20
| 20,344
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: checktools.inc.php 17391 2008-12-17 06:57:02Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
if($operation == 'filecheck') {
$step = max(1, intval($step));
shownav('tools', 'nav_filecheck');
showsubmenusteps('nav_filecheck', array(
array('nav_filecheck_confirm', $step == 1),
array('nav_filecheck_verify', $step == 2),
array('nav_filecheck_completed', $step == 3)
));
if($step == 1) {
cpmsg($lang[filecheck_tips_step1], $BASESCRIPT.'?action=checktools&operation=filecheck&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(lang('filecheck_verifying'), "$BASESCRIPT?action=checktools&operation=filecheck&step=3", 'loading', '', FALSE);
} elseif($step == 3) {
if(!$discuzfiles = @file('admin/discuzfiles.md5')) {
cpmsg('filecheck_nofound_md5file', '', 'error');
}
$md5data = array();
$cachelist = checkcachefiles('forumdata/cache/');
checkfiles('./', '\.php', 0, 'config.inc.php');
checkfiles('include/', '\.php|\.htm|\.js');
checkfiles('templates/default/', '\.php|\.htm');
checkfiles('wap/', '\.php');
checkfiles('archiver/', '\.php');
checkfiles('api/', '\.php');
checkfiles('plugins/', '\.php');
checkfiles('admin/', '\.php');
checkfiles('modcp/', '\.php');
checkfiles('uc_client/', '\.php', 0);
checkfiles('uc_client/control/', '\.php');
checkfiles('uc_client/model/', '\.php');
checkfiles('uc_client/lib/', '\.php');
foreach($discuzfiles as $line) {
$file = trim(substr($line, 34));
$md5datanew[$file] = substr($line, 0, 32);
if($md5datanew[$file] != $md5data[$file]) {
$modifylist[$file] = $md5data[$file];
}
$md5datanew[$file] = $md5data[$file];
}
$weekbefore = $timestamp - 604800;
$addlist = @array_merge(@array_diff_assoc($md5data, $md5datanew), $cachelist[2]);
$dellist = @array_diff_assoc($md5datanew, $md5data);
$modifylist = @array_merge(@array_diff_assoc($modifylist, $dellist), $cachelist[1]);
$showlist = @array_merge($md5data, $md5datanew, $cachelist[0]);
$doubt = 0;
$dirlist = $dirlog = array();
foreach($showlist as $file => $md5) {
$dir = dirname($file);
if(@array_key_exists($file, $modifylist)) {
$fileststus = 'modify';
} elseif(@array_key_exists($file, $dellist)) {
$fileststus = 'del';
} elseif(@array_key_exists($file, $addlist)) {
$fileststus = 'add';
} else {
$filemtime = @filemtime($file);
if($filemtime > $weekbefore) {
$fileststus = 'doubt';
$doubt++;
} else {
$fileststus = '';
}
}
if(file_exists($file)) {
$filemtime = @filemtime($file);
$fileststus && $dirlist[$fileststus][$dir][basename($file)] = array(number_format(filesize($file)).' Bytes', date("$dateformat $timeformat", $filemtime));
} else {
$fileststus && $dirlist[$fileststus][$dir][basename($file)] = array('', '');
}
}
$result = $resultjs = '';
$dirnum = 0;
foreach($dirlist as $status => $filelist) {
$dirnum++;
$class = $status == 'modify' ? 'edited' : ($status == 'del' ? 'del' : 'unknown');
$result .= '<tbody id="status_'.$status.'" style="display:'.($status != 'modify' ? 'none' : '').'">';
foreach($filelist as $dir => $files) {
$result .= '<tr><td colspan="4"><div class="ofolder">'.$dir.'</div><div class="lightfont filenum left">';
foreach($files as $filename => $file) {
$result .= '<tr><td><em class="files bold">'.$filename.'</em></td><td style="text-align: right">'.$file[0].' </td><td>'.$file[1].'</td><td><em class="'.$class.'"> </em></td></tr>';
}
}
$result .= '</tbody>';
$resultjs .= '$(\'status_'.$status.'\').style.display=\'none\';';
}
$modifiedfiles = count($modifylist);
$deletedfiles = count($dellist);
$unknownfiles = count($addlist);
$doubt = intval($doubt);
$result .= '<script>function showresult(o) {'.$resultjs.'$(\'status_\' + o).style.display=\'\';}</script>';
showtips('filecheck_tips');
showtableheader('filecheck_completed');
showtablerow('', 'colspan="4"', "<div class=\"lightfont filenum left\">".
"<em class=\"edited\">$lang[filecheck_modify]: $modifiedfiles</em> ".($modifiedfiles > 0 ? "<a href=\"###\" onclick=\"showresult('modify')\">[$lang[view]]</a> " : '').
" <em class=\"del\">$lang[filecheck_delete]: $deletedfiles</em> ".($deletedfiles > 0 ? "<a href=\"###\" onclick=\"showresult('del')\">[$lang[view]]</a> " : '').
" <em class=\"unknown\">$lang[filecheck_unknown]: $unknownfiles</em> ".($unknownfiles > 0 ? "<a href=\"###\" onclick=\"showresult('add')\">[$lang[view]]</a> " : '').
($doubt > 0 ? " <em class=\"unknown\">$lang[filecheck_doubt]: $doubt</em> <a href=\"###\" onclick=\"showresult('doubt')\">[$lang[view]]</a> " : '').
"</div>");
showsubtitle(array('filename', '', 'lastmodified', ''));
echo $result;
showtablefooter();
}
} elseif($operation == 'ftpcheck') {
$alertmsg = '';
$testdir = substr(md5('Discuz!' + $timestamp), 12, 8);
$testfile = 'discuztest.txt';
$attach_dir = $attachdir;
if($attachsave) {
$attach_dir .= '/'.$testdir;
if(!@mkdir($attach_dir, 0777)) {
$alertmsg = lang('settings_attach_local_mderr');
}
}
if(!$alertmsg) {
if(!@fclose(fopen($attach_dir.'/'.$testfile, 'w'))) {
$alertmsg = lang('settings_attach_local_uperr');
} else {
@unlink($attach_dir.'/'.$testfile);
}
$attachsave && @rmdir($attach_dir);
}
if(!$alertmsg) {
require_once './include/ftp.func.php';
if(!empty($settingsnew['ftp']['password'])) {
$settings['ftp'] = unserialize($db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='ftp'"));
$settings['ftp']['password'] = authcode($settings['ftp']['password'], 'DECODE', md5($authkey));
$pwlen = strlen($settingsnew['ftp']['password']);
if($settingsnew['ftp']['password']{0} == $settings['ftp']['password']{0} && $settingsnew['ftp']['password']{$pwlen - 1} == $settings['ftp']['password']{strlen($settings['ftp']['password']) - 1} && substr($settingsnew['ftp']['password'], 1, $pwlen - 2) == '********') {
$settingsnew['ftp']['password'] = $settings['ftp']['password'];
}
}
$ftp['pasv'] = intval($settingsnew['ftp']['pasv']);
$ftp_conn_id = dftp_connect($settingsnew['ftp']['host'], $settingsnew['ftp']['username'], $settingsnew['ftp']['password'], $settingsnew['ftp']['attachdir'], $settingsnew['ftp']['port'], $settingsnew['ftp']['ssl'], 1);
switch($ftp_conn_id) {
case '-1':
$alertmsg = $lang['settings_attach_remote_conerr'];
break;
case '-2':
$alertmsg = $lang['settings_attach_remote_logerr'];
break;
case '-3':
$alertmsg = $lang['settings_attach_remote_pwderr'];
break;
case '-4':
$alertmsg = $lang['settings_attach_remote_ftpoff'];
break;
default:
$alertmsg = '';
}
}
if(!$alertmsg) {
if(!dftp_mkdir($ftp_conn_id, $testdir)) {
$alertmsg = $lang['settings_attach_remote_mderr'];
} else {
if(!(function_exists('ftp_chmod') && dftp_chmod($ftp_conn_id, 0777, $testdir)) && !dftp_site($ftp_conn_id, "'CHMOD 0777 $testdir'") && !@ftp_exec($ftp_conn_id, "SITE CHMOD 0777 $testdir")) {
$alertmsg = $lang['settings_attach_remote_chmoderr'].'\n';
}
$testfile = $testdir.'/'.$testfile;
if(!dftp_put($ftp_conn_id, $testfile, DISCUZ_ROOT.'./robots.txt', FTP_BINARY)) {
$alertmsg .= $lang['settings_attach_remote_uperr'];
dftp_delete($ftp_conn_id, $testfile);
dftp_delete($ftp_conn_id, $testfile.'.uploading');
dftp_delete($ftp_conn_id, $testfile.'.abort');
dftp_rmdir($ftp_conn_id, $testdir);
} else {
if(!@readfile($settingsnew['ftp']['attachurl'].'/'.$testfile)) {
$alertmsg .= $lang['settings_attach_remote_geterr'];
dftp_delete($ftp_conn_id, $testfile);
dftp_rmdir($ftp_conn_id, $testdir);
} else {
if(!dftp_delete($ftp_conn_id, $testfile)) {
$alertmsg .= $lang['settings_attach_remote_delerr'];
} else {
dftp_rmdir($ftp_conn_id, $testdir);
$alertmsg = $lang['settings_attach_remote_ok'];
}
}
}
}
}
echo '<script language="javascript">alert(\''.str_replace('\'', '\\\'', $alertmsg).'\');parent.$(\'cpform\').action=\''.$BASESCRIPT.'?action=settings&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif($operation == 'mailcheck') {
$mail = serialize($settingsnew['mail']);
$test_tos = explode(',', $test_to);
$date = date('Y-m-d H:i:s');
$alertmsg = '';
$title = $lang['settings_mailcheck_title_'.$settingsnew['mail']['mailsend']];
$message = $lang['settings_mailcheck_message_'.$settingsnew['mail']['mailsend']].' '.$test_from.$lang['settings_mailcheck_date'].' '.$date;
$bbname = $lang['settings_mail_check_method_1'];
sendmail($test_tos[0], $title.' @ '.$date, "$bbname\n\n\n$message", $test_from);
$bbname = $lang['settings_mail_check_method_2'];
sendmail($test_to, $title.' @ '.$date, "$bbname\n\n\n$message", $test_from);
if(!$alertmsg) {
$alertmsg = $lang['settings_mail_check_success_1']."$title @ $date".$lang['settings_mail_check_success_2'];
} else {
$alertmsg = $lang['settings_mail_check_error'].$alertmsg;
}
echo '<script language="javascript">alert(\''.str_replace(array('\'', "\n", "\r"), array('\\\'', '\n', ''), $alertmsg).'\');parent.$(\'cpform\').action=\''.$BASESCRIPT.'?action=settings&edit=yes\';parent.$(\'cpform\').target=\'_self\'</script>';
} elseif($operation == 'imagepreview') {
if(!empty($previewthumb)) {
$thumbstatus = $settingsnew['thumbstatus'];
if(!$thumbstatus) {
cpmsg('thumbpreview_error', '', 'error');
}
$imagelib = $settingsnew['imagelib'];
$imageimpath = $settingsnew['imageimpath'];
$thumbwidth = $settingsnew['thumbwidth'];
$thumbheight = $settingsnew['thumbheight'];
$thumbquality = $settingsnew['thumbquality'];
require_once DISCUZ_ROOT.'./include/image.class.php';
@unlink(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
$image = new Image('images/admincp/watermarkpreview.jpg', 'images/admincp/watermarkpreview.jpg');
$image->Thumb($thumbwidth, $thumbheight, 1);
if(file_exists(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg')) {
showsubmenu('imagepreview_thumb');
$sizesource = filesize('images/admincp/watermarkpreview.jpg');
$sizetarget = filesize(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
echo '<img src="forumdata/watermark_temp.jpg?'.random(5).'"><br /><br />'.
$lang['imagepreview_imagesize_source'].' '.number_format($sizesource).' Bytes '.
$lang['imagepreview_imagesize_target'].' '.number_format($sizetarget).' Bytes ('.
(sprintf("%2.1f", $sizetarget / $sizesource * 100)).'%)';
} else {
cpmsg('thumbpreview_createerror', '', 'error');
}
} else {
$watermarkstatus = $settingsnew['watermarkstatus'];
if(!$watermarkstatus) {
cpmsg('watermarkpreview_error', '', 'error');
}
$imagelib = $settingsnew['imagelib'];
$imageimpath = $settingsnew['imageimpath'];
$watermarktype = $settingsnew['watermarktype'];
$watermarktrans = $settingsnew['watermarktrans'];
$watermarkquality = $settingsnew['watermarkquality'];
$watermarkminwidth = $settingsnew['watermarkminwidth'];
$watermarkminheight = $settingsnew['watermarkminheight'];
$settingsnew['watermarktext']['size'] = intval($settingsnew['watermarktext']['size']);
$settingsnew['watermarktext']['angle'] = intval($settingsnew['watermarktext']['angle']);
$settingsnew['watermarktext']['shadowx'] = intval($settingsnew['watermarktext']['shadowx']);
$settingsnew['watermarktext']['shadowy'] = intval($settingsnew['watermarktext']['shadowy']);
$settingsnew['watermarktext']['translatex'] = intval($settingsnew['watermarktext']['translatex']);
$settingsnew['watermarktext']['translatey'] = intval($settingsnew['watermarktext']['translatey']);
$settingsnew['watermarktext']['skewx'] = intval($settingsnew['watermarktext']['skewx']);
$settingsnew['watermarktext']['skewy'] = intval($settingsnew['watermarktext']['skewy']);
$settingsnew['watermarktext']['fontpath'] = str_replace(array('\\', '/'), '', $settingsnew['watermarktext']['fontpath']);
$settingsnew['watermarktext']['color'] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $settingsnew['watermarktext']['color']);
$settingsnew['watermarktext']['shadowcolor'] = preg_replace('/#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/e', "hexdec('\\1').','.hexdec('\\2').','.hexdec('\\3')", $settingsnew['watermarktext']['shadowcolor']);
if($watermarktype == 2) {
if($settingsnew['watermarktext']['fontpath']) {
$fontpath = $settingsnew['watermarktext']['fontpath'];
$fontpathnew = 'ch/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
if(!$settingsnew['watermarktext']['fontpath']) {
$fontpathnew = 'en/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
}
if(!$settingsnew['watermarktext']['fontpath']) {
cpmsg('watermarkpreview_fontpath_error', '', 'error');
}
$settingsnew['watermarktext']['fontpath'] = 'images/fonts/'.$settingsnew['watermarktext']['fontpath'];
}
if($settingsnew['watermarktext']['text'] && strtoupper($charset) != 'UTF-8') {
include DISCUZ_ROOT.'include/chinese.class.php';
$c = new Chinese($charset, 'utf8');
$settingsnew['watermarktext']['text'] = $c->Convert($settingsnew['watermarktext']['text']);
}
$settingsnew['watermarktext']['text'] = bin2hex($settingsnew['watermarktext']['text']);
$watermarktext = $settingsnew['watermarktext'];
}
require_once DISCUZ_ROOT.'./include/image.class.php';
@unlink(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
$image = new Image('images/admincp/watermarkpreview.jpg', 'images/admincp/watermarkpreview.jpg');
$image->Watermark(1);
if(file_exists(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg')) {
showsubmenu('imagepreview_watermark');
$sizesource = filesize('images/admincp/watermarkpreview.jpg');
$sizetarget = filesize(DISCUZ_ROOT.'./forumdata/watermark_temp.jpg');
echo '<img src="forumdata/watermark_temp.jpg?'.random(5).'"><br /><br />'.
$lang['imagepreview_imagesize_source'].' '.number_format($sizesource).' Bytes '.
$lang['imagepreview_imagesize_target'].' '.number_format($sizetarget).' Bytes ('.
(sprintf("%2.1f", $sizetarget / $sizesource * 100)).'%)';
} else {
cpmsg('watermarkpreview_createerror', '', 'error');
}
}
}
function checkfiles($currentdir, $ext = '', $sub = 1, $skip = '') {
global $md5data;
$dir = @opendir(DISCUZ_ROOT.$currentdir);
$exts = '/('.$ext.')$/i';
$skips = explode(',', $skip);
while($entry = @readdir($dir)) {
$file = $currentdir.$entry;
if($entry != '.' && $entry != '..' && (preg_match($exts, $entry) || $sub && is_dir($file)) && !in_array($entry, $skips)) {
if($sub && is_dir($file)) {
checkfiles($file.'/', $ext, $sub, $skip);
} else {
$md5data[$file] = md5_file($file);
}
}
}
}
function checkcachefiles($currentdir) {
global $authkey;
$dir = opendir($currentdir);
$exts = '/\.php$/i';
$showlist = $modifylist = $addlist = array();
while($entry = readdir($dir)) {
$file = $currentdir.$entry;
if($entry != '.' && $entry != '..' && preg_match($exts, $entry)) {
$fp = fopen($file, "rb");
$cachedata = fread($fp, filesize($file));
fclose($fp);
if(preg_match("/^<\?php\n\/\/Discuz! cache file, DO NOT modify me!\n\/\/Created: [\w\s,:]+\n\/\/Identify: (\w{32})\n\n(.+?)\?>$/s", $cachedata, $match)) {
$showlist[$file] = $md5 = $match[1];
$cachedata = $match[2];
if(md5($entry.$cachedata.$authkey) != $md5) {
$modifylist[$file] = $md5;
}
} else {
$showlist[$file] = $addlist[$file] = '';
}
}
}
return array($showlist, $modifylist, $addlist);
}
function checkmailerror($type, $error) {
global $alertmsg;
$alertmsg .= !$alertmsg ? $error : '';
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/checktools.inc.php
|
PHP
|
asf20
| 16,528
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: db.inc.php 17527 2009-01-13 03:05:52Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$tabletype = $db->version() > '4.1' ? 'Engine' : 'Type';
require_once DISCUZ_ROOT.'./include/attachment.func.php';
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$excepttables = array($tablepre.'adminsessions', $tablepre.'failedlogins', $tablepre.'pmsearchindex', $tablepre.'relatedthreads', $tablepre.'rsscaches', $tablepre.'searchindex', $tablepre.'spacecaches', $tablepre.'sessions');
if(!$backupdir = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='backupdir'")) {
$backupdir = random(6);
@mkdir('./forumdata/backup_'.$backupdir, 0777);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) values ('backupdir', '$backupdir')");
}
$backupdir = 'backup_'.$backupdir;
if(!is_dir('./forumdata/'.$backupdir)) {
mkdir('./forumdata/'.$backupdir, 0777);
}
if($operation == 'export') {
if(!submitcheck('exportsubmit', 1)) {
$shelldisabled = function_exists('shell_exec') ? '' : 'disabled';
$tables = '';
$dztables = array();
if($tables = $db->fetch_first("SELECT value FROM {$tablepre}settings WHERE variable='custombackup'")) {
$tables = unserialize($tables['value']);
$tables = is_array($tables) ? $tables : '';
}
$discuz_tables = fetchtablelist($tablepre);
$query = $db->query("SELECT datatables FROM {$tablepre}plugins WHERE datatables<>''");
while($plugin = $db->fetch_array($query)) {
foreach(explode(',', $plugin['datatables']) as $table) {
if($table = trim($table)) {
$discuz_tables[] = array('Name' => $table);
}
}
}
foreach($discuz_tables as $table) {
$dztables[$table[Name]] = $table[Name];
}
$defaultfilename = date('ymd').'_'.random(8);
shownav('tools', 'nav_db', 'nav_db_export');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 1),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_export_tips');
showformheader('db&operation=export&setup=1');
showtableheader();
showsetting('db_export_type', array('type', array(
array('discuz', $lang['db_export_discuz'], array('showtables' => 'none')),
array('custom', $lang['db_export_custom'], array('showtables' => ''))
)), 'discuz', 'mradio');
showtagheader('tbody', 'showtables');
showtablerow('', '', '<input class="checkbox" name="chkall" onclick="checkAll(\'prefix\', this.form, \'customtables\', \'chkall\', true)" checked="checked" type="checkbox" id="chkalltables" /><label for="chkalltables"> '.lang('db_export_custom_select_all').' - '.lang('db_export_discuz_table')).'</label>';
showtablerow('', 'colspan="2"', mcheckbox('customtables', $dztables));
showtagfooter('tbody');
showtagheader('tbody', 'advanceoption');
showsetting('db_export_method', '', '', '<ul class="nofloat"><li><input class="radio" type="radio" name="method" value="shell" '.$shelldisabled.' onclick="if(\''.intval($db->version() < '4.1').'\') {if(this.form.sqlcompat[2].checked==true) this.form.sqlcompat[0].checked=true; this.form.sqlcompat[2].disabled=true; this.form.sizelimit.disabled=true;} else {this.form.sqlcharset[0].checked=true; for(var i=1; i<=5; i++) {if(this.form.sqlcharset[i]) this.form.sqlcharset[i].disabled=true;}}" id="method_shell" /><label="method_shell"> '.$lang['db_export_shell'].'</label></li><li><input class="radio" type="radio" name="method" value="multivol" checked="checked" onclick="this.form.sqlcompat[2].disabled=false; this.form.sizelimit.disabled=false; for(var i=1; i<=5; i++) {if(this.form.sqlcharset[i]) this.form.sqlcharset[i].disabled=false;}" id="method_multivol" /><label for="method_multivol"> '.$lang['db_export_multivol'].'</label> <input type="text" class="txt" size="40" name="sizelimit" value="2048" /></li></ul>');
showtitle('db_export_options');
showsetting('db_export_options_extended_insert', 'extendins', 0, 'radio');
showsetting('db_export_options_sql_compatible', array('sqlcompat', array(
array('', $lang['default']),
array('MYSQL40', 'MySQL 3.23/4.0.x'),
array('MYSQL41', 'MySQL 4.1.x/5.x')
)), '', 'mradio');
showsetting('db_export_options_charset', array('sqlcharset', array(
array('', lang('default')),
$dbcharset ? array($dbcharset, strtoupper($dbcharset)) : array(),
$db->version() > '4.1' && $dbcharset != 'utf8' ? array('utf8', 'UTF-8') : array()
), TRUE), 0, 'mradio');
showsetting('db_export_usehex', 'usehex', 1, 'radio');
if(function_exists('gzcompress')) {
showsetting('db_export_usezip', array('usezip', array(
array('1', $lang['db_export_zip_1']),
array('2', $lang['db_export_zip_2']),
array('0', $lang['db_export_zip_3'])
)), 0, 'mradio');
}
showsetting('db_export_filename', '', '', '<input type="text" class="txt" name="filename" value="'.$defaultfilename.'" />.sql');
showtagfooter('tbody');
showsubmit('exportsubmit', 'submit', '', 'more_options');
showtablefooter();
showformfooter();
} else {
$db->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');
if(!$filename || preg_match("/(\.)(exe|jsp|asp|aspx|cgi|fcgi|pl)(\.|$)/i", $filename)) {
cpmsg('database_export_filename_invalid', '', 'error');
}
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
if($type == 'discuz') {
$tables = arraykeys2(fetchtablelist($tablepre), 'Name');
} elseif($type == 'custom') {
$tables = array();
if(empty($setup)) {
if($tables = $db->fetch_first("SELECT value FROM {$tablepre}settings WHERE variable='custombackup'")) {
$tables = unserialize($tables['value']);
}
} else {
$customtablesnew = empty($customtables)? '' : addslashes(serialize($customtables));
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('custombackup', '$customtablesnew')");
$tables = & $customtables;
}
if( !is_array($tables) || empty($tables)) {
cpmsg('database_export_custom_invalid', '', 'error');
}
}
$query = $db->query("SELECT datatables FROM {$tablepre}plugins WHERE datatables<>''");
while($plugin = $db->fetch_array($query)) {
foreach(explode(',', $plugin['datatables']) as $table) {
if($table = trim($table)) {
$tables[] = $table;
}
}
}
$volume = intval($volume) + 1;
$idstring = '# Identify: '.base64_encode("$timestamp,$version,$type,$method,$volume")."\n";
$dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', $GLOBALS['charset']);
$setnames = ($sqlcharset && $db->version() > '4.1' && (!$sqlcompat || $sqlcompat == 'MYSQL41')) ? "SET NAMES '$dumpcharset';\n\n" : '';
if($db->version() > '4.1') {
if($sqlcharset) {
$db->query("SET NAMES '".$sqlcharset."';\n\n");
}
if($sqlcompat == 'MYSQL40') {
$db->query("SET SQL_MODE='MYSQL40'");
} elseif($sqlcompat == 'MYSQL41') {
$db->query("SET SQL_MODE=''");
}
}
$backupfilename = './forumdata/'.$backupdir.'/'.str_replace(array('/', '\\', '.'), '', $filename);
if($usezip) {
require_once DISCUZ_ROOT.'admin/zip.func.php';
}
if($method == 'multivol') {
$sqldump = '';
$tableid = intval($tableid);
$startfrom = intval($startfrom);
$complete = TRUE;
for(; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) {
$sqldump .= sqldumptable($tables[$tableid], $startfrom, strlen($sqldump));
if($complete) {
$startfrom = 0;
}
}
$dumpfile = $backupfilename."-%s".'.sql';
!$complete && $tableid--;
if(trim($sqldump)) {
$sqldump = "$idstring".
"# <?exit();?>\n".
"# Discuz! Multi-Volume Data Dump Vol.$volume\n".
"# Version: Discuz! $version\n".
"# Time: $time\n".
"# Type: $type\n".
"# Table Prefix: $tablepre\n".
"#\n".
"# Discuz! Home: http://www.discuz.com\n".
"# Please visit our website for newest infomation about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
"$setnames".
$sqldump;
$dumpfilename = sprintf($dumpfile, $volume);
@$fp = fopen($dumpfilename, 'wb');
@flock($fp, 2);
if(@!fwrite($fp, $sqldump)) {
@fclose($fp);
cpmsg('database_export_file_invalid', '', 'error');
} else {
fclose($fp);
if($usezip == 2) {
$fp = fopen($dumpfilename, "r");
$content = @fread($fp, filesize($dumpfilename));
fclose($fp);
$zip = new zipfile();
$zip->addFile($content, basename($dumpfilename));
$fp = fopen(sprintf($backupfilename."-%s".'.zip', $volume), 'w');
if(@fwrite($fp, $zip->file()) !== FALSE) {
@unlink($dumpfilename);
}
fclose($fp);
}
unset($sqldump, $zip, $content);
cpmsg('database_export_multivol_redirect', "$BASESCRIPT?action=db&operation=export&type=".rawurlencode($type)."&saveto=server&filename=".rawurlencode($filename)."&method=multivol&sizelimit=".rawurlencode($sizelimit)."&volume=".rawurlencode($volume)."&tableid=".rawurlencode($tableid)."&startfrom=".rawurlencode($startrow)."&extendins=".rawurlencode($extendins)."&sqlcharset=".rawurlencode($sqlcharset)."&sqlcompat=".rawurlencode($sqlcompat)."&exportsubmit=yes&usehex=$usehex&usezip=$usezip", 'loading');
}
} else {
$volume--;
$filelist = '<ul>';
cpheader();
if($usezip == 1) {
$zip = new zipfile();
$zipfilename = $backupfilename.'.zip';
$unlinks = '';
for($i = 1; $i <= $volume; $i++) {
$filename = sprintf($dumpfile, $i);
$fp = fopen($filename, "r");
$content = @fread($fp, filesize($filename));
fclose($fp);
$zip->addFile($content, basename($filename));
$unlinks .= "@unlink('$filename');";
$filelist .= "<li><a href=\"$filename\">$filename\n";
}
$fp = fopen($zipfilename, 'w');
if(@fwrite($fp, $zip->file()) !== FALSE) {
eval($unlinks);
} else {
cpmsg('database_export_multivol_succeed', '', 'succeed');
}
unset($sqldump, $zip, $content);
fclose($fp);
@touch('./forumdata/'.$backupdir.'/index.htm');
$filename = $zipfilename;
cpmsg('database_export_zip_succeed', '', 'succeed');
} else {
@touch('./forumdata/'.$backupdir.'/index.htm');
for($i = 1; $i <= $volume; $i++) {
$filename = sprintf($usezip == 2 ? $backupfilename."-%s".'.zip' : $dumpfile, $i);
$filelist .= "<li><a href=\"$filename\">$filename\n";
}
cpmsg('database_export_multivol_succeed', '', 'succeed');
}
}
} else {
$tablesstr = '';
foreach($tables as $table) {
$tablesstr .= '"'.$table.'" ';
}
require './config.inc.php';
list($dbhost, $dbport) = explode(':', $dbhost);
$query = $db->query("SHOW VARIABLES LIKE 'basedir'");
list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);
$dumpfile = addslashes(dirname(dirname(__FILE__))).'/'.$backupfilename.'.sql';
@unlink($dumpfile);
$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
@shell_exec($mysqlbin.'mysqldump --force --quick '.($db->version() > '4.1' ? '--skip-opt --create-options' : '-all').' --add-drop-table'.($extendins == 1 ? ' --extended-insert' : '').''.($db->version() > '4.1' && $sqlcompat == 'MYSQL40' ? ' --compatible=mysql40' : '').' --host="'.$dbhost.($dbport ? (is_numeric($dbport) ? ' --port='.$dbport : ' --socket="'.$dbport.'"') : '').'" --user="'.$dbuser.'" --password="'.$dbpw.'" "'.$dbname.'" '.$tablesstr.' > '.$dumpfile);
if(@file_exists($dumpfile)) {
if($usezip) {
require_once DISCUZ_ROOT.'admin/zip.func.php';
$zip = new zipfile();
$zipfilename = $backupfilename.'.zip';
$fp = fopen($dumpfile, "r");
$content = @fread($fp, filesize($dumpfile));
fclose($fp);
$zip->addFile($idstring."# <?exit();?>\n ".$setnames."\n #".$content, basename($dumpfile));
$fp = fopen($zipfilename, 'w');
@fwrite($fp, $zip->file());
fclose($fp);
@unlink($dumpfile);
@touch('./forumdata/'.$backupdir.'/index.htm');
$filename = $backupfilename.'.zip';
unset($sqldump, $zip, $content);
cpmsg('database_export_zip_succeed', '', 'succeed');
} else {
if(@is_writeable($dumpfile)) {
$fp = fopen($dumpfile, 'rb+');
@fwrite($fp, $idstring."# <?exit();?>\n ".$setnames."\n #");
fclose($fp);
}
@touch('./forumdata/'.$backupdir.'/index.htm');
$filename = $backupfilename.'.sql';
cpmsg('database_export_succeed', '', 'succeed');
}
} else {
cpmsg('database_shell_fail', '', 'error');
}
}
}
} elseif($operation == 'importzip') {
if(empty($datafile_server)) {
cpmsg('database_import_file_illegal', '', 'error');
} else {
$datafile_server = DISCUZ_ROOT.'./forumdata/'.$backupdir.'/'.basename($datafile_server);
if(!@file_exists($datafile_server)) {
cpmsg('database_import_file_illegal', '', 'error');
}
}
require_once DISCUZ_ROOT.'admin/zip.func.php';
$unzip = new SimpleUnzip();
$unzip->ReadFile($datafile_server);
if($unzip->Count() == 0 || $unzip->GetError(0) != 0 || !preg_match("/\.sql$/i", $importfile = $unzip->GetName(0))) {
cpmsg('database_import_file_illegal', '', 'error');
}
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", substr($unzip->GetData(0), 0, 256))));
$confirm = !empty($confirm) ? 1 : 0;
if(!$confirm && $identify[1] != $version) {
cpmsg('database_import_confirm', $BASESCRIPT.'?action=db&operation=importzip&datafile_server=$datafile_server&importsubmit=yes&confirm=yes', 'form');
}
$sqlfilecount = 0;
foreach($unzip->Entries as $entry) {
if(preg_match("/\.sql$/i", $entry->Name)) {
$fp = fopen('./forumdata/'.$backupdir.'/'.$entry->Name, 'w');
fwrite($fp, $entry->Data);
fclose($fp);
$sqlfilecount++;
}
}
if(!$sqlfilecount) {
cpmsg('database_import_file_illegal', '', 'error');
}
$info = basename($datafile_server).'<br />'.$lang['version'].': '.$identify[1].'<br />'.$lang['type'].': '.$lang['db_export_'.$identify[2]].'<br />'.$lang['db_method'].': '.($identify[3] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell']).'<br />';
if(isset($multivol)) {
$multivol++;
$datafile_server = preg_replace("/-(\d+)(\..+)$/", "-$multivol\\2", $datafile_server);
if(file_exists($datafile_server)) {
cpmsg('database_import_multivol_unzip_redirect', $BASESCRIPT.'?action=db&operation=importzip&multivol='.$multivol.'&datafile_vol1='.$datafile_vol1.'&datafile_server='.$datafile_server.'&importsubmit=yes&confirm=yes', 'loading');
} else {
cpmsg('database_import_multivol_confirm', $BASESCRIPT.'?action=db&operation=import&from=server&datafile_server='.$datafile_vol1.'&importsubmit=yes&delunzip=yes', 'form');
}
}
if($identify[3] == 'multivol' && $identify[4] == 1 && preg_match("/-1(\..+)$/", $datafile_server)) {
$datafile_vol1 = $datafile_server;
$datafile_server = preg_replace("/-1(\..+)$/", "-2\\1", $datafile_server);
if(file_exists($datafile_server)) {
cpmsg('database_import_multivol_unzip', $BASESCRIPT.'?action=db&operation=importzip&multivol=1&datafile_vol1=./forumdata/'.$backupdir.'/'.$importfile.'&datafile_server='.$datafile_server.'&importsubmit=yes&confirm=yes', 'form');
}
}
cpmsg('database_import_unzip', $BASESCRIPT.'?action=db&operation=import&from=server&datafile_server=./forumdata/'.$backupdir.'/'.$importfile.'&importsubmit=yes&delunzip=yes', 'form');
} elseif($operation == 'import') {
checkpermission('dbimport');
if(!submitcheck('importsubmit', 1) && !submitcheck('deletesubmit')) {
$exportlog = $exportsize = $exportziplog = array();
if(is_dir(DISCUZ_ROOT.'./forumdata/'.$backupdir)) {
$dir = dir(DISCUZ_ROOT.'./forumdata/'.$backupdir);
while($entry = $dir->read()) {
$entry = './forumdata/'.$backupdir.'/'.$entry;
if(is_file($entry)) {
if(preg_match("/\.sql$/i", $entry)) {
$filesize = filesize($entry);
$fp = fopen($entry, 'rb');
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", fgets($fp, 256))));
fclose($fp);
$key = preg_replace('/^(.+?)(\-\d+)\.sql$/i', '\\1', basename($entry));
$exportlog[$key][$identify[4]] = array(
'version' => $identify[1],
'type' => $identify[2],
'method' => $identify[3],
'volume' => $identify[4],
'filename' => $entry,
'dateline' => filemtime($entry),
'size' => $filesize
);
$exportsize[$key] += $filesize;
} elseif(preg_match("/\.zip$/i", $entry)) {
$filesize = filesize($entry);
$exportziplog[] = array(
'type' => 'zip',
'filename' => $entry,
'size' => filesize($entry),
'dateline' => filemtime($entry)
);
}
}
}
$dir->close();
} else {
cpmsg('database_export_dest_invalid', '', 'error');
}
shownav('tools', 'nav_db', 'nav_db_import');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 1),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_import_tips');
showtableheader('db_import');
showformheader('db&operation=import', 'enctype');
showtablerow('', array('colspan="2" class="rowform"', 'colspan="7" class="rowform"'), array(
'<input class="radio" type="radio" name="from" value="server" checked="checked" onclick="this.form.datafile_server.disabled=!this.checked;this.form.datafile.disabled=this.checked" />'.$lang[db_import_from_server],
'<input type="text" class="txt" name="datafile_server" value="./forumdata/'.$backupdir.'/" style="width:245px;" />'
));
showtablerow('', array('colspan="2" class="rowform"', 'colspan="8" class="rowform"'), array(
'<input class="radio" type="radio" name="from" value="local" onclick="this.form.datafile_server.disabled=this.checked;this.form.datafile.disabled=!this.checked" />'.$lang[db_import_from_local],
'<input type="file" name="datafile" size="29" disabled="disabled" class="uploadbtn marginbot" />'
));
showsubmit('importsubmit');
showformfooter();
showformheader('db&operation=import');
showtitle('db_export_file');
showsubtitle(array('', 'filename', 'version', 'time', 'type', 'size', 'db_method', 'db_volume', ''));
foreach($exportlog as $key => $val) {
$info = $val[1];
$info['dateline'] = is_int($info['dateline']) ? gmdate("$dateformat $timeformat", $info['dateline'] + $timeoffset * 3600) : $lang['unknown'];
$info['size'] = sizecount($exportsize[$key]);
$info['volume'] = count($val);
$info['method'] = $info['type'] != 'zip' ? ($info['method'] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell']) : '';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"".$key."\">",
"<a href=\"javascript:;\" onclick=\"display_detail('exportlog_$key')\">".$key."</a>",
$info['version'],
$info['dateline'],
$lang['db_export_'.$info['type']],
$info['size'],
$info['method'],
$info['volume'],
$info['type'] == 'zip' ? "<a href=\"$BASESCRIPT?action=db&operation=importzip&datafile_server=$info[filename]&importsubmit=yes\" class=\"act\">$lang[db_import_unzip]</a>" : "<a class=\"act\" href=\"$BASESCRIPT?action=db&operation=import&from=server&datafile_server=$info[filename]&importsubmit=yes\"".($info['version'] != $version ? " onclick=\"return confirm('$lang[db_import_confirm]');\"" : '')." class=\"act\">$lang[import]</a>"
));
echo '<tbody id="exportlog_'.$key.'" style="display:none">';
foreach($val as $info) {
$info['dateline'] = is_int($info['dateline']) ? gmdate("$dateformat $timeformat", $info['dateline'] + $timeoffset * 3600) : $lang['unknown'];
$info['size'] = sizecount($info['size']);
showtablerow('', '', array(
'',
"<a href=\"$info[filename]\">".substr(strrchr($info['filename'], "/"), 1)."</a>",
$info['version'],
$info['dateline'],
'',
$info['size'],
'',
$info['volume'],
''
));
}
echo '</tbody>';
}
foreach($exportziplog as $info) {
$info['dateline'] = is_int($info['dateline']) ? gmdate("$dateformat $timeformat", $info['dateline'] + $timeoffset * 3600) : $lang['unknown'];
$info['size'] = sizecount($info['size']);
$info['method'] = $info['method'] == 'multivol' ? $lang['db_multivol'] : $lang['db_shell'];
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"".basename($info['filename'])."\">",
"<a href=\"$info[filename]\">".substr(strrchr($info['filename'], "/"), 1)."</a>",
'',
$info['dateline'],
$lang['db_export_'.$info['type']],
$info['size'],
$info['method'],
'',
"<a href=\"$BASESCRIPT?action=db&operation=importzip&datafile_server=$info[filename]&importsubmit=yes\" class=\"act\">$lang[db_import_unzip]</a>"
));
}
showsubmit('deletesubmit', 'submit', 'del');
showformfooter();
showtablefooter();
} elseif(submitcheck('importsubmit', 1)) {
$readerror = 0;
$datafile = '';
if($from == 'server') {
$datafile = DISCUZ_ROOT.'./'.$datafile_server;
}
if(@$fp = fopen($datafile, 'rb')) {
$sqldump = fgets($fp, 256);
$identify = explode(',', base64_decode(preg_replace("/^# Identify:\s*(\w+).*/s", "\\1", $sqldump)));
$dumpinfo = array('method' => $identify[3], 'volume' => intval($identify[4]));
if($dumpinfo['method'] == 'multivol') {
$sqldump .= fread($fp, filesize($datafile));
}
fclose($fp);
} else {
if($autoimport) {
updatecache();
cpmsg('database_import_multivol_succeed', '', 'succeed');
} else {
cpmsg('database_import_file_illegal', '', 'error');
}
}
if($dumpinfo['method'] == 'multivol') {
$sqlquery = splitsql($sqldump);
unset($sqldump);
foreach($sqlquery as $sql) {
$sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
if($sql != '') {
$db->query($sql, 'SILENT');
if(($sqlerror = $db->error()) && $db->errno() != 1062) {
$db->halt('MySQL Query Error', $sql);
}
}
}
if($delunzip) {
@unlink($datafile_server);
}
$datafile_next = preg_replace("/-($dumpinfo[volume])(\..+)$/", "-".($dumpinfo['volume'] + 1)."\\2", $datafile_server);
if($dumpinfo['volume'] == 1) {
cpmsg('database_import_multivol_prompt',
"$BASESCRIPT?action=db&operation=import&from=server&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : ''),
'form');
} elseif($autoimport) {
cpmsg('database_import_multivol_redirect', "$BASESCRIPT?action=db&operation=import&from=server&datafile_server=$datafile_next&autoimport=yes&importsubmit=yes".(!empty($delunzip) ? '&delunzip=yes' : ''), 'loading');
} else {
updatecache();
cpmsg('database_import_succeed', '', 'succeed');
}
} elseif($dumpinfo['method'] == 'shell') {
require './config.inc.php';
list($dbhost, $dbport) = explode(':', $dbhost);
$query = $db->query("SHOW VARIABLES LIKE 'basedir'");
list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);
$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
shell_exec($mysqlbin.'mysql -h"'.$dbhost.($dbport ? (is_numeric($dbport) ? ' -P'.$dbport : ' -S"'.$dbport.'"') : '').
'" -u"'.$dbuser.'" -p"'.$dbpw.'" "'.$dbname.'" < '.$datafile);
updatecache();
cpmsg('database_import_succeed', '', 'succeed');
} else {
cpmsg('database_import_format_illegal', '', 'error');
}
} elseif(submitcheck('deletesubmit')) {
if(is_array($delete)) {
foreach($delete as $filename) {
$file_path = './forumdata/'.$backupdir.'/'.str_replace(array('/', '\\'), '', $filename);
if(is_file($file_path)) {
@unlink($file_path);
} else {
$i = 1;
while(1) {
$file_path = './forumdata/'.$backupdir.'/'.str_replace(array('/', '\\'), '', $filename.'-'.$i.'.sql');
if(is_file($file_path)) {
@unlink($file_path);
$i++;
} else {
break;
}
}
}
}
cpmsg('database_file_delete_succeed', '', 'succeed');
} else {
cpmsg('database_file_delete_invalid', '', 'error');
}
}
} elseif($operation == 'runquery') {
$checkperm = checkpermission('runquery', 0);
$runquerys = array();
@include_once(DISCUZ_ROOT.'admin/quickqueries.inc.php');
if(!submitcheck('sqlsubmit')) {
$runqueryselect = '';
foreach($simplequeries as $key => $query) {
if(empty($query['sql'])) {
$runqueryselect .= "<optgroup label=\"$query[comment]\">";
} else {
$runqueryselect .= '<option value="'.$key.'">'.$query['comment'].'</option>';
}
}
if($runqueryselect) {
$runqueryselect = '<select name="queryselect" style="width:500px">'.$runqueryselect.'</select>';
}
$queries = $queryselect ? $runquerys[$queryselect] : '';
shownav('tools', 'nav_db', 'nav_db_runquery');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 1),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_runquery_tips');
showtableheader();
showformheader('db&operation=runquery&option=simple');
showsetting('db_runquery_simply', '', '', $runqueryselect);
showsetting('', '', '', '<input type="checkbox" class="checkbox" name="createcompatible" value="1" checked="checked" />'.lang('db_runquery_createcompatible'));
showsubmit('sqlsubmit');
showformfooter();
if($checkperm) {
showformheader('db&operation=runquery&option=');
showsetting('db_runquery_sql', '', '', '<textarea cols="85" rows="10" name="queries" style="width:500px;">'.$queries.'</textarea>');
showsetting('', '', '', '<input type="checkbox" class="checkbox" name="createcompatible" value="1" checked="checked" />'.lang('db_runquery_createcompatible'));
showsubmit('sqlsubmit', 'submit', '', lang('db_runquery_comment'));
showformfooter();
}
showtablefooter();
} else {
if($option == 'simple') {
$queryselect = intval($queryselect);
$queries = isset($simplequeries[$queryselect]) && $simplequeries[$queryselect]['sql'] ? $simplequeries[$queryselect]['sql'] : '';
} elseif(!$checkperm) {
cpmsg('database_run_query_denied', '', 'error');
}
$sqlquery = splitsql(str_replace(array(' cdb_', ' {tablepre}', ' `cdb_'), array(' '.$tablepre, ' '.$tablepre, ' `'.$tablepre), $queries));
$affected_rows = 0;
foreach($sqlquery as $sql) {
if(trim($sql) != '') {
$sql = !empty($createcompatible) ? syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset) : $sql;
$db->query(stripslashes($sql), 'SILENT');
if($sqlerror = $db->error()) {
break;
} else {
$affected_rows += intval($db->affected_rows());
}
}
}
$sqlerror ? cpmsg('database_run_query_invalid', '', 'error') : cpmsg('database_run_query_succeed', '', 'succeed');
}
} elseif($operation == 'optimize') {
$optimizetable = '';
$totalsize = 0;
$tablearray = array( 0 =>$tablepre);
shownav('tools', 'nav_db', 'nav_db_optimize');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 1),
array('nav_db_dbcheck', 'db&operation=dbcheck', 0)
));
showtips('db_optimize_tips');
showformheader('db&operation=optimize');
showtableheader('db_optimize_tables');
showsubtitle(array('', 'db_optimize_table_name', 'type', 'db_optimize_rows', 'db_optimize_data', 'db_optimize_index', 'db_optimize_frag'));
if(!submitcheck('optimizesubmit')) {
foreach($tablearray as $tp) {
$query = $db->query("SHOW TABLE STATUS LIKE '$tp%'", 'SILENT');
while($table = $db->fetch_array($query)) {
if($table['Data_free'] && $table[$tabletype] == 'MyISAM') {
$checked = $table[$tabletype] == 'MyISAM' ? 'checked' : 'disabled';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"optimizetables[]\" value=\"$table[Name]\" $checked>",
$table[Name],
$table[$tabletype],
$table[Rows],
$table[Data_length],
$table[Index_length],
$table[Data_free],
));
$totalsize += $table['Data_length'] + $table['Index_length'];
}
}
}
if(empty($totalsize)) {
showtablerow('', 'colspan="6"', $lang['db_optimize_done']);
} else {
showtablerow('', 'colspan="6"', $lang['db_optimize_used'].' '.sizecount($totalsize));
showsubmit('optimizesubmit', 'submit', '<input name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form)" checked="checked" type="checkbox" /><label for="chkall">'.$lang[db_optimize_opt].'</label>');
}
} else {
//$db->query("DELETE FROM {$tablepre}subscriptions", 'UNBUFFERED');
//$db->query("UPDATE {$tablepre}memberfields SET authstr=''", 'UNBUFFERED');
foreach($tablearray as $tp) {
$query = $db->query("SHOW TABLE STATUS LIKE '$tp%'", 'SILENT');
while($table = $db->fetch_array($query)) {
if(is_array($optimizetables) && in_array($table['Name'], $optimizetables)) {
$db->query("OPTIMIZE TABLE $table[Name]");
}
showtablerow('', '', array(
$table[Name],
$db->version() > '4.1' ? $table['Engine'] : $table['Type'],
$table[Rows],
$table[Data_length],
$table[Index_length],
0
));
$totalsize += $table['Data_length'] + $table['Index_length'];
}
}
showtablerow('', 'colspan="6"', $lang['db_optimize_used'].' '.sizecount($totalsize));
}
showtablefooter();
showformfooter();
} elseif($operation == 'dbcheck') {
if(!$db->query("SHOW FIELDS FROM {$tablepre}settings", 'SILENT')) {
cpmsg('dbcheck_permissions_invalid', '', 'error');
}
$step = max(1, intval($step));
if($step == 3) {
if(!file_exists('admin/discuzdb.md5')) {
cpmsg('dbcheck_nofound_md5file', '', 'error');
}
include DISCUZ_ROOT.'./config.inc.php';
$dbcharset = empty($dbcharset) ? $charset : $dbcharset;
unset($dbuser, $dbpw, $dbname);
$fp = fopen(DISCUZ_ROOT.'./admin/discuzdb.md5', "rb");
$discuzdb = fread($fp, filesize(DISCUZ_ROOT.'./admin/discuzdb.md5'));
fclose($fp);
$dbmd5 = substr($discuzdb, 0, 32);
$discuzdb = unserialize(substr($discuzdb, 34));
$settingsdata = $discuzdb[1];
$discuzdb = $discuzdb[0][0];
$repair = !empty($repair) ? $repair : array();
$setting = !empty($setting) ? $setting : array();
$missingtable = !empty($missingtable) ? $missingtable : array();
$repairtable = is_array($repairtable) && !empty($repairtable) ? $repairtable : array();
$except = array('threads' => array('sgid'));
$query = $db->query("SELECT fieldid FROM {$tablepre}profilefields");
while($profilefields = $db->fetch_array($query)) {
$except['memberfields'][] = 'field_'.$profilefields[$fieldid];
}
if(submitcheck('repairsubmit') && (!empty($repair) || !empty($setting) || !empty($repairtable) || !empty($missingtable))) {
$error = '';$errorcount = 0;
$alter = $fielddefault = array();
foreach($missingtable as $value) {
if(!isset($installdata)) {
$fp = fopen(DISCUZ_ROOT.'./install/discuz.sql', "rb");
$installdata = fread($fp, filesize(DISCUZ_ROOT.'./install/discuz.sql'));
fclose($fp);
}
preg_match("/CREATE TABLE ".$tablepre.$value."\s+\(.+?;/is", $installdata, $a);
$db->query(createtable($a[0], $dbcharset));
}
foreach($repair as $value) {
if(!in_array($r_table, $repairtable)) {
list($r_table, $r_field, $option) = explode('|', $value);
if(!isset($repairrtable[$r_table]) && $fieldsquery = $db->query("SHOW FIELDS FROM $tablepre$r_table", 'SILENT')) {
while($fields = $db->fetch_array($fieldsquery)) {
$fielddefault[$r_table][$fields['Field']] = $fields['Default'];
}
}
$field = $discuzdb[$r_table][$r_field];
$altersql = '`'.$field['Field'].'` '.$field['Type'];
$altersql .= $field['Null'] == 'NO' ? ' NOT NULL' : '';
$altersql .= in_array($fielddefault[$r_table][$field['Field']], array('', '0')) && in_array($field['Default'], array('', '0')) ||
$field['Null'] == 'NO' && $field['Default'] == '' ||
preg_match('/text/i', $field['Type']) || preg_match('/auto_increment/i', $field['Extra']) ?
'' : ' default \''.$field['Default'].'\'';
$altersql .= $field['Extra'] != '' ? ' '.$field['Extra'] : '';
$altersql = $option == 'modify' ? "MODIFY COLUMN ".$altersql : "ADD COLUMN ".$altersql;
$alter[$r_table][] = $altersql;
}
}
foreach($alter as $r_table => $sqls) {
$db->query("ALTER TABLE `$tablepre$r_table` ".implode(',', $sqls), 'SILENT');
if($sqlerror = $db->error()) {
$errorcount += count($sqls);
$error .= $sqlerror.'<br /><br />';
}
}
$alter = array();
foreach($repairtable as $value) {
foreach($discuzdb[$value] as $field) {
if(!isset($fielddefault[$value]) && $fieldsquery = $db->query("SHOW FIELDS FROM $tablepre$value", 'SILENT')) {
while($fields = $db->fetch_array($fieldsquery)) {
$fielddefault[$value][$fields['Field']] = $fields['Default'];
}
}
$altersql = '`'.$field['Field'].'` '.$field['Type'];
$altersql .= $field['Null'] == 'NO' ? ' NOT NULL' : '';
$altersql .= in_array($fielddefault[$value][$field['Field']], array('', '0')) && in_array($field['Default'], array('', '0')) ||
$field['Null'] == 'NO' && $field['Default'] == '' ||
preg_match('/text/i', $field['Type']) || preg_match('/auto_increment/i', $field['Extra']) ?
'' : ' default \''.$field['Default'].'\'';
$altersql .= $field['Extra'] != '' ? ' '.$field['Extra'] : '';
$altersql = "MODIFY COLUMN ".$altersql;
$alter[$value][] = $altersql;
}
}
foreach($alter as $r_table => $sqls) {
$db->query("ALTER TABLE `$tablepre$r_table` ".implode(',', $sqls), 'SILENT');
if($sqlerror = $db->error()) {
$errorcount += count($sqls);
$error .= $sqlerror.'<br /><br />';
}
}
if(!empty($setting)) {
$settingsdatanow = array();
$settingsquery = $db->query("SELECT variable FROM {$tablepre}settings WHERE SUBSTRING(variable, 1, 9)<>'jswizard_' ORDER BY variable");
while($settings = $db->fetch_array($settingsquery)) {
$settingsdatanew[] = $settings['variable'];
}
$settingsdellist = @array_diff($settingsdata, $settingsdatanew);
if($setting['del'] && is_array($settingsdellist)) {
foreach($settingsdellist as $variable) {
$db->query("INSERT INTO {$tablepre}settings (variable, value) VALUES ('$variable', '')", 'SILENT');
}
}
updatecache('settings');
}
if($errorcount) {
cpmsg('dbcheck_repair_error', '', 'error');
} else {
cpmsg('dbcheck_repair_completed', $BASESCRIPT.'?action=db&operation=dbcheck&step=3', 'succeed');
}
}
$installexists = file_exists(DISCUZ_ROOT.'./install/discuz.sql');
$discuzdbnew = $deltables = $excepttables = $missingtables = $charseterror = array();
foreach($discuzdb as $dbtable => $fields) {
if($fieldsquery = $db->query("SHOW FIELDS FROM $tablepre$dbtable", 'SILENT')) {
while($fields = $db->fetch_array($fieldsquery)) {
$r = '/^'.$tablepre.'/';
$cuttable = preg_replace($r, '', $dbtable);
if($db->version() < '4.1' && $cuttable == 'sessions' && $fields['Field'] == 'sid') {
$fields['Type'] = str_replace(' binary', '', $fields['Type']);
}
if($cuttable == 'memberfields' && preg_match('/^field\_\d+$/', $fields['Field'])) {
unset($discuzdbnew[$cuttable][$fields['Field']]);
continue;
}
$discuzdbnew[$cuttable][$fields['Field']]['Field'] = $fields['Field'];
$discuzdbnew[$cuttable][$fields['Field']]['Type'] = $fields['Type'];
$discuzdbnew[$cuttable][$fields['Field']]['Null'] = $fields['Null'] == '' ? 'NO' : $fields['Null'];
$discuzdbnew[$cuttable][$fields['Field']]['Extra'] = $fields['Extra'];
$discuzdbnew[$cuttable][$fields['Field']]['Default'] = $fields['Default'] == '' || $fields['Default'] == '0' ? '' : $fields['Default'];
}
ksort($discuzdbnew[$cuttable]);
} else {
$missingtables[] = '<span style="float:left;width:33%">'.(($installexists ? '<input name="missingtable[]" type="checkbox" class="checkbox" value="'.$dbtable.'">' : '').$tablepre.$dbtable).'</span>';
$excepttables[] = $dbtable;
}
}
if($db->version() > '4.1') {
$dbcharset = strtoupper($dbcharset) == 'UTF-8' ? 'UTF8' : strtoupper($dbcharset);
$query = $db->query("SHOW TABLE STATUS LIKE '$tablepre%'");
while($tables = $db->fetch_array($query)) {
$r = '/^'.$tablepre.'/';
$cuttable = preg_replace($r, '', $tables['Name']);
$tabledbcharset = substr($tables['Collation'], 0, strpos($tables['Collation'], '_'));
if($dbcharset != strtoupper($tabledbcharset)) {
$charseterror[] = '<span style="float:left;width:33%">'.$tablepre.$cuttable.'('.$tabledbcharset.')</span>';
}
}
}
$dbmd5new = md5(serialize($discuzdbnew));
$settingsdatanow = array();
$settingsquery = $db->query("SELECT variable FROM {$tablepre}settings WHERE SUBSTRING(variable, 1, 9)<>'jswizard_' ORDER BY variable");
while($settings = $db->fetch_array($settingsquery)) {
$settingsdatanew[] = $settings['variable'];
}
$settingsdellist = @array_diff($settingsdata, $settingsdatanew);
if($dbmd5 == $dbmd5new && empty($charseterror) && empty($settingsdellist)) {
cpmsg('dbcheck_ok', '', 'succeed');
}
$showlist = $addlists = '';
foreach($discuzdb as $dbtable => $fields) {
$addlist = $modifylist = $dellist = array();
if($fields != $discuzdbnew[$dbtable]) {
foreach($discuzdb[$dbtable] as $key => $value) {
if(is_array($missingtables) && in_array($tablepre.$dbtable, $missingtables)) {
} elseif(!isset($discuzdbnew[$dbtable][$key])) {
$dellist[] = $value;
} elseif($value != $discuzdbnew[$dbtable][$key]) {
$modifylist[] = $value;
}
}
if(is_array($discuzdbnew[$dbtable])) {
foreach($discuzdbnew[$dbtable] as $key => $value) {
if(!isset($discuzdb[$dbtable][$key]) && !@in_array($value['Field'], $except[$dbtable])) {
$addlist[] = $value;
}
}
}
}
if(($modifylist || $dellist) && !in_array($dbtable, $excepttables)) {
$showlist .= showtablerow('', '', array("<span class=\"diffcolor3\">$tablepre$dbtable</span> $lang[dbcheck_field]", $lang[dbcheck_org_field], $lang[dbcheck_status]), TRUE);
foreach($modifylist as $value) {
$slowstatus = slowcheck($discuzdbnew[$dbtable][$value['Field']]['Type'], $value['Type']);
$showlist .= "<tr><td><input name=\"repair[]\" class=\"checkbox\" type=\"checkbox\" value=\"$dbtable|$value[Field]|modify\"> <b>".$value['Field']."</b> ".
$discuzdbnew[$dbtable][$value['Field']]['Type'].
($discuzdbnew[$dbtable][$value['Field']]['Null'] == 'NO' ? ' NOT NULL' : '').
(!preg_match('/auto_increment/i', $discuzdbnew[$dbtable][$value['Field']]['Extra']) && !preg_match('/text/i', $discuzdbnew[$dbtable][$value['Field']]['Type']) ? ' default \''.$discuzdbnew[$dbtable][$value['Field']]['Default'].'\'' : '').
' '.$discuzdbnew[$dbtable][$value['Field']]['Extra'].
"</td><td><b>".$value['Field']."</b> ".$value['Type'].
($value['Null'] == 'NO' ? ' NOT NULL' : '').
(!preg_match('/auto_increment/i', $value['Extra']) && !preg_match('/text/i', $value['Type']) ? ' default \''.$value['Default'].'\'' : '').
' '.$value['Extra']."</td><td>".
(!$slowstatus ? "<em class=\"edited\">$lang[dbcheck_modify]</em></td></tr>" : "<em class=\"unknown\">$lang[dbcheck_slow]</em>")."</td></tr>";
}
if($modifylist) {
$showlist .= showtablerow('', 'colspan="3"', "<input onclick=\"setrepaircheck(this, this.form, '$dbtable')\" name=\"repairtable[]\" class=\"checkbox\" type=\"checkbox\" value=\"$dbtable\"> <b>$lang[dbcheck_repairtable]</b>", TRUE);
}
foreach($dellist as $value) {
$showlist .= "<tr><td><input name=\"repair[]\" class=\"checkbox\" type=\"checkbox\" value=\"$dbtable|$value[Field]|add\"> <strike><b>".$value['Field']."</b></strike></td><td> <b>".$value['Field']."</b> ".$value['Type'].($value['Null'] == 'NO' ? ' NOT NULL' : '')."</td><td>".
"<em class=\"del\">$lang[dbcheck_delete]</em></td></tr>";
}
}
if($addlist) {
$addlists .= "<tr><td colspan=\"3\"><b>$tablepre$dbtable</b> $lang[dbcheck_new_field]</td></tr>";
foreach($addlist as $value) {
$addlists .= "<tr><td colspan=\"3\"> <b>".$value['Field']."</b> ".$discuzdbnew[$dbtable][$value['Field']]['Type'].($discuzdbnew[$dbtable][$value['Field']]['Null'] == 'NO' ? ' NOT NULL' : '')."</td></tr>";
}
}
}
if($showlist) {
$showlist = showtablerow('', 'colspan="3" class="partition"', $lang['dbcheck_errorfields_tables'], TRUE).$showlist;
}
if($missingtables) {
$showlist .= showtablerow('', 'colspan="3" class="partition"', $lang['dbcheck_missing_tables'], TRUE);
$showlist .= showtablerow('', 'colspan="3" class="partition"', implode('', $missingtables), TRUE);
}
if($settingsdellist) {
$showlist .= "<tr class=\"partition\"><td colspan=\"3\">$lang[dbcheck_settings]</td></tr>";
$showlist .= '<tr><td colspan="3">';
$showlist .= "<input name=\"setting[del]\" class=\"checkbox\" type=\"checkbox\" value=\"1\"> ".implode(', ', $settingsdellist).'<br />';
$showlist .= '</td></tr>';
}
if($showlist) {
$showlist .= '<tr><td colspan="3"><input class="btn" type="submit" value="'.$lang['dbcheck_repair'].'" name="repairsubmit"></td></tr>';
}
if($charseterror) {
$showlist .= "<tr><td class=\"partition\" colspan=\"3\">$lang[dbcheck_charseterror_tables] ($lang[dbcheck_charseterror_notice] $dbcharset)</td></tr>";
$showlist .= '<tr><td colspan="3">'.implode('', $charseterror).'</td></tr>';
}
if($addlists) {
$showlist .= '<tr><td class="partition" colspan="3">'.$lang['dbcheck_userfields'].'</td></tr>'.$addlists;
}
}
shownav('tools', 'nav_db', 'nav_db_dbcheck');
showsubmenu('nav_db', array(
array('nav_db_export', 'db&operation=export', 0),
array('nav_db_import', 'db&operation=import', 0),
array('nav_db_runquery', 'db&operation=runquery', 0),
array('nav_db_optimize', 'db&operation=optimize', 0),
array('nav_db_dbcheck', 'db&operation=dbcheck', 1)
));
showsubmenusteps('', array(
array('nav_filecheck_confirm', $step == 1),
array('nav_filecheck_verify', $step == 2),
array('nav_filecheck_completed', $step == 3)
));
if($step == 1) {
cpmsg($lang[dbcheck_tips_step1], $BASESCRIPT.'?action=db&operation=dbcheck&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(lang('dbcheck_verifying'), "$BASESCRIPT?action=db&operation=dbcheck&step=3", 'loading', '', FALSE);
} elseif($step == 3) {
showtips('dbcheck_tips');
echo <<<EOT
<script type="text/JavaScript">
function setrepaircheck(obj, form, table) {
eval('var rem = /^' + table + '\\\\|.+?\\\\|modify$/;');
eval('var rea = /^' + table + '\\\\|.+?\\\\|add$/;');
for(var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if(e.type == 'checkbox' && e.name == 'repair[]') {
if(rem.exec(e.value) != null) {
if(obj.checked) {
e.checked = false;
e.disabled = true;
} else {
e.checked = false;
e.disabled = false;
}
}
if(rea.exec(e.value) != null) {
if(obj.checked) {
e.checked = true;
e.disabled = false;
} else {
e.checked = false;
e.disabled = false;
}
}
}
}
}
</script>
EOT;
showformheader('db&operation=dbcheck&step=3', 'fixpadding');
showtableheader();
echo $showlist;
showtablefooter();
showformfooter();
}
}
function createtable($sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
(mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
}
function fetchtablelist($tablepre = '') {
global $db;
$arr = explode('.', $tablepre);
$dbname = $arr[1] ? $arr[0] : '';
$sqladd = $dbname ? " FROM $dbname LIKE '$arr[1]%'" : "LIKE '$tablepre%'";
!$tablepre && $tablepre = '*';
$tables = $table = array();
$query = $db->query("SHOW TABLE STATUS $sqladd");
while($table = $db->fetch_array($query)) {
$table['Name'] = ($dbname ? "$dbname." : '').$table['Name'];
$tables[] = $table;
}
return $tables;
}
function arraykeys2($array, $key2) {
$return = array();
foreach($array as $val) {
$return[] = $val[$key2];
}
return $return;
}
function syntablestruct($sql, $version, $dbcharset) {
if(strpos(trim(substr($sql, 0, 18)), 'CREATE TABLE') === FALSE) {
return $sql;
}
$sqlversion = strpos($sql, 'ENGINE=') === FALSE ? FALSE : TRUE;
if($sqlversion === $version) {
return $sqlversion && $dbcharset ? preg_replace(array('/ character set \w+/i', '/ collate \w+/i', "/DEFAULT CHARSET=\w+/is"), array('', '', "DEFAULT CHARSET=$dbcharset"), $sql) : $sql;
}
if($version) {
return preg_replace(array('/TYPE=HEAP/i', '/TYPE=(\w+)/is'), array("ENGINE=MEMORY DEFAULT CHARSET=$dbcharset", "ENGINE=\\1 DEFAULT CHARSET=$dbcharset"), $sql);
} else {
return preg_replace(array('/character set \w+/i', '/collate \w+/i', '/ENGINE=MEMORY/i', '/\s*DEFAULT CHARSET=\w+/is', '/\s*COLLATE=\w+/is', '/ENGINE=(\w+)(.*)/is'), array('', '', 'ENGINE=HEAP', '', '', 'TYPE=\\1\\2'), $sql);
}
}
function sqldumptable($table, $startfrom = 0, $currsize = 0) {
global $db, $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
$offset = 300;
$tabledump = '';
$tablefields = array();
$query = $db->query("SHOW FULL COLUMNS FROM $table", 'SILENT');
if(strexists($table, 'adminsessions')) {
return ;
} elseif(!$query && $db->errno() == 1146) {
return;
} elseif(!$query) {
$usehex = FALSE;
} else {
while($fieldrow = $db->fetch_array($query)) {
$tablefields[] = $fieldrow;
}
}
if(!$startfrom) {
$createtable = $db->query("SHOW CREATE TABLE $table", 'SILENT');
if(!$db->error()) {
$tabledump = "DROP TABLE IF EXISTS $table;\n";
} else {
return '';
}
$create = $db->fetch_row($createtable);
if(strpos($table, '.') !== FALSE) {
$tablename = substr($table, strpos($table, '.') + 1);
$create[1] = str_replace("CREATE TABLE $tablename", 'CREATE TABLE '.$table, $create[1]);
}
$tabledump .= $create[1];
if($sqlcompat == 'MYSQL41' && $db->version() < '4.1') {
$tabledump = preg_replace("/TYPE\=(.+)/", "ENGINE=\\1 DEFAULT CHARSET=".$dumpcharset, $tabledump);
}
if($db->version() > '4.1' && $sqlcharset) {
$tabledump = preg_replace("/(DEFAULT)*\s*CHARSET=.+/", "DEFAULT CHARSET=".$sqlcharset, $tabledump);
}
$tablestatus = $db->fetch_first("SHOW TABLE STATUS LIKE '$table'");
$tabledump .= ($tablestatus['Auto_increment'] ? " AUTO_INCREMENT=$tablestatus[Auto_increment]" : '').";\n\n";
if($sqlcompat == 'MYSQL40' && $db->version() >= '4.1' && $db->version() < '5.1') {
if($tablestatus['Auto_increment'] <> '') {
$temppos = strpos($tabledump, ',');
$tabledump = substr($tabledump, 0, $temppos).' auto_increment'.substr($tabledump, $temppos);
}
if($tablestatus['Engine'] == 'MEMORY') {
$tabledump = str_replace('TYPE=MEMORY', 'TYPE=HEAP', $tabledump);
}
}
}
if(!in_array($table, $excepttables)) {
$tabledumped = 0;
$numrows = $offset;
$firstfield = $tablefields[0];
if($extendins == '0') {
while($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) {
if($firstfield['Extra'] == 'auto_increment') {
$selectsql = "SELECT * FROM $table WHERE $firstfield[Field] > $startfrom LIMIT $offset";
} else {
$selectsql = "SELECT * FROM $table LIMIT $startfrom, $offset";
}
$tabledumped = 1;
$rows = $db->query($selectsql);
$numfields = $db->num_fields($rows);
$numrows = $db->num_rows($rows);
while($row = $db->fetch_row($rows)) {
$comma = $t = '';
for($i = 0; $i < $numfields; $i++) {
$t .= $comma.($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text')) ? '0x'.bin2hex($row[$i]) : '\''.mysql_escape_string($row[$i]).'\'');
$comma = ',';
}
if(strlen($t) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) {
if($firstfield['Extra'] == 'auto_increment') {
$startfrom = $row[0];
} else {
$startfrom++;
}
$tabledump .= "INSERT INTO $table VALUES ($t);\n";
} else {
$complete = FALSE;
break 2;
}
}
}
} else {
while($currsize + strlen($tabledump) + 500 < $sizelimit * 1000 && $numrows == $offset) {
if($firstfield['Extra'] == 'auto_increment') {
$selectsql = "SELECT * FROM $table WHERE $firstfield[Field] > $startfrom LIMIT $offset";
} else {
$selectsql = "SELECT * FROM $table LIMIT $startfrom, $offset";
}
$tabledumped = 1;
$rows = $db->query($selectsql);
$numfields = $db->num_fields($rows);
if($numrows = $db->num_rows($rows)) {
$t1 = $comma1 = '';
while($row = $db->fetch_row($rows)) {
$t2 = $comma2 = '';
for($i = 0; $i < $numfields; $i++) {
$t2 .= $comma2.($usehex && !empty($row[$i]) && (strexists($tablefields[$i]['Type'], 'char') || strexists($tablefields[$i]['Type'], 'text'))? '0x'.bin2hex($row[$i]) : '\''.mysql_escape_string($row[$i]).'\'');
$comma2 = ',';
}
if(strlen($t1) + $currsize + strlen($tabledump) + 500 < $sizelimit * 1000) {
if($firstfield['Extra'] == 'auto_increment') {
$startfrom = $row[0];
} else {
$startfrom++;
}
$t1 .= "$comma1 ($t2)";
$comma1 = ',';
} else {
$tabledump .= "INSERT INTO $table VALUES $t1;\n";
$complete = FALSE;
break 2;
}
}
$tabledump .= "INSERT INTO $table VALUES $t1;\n";
}
}
}
$startrow = $startfrom;
$tabledump .= "\n";
}
return $tabledump;
}
function splitsql($sql) {
$sql = str_replace("\r", "\n", $sql);
$ret = array();
$num = 0;
$queriesarray = explode(";\n", trim($sql));
unset($sql);
foreach($queriesarray as $query) {
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= $query[0] == "#" ? NULL : $query;
}
$num++;
}
return($ret);
}
function slowcheck($type1, $type2) {
$t1 = explode(' ', $type1);$t1 = $t1[0];
$t2 = explode(' ', $type2);$t2 = $t2[0];
$arr = array($t1, $t2);
sort($arr);
if($arr == array('mediumtext', 'text')) {
return TRUE;
} elseif(substr($arr[0], 0, 4) == 'char' && substr($arr[1], 0, 7) == 'varchar') {
return TRUE;
}
return FALSE;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/db.inc.php
|
PHP
|
asf20
| 52,535
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: counter.inc.php 17163 2008-12-08 08:03:10Z zhaoxiongfei $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$pertask = isset($pertask) ? intval($pertask) : 100;
$current = isset($current) && $current > 0 ? intval($current) : 0;
$next = $current + $pertask;
if(submitcheck('forumsubmit', 1)) {
$nextlink = "$BASESCRIPT?action=counter¤t=$next&pertask=$pertask&forumsubmit=yes";
$processed = 0;
$queryf = $db->query("SELECT fid FROM {$tablepre}forums WHERE type<>'group' LIMIT $current, $pertask");
while($forum = $db->fetch_array($queryf)) {
$processed = 1;
extract($db->fetch_first("SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0'"));
$thread = $db->fetch_first("SELECT tid, subject, lastpost, lastposter FROM {$tablepre}threads WHERE fid='$forum[fid]' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
$lastpost = addslashes("$thread[tid]\t$thread[subject]\t$thread[lastpost]\t$thread[lastposter]");
$db->query("UPDATE {$tablepre}forums SET threads='$threads', posts='$posts', lastpost='$lastpost' WHERE fid='$forum[fid]'");
}
if($processed) {
cpmsg("$lang[counter_forum]: $lang[counter_processing]", $nextlink, 'loading');
} else {
$db->query("UPDATE {$tablepre}forums SET threads='0', posts='0' WHERE type='group'");
cpmsg('counter_forum_succeed', $BASESCRIPT.'?action=counter', 'succeed');
}
} elseif(submitcheck('digestsubmit', 1)) {
if(!$current) {
$db->query("UPDATE {$tablepre}members SET digestposts=0", 'UNBUFFERED');
$current = 0;
}
$nextlink = "$BASESCRIPT?action=counter¤t=$next&pertask=$pertask&digestsubmit=yes";
$processed = 0;
$membersarray = $postsarray = array();
$query = $db->query("SELECT authorid FROM {$tablepre}threads WHERE digest<>'0' AND displayorder>='0' LIMIT $current, $pertask");
while($thread = $db->fetch_array($query)) {
$processed = 1;
$membersarray[$thread['authorid']]++;
}
foreach($membersarray as $uid => $posts) {
$postsarray[$posts] .= ','.$uid;
}
unset($membersarray);
foreach($postsarray as $posts => $uids) {
$db->query("UPDATE {$tablepre}members SET digestposts=digestposts+'$posts' WHERE uid IN (0$uids)", 'UNBUFFERED');
}
if($processed) {
cpmsg("$lang[counter_digest]: $lang[counter_processing]", $nextlink, 'loading');
} else {
cpmsg('counter_digest_succeed', $BASESCRIPT.'?action=counter', 'succeed');
}
} elseif(submitcheck('membersubmit', 1)) {
$nextlink = "$BASESCRIPT?action=counter¤t=$next&pertask=$pertask&membersubmit=yes";
$processed = 0;
$queryt = $db->query("SELECT uid FROM {$tablepre}members LIMIT $current, $pertask");
while($mem = $db->fetch_array($queryt)) {
$processed = 1;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts WHERE authorid='$mem[uid]' AND invisible='0'");
$db->query("UPDATE {$tablepre}members SET posts='".$db->result($query, 0)."' WHERE uid='$mem[uid]'");
}
if($processed) {
cpmsg("$lang[counter_member]: $lang[counter_processing]", $nextlink, 'loading');
} else {
cpmsg('counter_member_succeed', $BASESCRIPT.'?action=counter', 'succeed');
}
} elseif(submitcheck('threadsubmit', 1)) {
$nextlink = "$BASESCRIPT?action=counter¤t=$next&pertask=$pertask&threadsubmit=yes";
$processed = 0;
$queryt = $db->query("SELECT tid, replies, lastpost, lastposter FROM {$tablepre}threads WHERE displayorder>='0' LIMIT $current, $pertask");
while($threads = $db->fetch_array($queryt)) {
$processed = 1;
$replynum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$threads[tid]' AND invisible='0'");
$replynum--;
$lastpost = $db->fetch_first("SELECT author, dateline FROM {$tablepre}posts WHERE tid='$threads[tid]' AND invisible='0' ORDER BY dateline DESC LIMIT 1");
if($threads['replies'] != $replynum || $threads['lastpost'] != $lastpost['dateline'] || $threads['lastposter'] != $lastpost['author']) {
$db->query("UPDATE LOW_PRIORITY {$tablepre}threads SET replies='$replynum', lastpost='$lastpost[dateline]', lastposter='".addslashes($lastpost['author'])."' WHERE tid='$threads[tid]'", 'UNBUFFERED');
}
}
if($processed) {
cpmsg("$lang[counter_thread]: $lang[counter_processing]", $nextlink, 'loading');
} else {
cpmsg('counter_thread_succeed', $BASESCRIPT.'?action=counter', 'succeed');
}
} elseif(submitcheck('movedthreadsubmit', 1)) {
$nextlink = "$BASESCRIPT?action=counter¤t=$next&pertask=$pertask&movedthreadsubmit=yes";
$processed = 0;
$tids = 0;
$query = $db->query("SELECT t1.tid, t2.tid AS threadexists FROM {$tablepre}threads t1
LEFT JOIN {$tablepre}threads t2 ON t2.tid=t1.closed AND t2.displayorder>='0'
WHERE t1.closed>'1' LIMIT $current, $pertask");
while($thread = $db->fetch_array($query)) {
$processed = 1;
if($thread['threadexists']) {
$tids .= ','.$thread['tid'];
}
}
if($tids) {
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($tids)", 'UNBUFFERED');
}
if($processed) {
cpmsg("$lang[counter_moved_thread]: $lang[counter_processing]", $nextlink, 'loading');
} else {
cpmsg('counter_moved_thread_succeed', $BASESCRIPT.'?action=counter', 'succeed');
}
} elseif(submitcheck('cleanupsubmit', 1)) {
$nextlink = "$BASESCRIPT?action=counter¤t=$next&pertask=$pertask&cleanupsubmit=yes";
$processed = 0;
$queryt = $db->query("SELECT tid,fid FROM {$tablepre}favorites LIMIT $current, $pertask");
while($fav = $db->fetch_array($queryt)) {
$processed = 1;
if($fav['tid']) {
$favtid[]= $fav['tid'];
} elseif($fav['fid']) {
$favfid[]= $fav['fid'];
}
}
if(!empty($favtid)) {
foreach($favtid as $tid) {
if(!$db->result_first("SELECT tid FROM {$tablepre}threads WHERE tid='$tid'")) {
$db->query("DELETE FROM {$tablepre}favorites WHERE tid='$tid'");
$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$tid'");
}
}
}
if(!empty($favfid)) {
foreach($favfid as $fid) {
if(!$db->result_first("SELECT fid FROM {$tablepre}forums WHERE fid='$fid'")) {
$db->query("DELETE FROM {$tablepre}favorites WHERE fid='$fid'");
}
}
}
if($processed) {
cpmsg("$lang[counter_moved_favorites_logs]: $lang[counter_processing]", $nextlink, 'loading');
} else {
cpmsg('counter_moved_favorites_logs_succeed', $BASESCRIPT.'?action=counter', 'succeed');
}
} else {
shownav('tools', 'nav_updatecounters');
showsubmenu('nav_updatecounters');
showformheader('counter');
showtableheader();
showsubtitle(array('', 'counter_amount'));
showhiddenfields(array('pertask' => ''));
showtablerow('', array('class="td21"'), array(
"$lang[counter_forum]:",
'<input name="pertask1" type="text" class="txt" value="15" /><input type="submit" class="btn" name="forumsubmit" onclick="this.form.pertask.value=this.form.pertask1.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td21"'), array(
"$lang[counter_digest]:",
'<input name="pertask2" type="text" class="txt" value="1000" /><input type="submit" class="btn" name="digestsubmit" onclick="this.form.pertask.value=this.form.pertask2.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td21"'), array(
"$lang[counter_member]:",
'<input name="pertask3" type="text" class="txt" value="1000" /><input type="submit" class="btn" name="membersubmit" onclick="this.form.pertask.value=this.form.pertask3.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td21"'), array(
"$lang[counter_thread]:",
'<input name="pertask4" type="text" class="txt" value="500" /><input type="submit" class="btn" name="threadsubmit" onclick="this.form.pertask.value=this.form.pertask4.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td21"'), array(
"$lang[counter_moved_thread]:",
'<input name="pertask5" type="text" class="txt" value="100" /><input type="submit" class="btn" name="movedthreadsubmit" onclick="this.form.pertask.value=this.form.pertask5.value" value="'.$lang['submit'].'" />'
));
showtablerow('', array('class="td21"'), array(
"$lang[counter_moved_favorites_logs]:",
'<input name="pertask6" type="text" class="txt" value="100" /><input type="submit" class="btn" name="cleanupsubmit" onclick="this.form.pertask.value=this.form.pertask6.value" value="'.$lang['submit'].'" />'
));
showtablefooter();
showformfooter();
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/counter.inc.php
|
PHP
|
asf20
| 8,689
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: home.inc.php 17291 2008-12-12 03:15:51Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(@file_exists(DISCUZ_ROOT.'./install/index.php')) {
@unlink(DISCUZ_ROOT.'./install/index.php');
if(@file_exists(DISCUZ_ROOT.'./install/index.php')) {
dexit('Please delete install/index.php via FTP!');
}
}
@include_once DISCUZ_ROOT.'./discuz_version.php';
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$siteuniqueid = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='siteuniqueid'");
if(empty($siteuniqueid) || strlen($siteuniqueid) < 16) {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$siteuniqueid = $chars[date('y')%60].$chars[date('n')].$chars[date('j')].$chars[date('G')].$chars[date('i')].$chars[date('s')].substr(md5($onlineip.$discuz_user.$timestamp), 0, 4).random(6);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('siteuniqueid', '$siteuniqueid')");
}
if(empty($_DCACHE['settings']['authkey']) || strlen($_DCACHE['settings']['authkey']) < 16) {
$authkey = $_DCACHE['settings']['authkey'] = substr(md5($siteuniqueid.$bbname.$timestamp), 8, 8).random(8);
$db->query("REPLACE INTO {$tablepre}settings SET variable='authkey', value='$authkey'");
updatesettings();
}
if(submitcheck('notesubmit', 1)) {
if($noteid) {
$db->query("DELETE FROM {$tablepre}adminnotes WHERE id='$noteid' AND (admin='$discuz_user' OR adminid>='$adminid')");
}
if($newmessage) {
$newaccess[$adminid] = 1;
$newaccess = bindec(intval($newaccess[1]).intval($newaccess[2]).intval($newaccess[3]));
$newexpiration = strtotime($newexpiration);
$newmessage = nl2br(dhtmlspecialchars($newmessage));
$db->query("INSERT INTO {$tablepre}adminnotes (admin, access, adminid, dateline, expiration, message)
VALUES ('$discuz_user', '$newaccess', '$adminid', '$timestamp', '$newexpiration', '$newmessage')");
}
}
$serverinfo = PHP_OS.' / PHP v'.PHP_VERSION;
$serverinfo .= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
$serversoft = $_SERVER['SERVER_SOFTWARE'];
$dbversion = $db->result_first("SELECT VERSION()");
if(@ini_get('file_uploads')) {
$fileupload = ini_get('upload_max_filesize');
} else {
$fileupload = '<font color="red">'.$lang['no'].'</font>';
}
//$groupselect = '';
//$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups ORDER BY creditslower, groupid");
//while($group = $db->fetch_array($query)) {
// $groupselect .= '<option value="'.$group['groupid'].'">'.$group['grouptitle'].'</option>';
//}
$dbsize = 0;
$query = $db->query("SHOW TABLE STATUS LIKE '$tablepre%'", 'SILENT');
while($table = $db->fetch_array($query)) {
$dbsize += $table['Data_length'] + $table['Index_length'];
}
$dbsize = $dbsize ? sizecount($dbsize) : $lang['unknown'];
if(isset($attachsize)) {
$attachsize = $db->result($db->query("SELECT SUM(filesize) FROM {$tablepre}attachments"), 0);
$attachsize = is_numeric($attachsize) ? sizecount($attachsize) : $lang['unknown'];
} else {
$attachsize = '<a href="admincp.php?action=home&attachsize">[ '.$lang['detail'].' ]</a>';
}
$membersmod = $db->result_first("SELECT COUNT(*) FROM {$tablepre}validating WHERE status='0'");
$postsmod = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE first='0' AND invisible='-2'");
$threadsdel = $threadsmod = 0;
$query = $db->query("SELECT displayorder FROM {$tablepre}threads WHERE displayorder<'0'");
while($thread = $db->fetch_array($query)) {
if($thread['displayorder'] == -1) {
$threadsdel++;
} elseif($thread['displayorder'] == -2) {
$threadsmod++;
}
}
cpheader();
shownav();
showsubmenu('home_welcome');
$save_mastermobile = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='mastermobile'");
$save_mastermobile = !empty($save_mastermobile) ? authcode($save_mastermobile, 'DECODE', $authkey) : '';
$securityadvise = '';
$securityadvise .= !$discuz_secques ? $lang['home_secques_invalid'] : '';
$securityadvise .= empty($forumfounders) ? $lang['home_security_nofounder'] : '';
$securityadvise .= $admincp['tpledit'] ? $lang['home_security_tpledit'] : '';
$securityadvise .= $admincp['runquery'] ? $lang['home_security_runquery'] : '';
if(isfounder()) {
if($securyservice) {
$new_mastermobile = trim($new_mastermobile);
if(empty($new_mastermobile)) {
$save_mastermobile = $new_mastermobile;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('mastermobile', '$new_mastermobile')");
} elseif($save_mastermobile != $new_mastermobile && strlen($new_mastermobile) == 11 && is_numeric($new_mastermobile) && (substr($new_mastermobile, 0, 2) == '13' || substr($new_mastermobile, 0, 2) == '15')) {
$save_mastermobile = $new_mastermobile;
$new_mastermobile = authcode($new_mastermobile, 'ENCODE', $authkey);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('mastermobile', '$new_mastermobile')");
}
}
$view_mastermobile = !empty($save_mastermobile) ? substr($save_mastermobile, 0 , 3).'*****'.substr($save_mastermobile, -3) : '';
$securityadvise = '<li><p>'.lang('home_security_service_info').'</p><form method="post" action="'.$BASESCRIPT.'?action=home&securyservice=yes">'.lang('home_security_service_mobile').': <input type="text" class="txt" name="new_mastermobile" value="'.$view_mastermobile.'" size="30" /> <input type="submit" class="btn" name="securyservice" value="'.lang($view_mastermobile ? 'submit' : 'home_security_service_open').'" /> <span class="lightfont">'.lang($view_mastermobile ? 'home_security_service_mobile_save' : 'home_security_service_mobile_none').'</span></form></li>'.$securityadvise;
}
showtableheader('home_security_tips', '', '', 0);
showtablerow('', 'class="tipsblock"', '<ul>'.$securityadvise.'</ul>');
showtablefooter();
//showsubmenu('home_security_tips');
//echo '<ul class="safelist">'.$securityadvise.'</ul>';
if($isfounder) {
$insenz = ($insenz = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='insenz'")) ? unserialize($insenz) : array();
if(empty($insenz['authkey'])) {
showtableheader('insenz_note', 'noborder mt10', '', 0);
showtablerow('', '', lang('insenz_note_join_insenz').'<a href="'.$BASESCRIPT.'?action=insenz"><u>'.$lang['insenz_note_register'].'</u></a>');
showtablefooter();
} elseif($insenz['status']) {
require_once DISCUZ_ROOT.'./include/insenz.func.php';
echo '<div id="insenznews"></div>';
}
}
echo '<div id="boardnews"></div>';
showtableheader('', 'nobottom fixpadding');
if($membersmod || $threadsmod || $postsmod || $threadsdel) {
showtablerow('', '', '<h3 class="left margintop">'.lang('home_mods').': </h3><p class="left difflink">'.
($membersmod ? '<a href="'.$BASESCRIPT.'?action=moderate&operation=members">'.lang('home_mod_members').'</a>(<em class="lightnum">'.$membersmod.'</em>)' : '').
($threadsmod ? '<a href="'.$BASESCRIPT.'?action=moderate&operation=threads">'.lang('home_mod_threads').'</a>(<em class="lightnum">'.$threadsmod.'</em>)' : '').
($postsmod ? '<a href="'.$BASESCRIPT.'?action=moderate&operation=replies">'.lang('home_mod_posts').'</a>(<em class="lightnum">'.$postsmod.'</em>)' : '').
($threadsdel ? '<a href="'.$BASESCRIPT.'?action=recyclebin">'.lang('home_del_threads').'</a>(<em class="lightnum">'.$threadsdel.'</em>)' : '').
'</p><div class="clear"></div>'
);
}
showtablefooter();
showformheader('home');
showtableheader('home_notes', 'fixpadding"', '', '3');
$query = $db->query("SELECT * FROM {$tablepre}adminnotes ORDER BY dateline DESC");
while($note = $db->fetch_array($query)) {
if($note['expiration'] < $timestamp) {
$db->query("DELETE FROM {$tablepre}adminnotes WHERE id='$note[id]'");
} else {
$note['adminenc'] = rawurlencode($note['admin']);
$note['dateline'] = gmdate($dateformat, $note['dateline'] + $timeoffset * 3600);
$note['expiration'] = gmdate($dateformat, $note['expiration'] + $timeoffset * 3600);
showtablerow('', array('', '', ''), array(
'<a href="'.$BASESCRIPT.'?action=home¬esubmit=yes¬eid='.$note['id'].'"><img src="images/admincp/close.gif" width="7" height="8" title="'.lang('delete').'" /></a>',
"<span class=\"bold\"><a href=\"space.php?username=$note[adminenc]\" target=\"_blank\">$note[admin]</a>: </span>$note[message]",
"$note[dateline] ~ $note[expiration]"
));
}
}
showtablerow('', array(), array(
lang('home_notes_add'),
'<input type="text" class="txt" name="newmessage" value="" style="width:300px;" />',
lang('validity').': <input type="text" class="txt" name="newexpiration" value="'.gmdate('Y-n-j', $timestamp + $timeoffset * 3600 + 86400 * 30).'" size="8" /><input name="notesubmit" value="'.lang('submit').'" type="submit" class="btn" />'
));
showtablefooter();
showformfooter();
include_once DISCUZ_ROOT.'./uc_client/client.php';
showtableheader('home_sys_info', 'fixpadding');
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_discuz_version'),
'Discuz! '.DISCUZ_VERSION.' Release '.DISCUZ_RELEASE.' <a href="http://www.discuz.net/forumdisplay.php?fid=10" class="lightlink smallfont" target="_blank">'.lang('home_check_newversion').'</a> <a href="http://www.comsenz.com/purchase/discuz/" class="lightlink smallfont" target="_blank">专业支持与服务</a> <a href="http://idc.comsenz.com" class="lightlink smallfont" target="_blank">Discuz!专用主机</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_ucclient_version'),
'UCenter '.UC_CLIENT_VERSION.' Release '.UC_CLIENT_RELEASE
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_environment'),
$serverinfo
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_serversoftware'),
$serversoft
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_database'),
$dbversion
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_upload_perm'),
$fileupload
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_database_size'),
$dbsize
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_attach_size'),
$attachsize
));
showtablefooter();
showtableheader('home_dev', 'fixpadding');
showtablerow('', array('class="vtop td24 lineheight"'), array(
lang('home_dev_copyright'),
'<span class="bold"><a href="http://www.comsenz.com" class="lightlink2" target="_blank">康盛创想(北京)科技有限公司 (Comsenz Inc.)</a></span>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_dev_manager'),
'<a href="http://www.discuz.net/space.php?uid=1" class="lightlink smallfont" target="_blank">戴志康 (Kevin \'Crossday\' Day)</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight smallfont"'), array(
lang('home_dev_team'),
'<a href="http://www.discuz.net/space.php?uid=2691" class="lightlink smallfont" target="_blank">Liang \'Readme\' Chen</a>,
<a href="http://www.discuz.net/space.php?uid=1519" class="lightlink smallfont" target="_blank">Yang \'Summer\' Xia</a>,
<a href="http://www.discuz.net/space.php?uid=859" class="lightlink smallfont" target="_blank">Hypo \'cnteacher\' Wang</a>,
<a href="http://www.discuz.net/space.php?uid=16678" class="lightlink smallfont" target="_blank">Yang \'Dokho\' Song</a>,
<a href="http://www.discuz.net/space.php?uid=10407" class="lightlink smallfont" target="_blank">Qiang Liu</a>,
<a href="http://www.discuz.net/space.php?uid=80629" class="lightlink smallfont" target="_blank">Ning \'Monkey\' Hou</a>,
<a href="http://www.discuz.net/space.php?uid=15104" class="lightlink smallfont" target="_blank">Xiongfei \'Redstone\' Zhao</a>,
<a href="http://www.discuz.net/space.php?uid=210272" class="lightlink smallfont" target="_blank">XiaoDun \'Kenshine\' Fang</a>,
<a href="http://www.discuz.net/space.php?uid=492114" class="lightlink smallfont" target="_blank">Liang \'Metthew\' Xu</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight"'), array(
lang('home_dev_skins'),
'<a href="http://www.discuz.net/space.php?uid=294092" class="lightlink smallfont" target="_blank">Fangming \'Lushnis\' Li</a>,
<a href="http://www.discuz.net/space.php?uid=674006" class="lightlink smallfont" target="_blank">Jizhou \'Iavav\' Yuan</a>,
<a href="http://www.discuz.net/space.php?uid=362790" class="lightlink smallfont" target="_blank">Defeng \'Dfox\' Xu</a>,
<a href="http://www.discuz.net/space.php?uid=717854" class="lightlink smallfont" target="_blank">Ruitao \'Pony.M\' Ma</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight"'), array(
lang('home_dev_thanks'),
'<a href="http://www.discuz.net/space.php?uid=122246" class="lightlink smallfont" target="_blank">Heyond</a>,
<a href="http://www.discuz.net/space.php?uid=86282" class="lightlink smallfont" target="_blank">Jianxieshui</a>,
<a href="http://www.discuz.net/space.php?uid=9600" class="lightlink smallfont" target="_blank">Theoldmemory</a>,
<a href="http://www.discuz.net/space.php?uid=2629" class="lightlink smallfont" target="_blank">Rain5017</a>,
<a href="http://www.discuz.net/space.php?uid=26926" class="lightlink smallfont" target="_blank">Snow Wolf</a>,
<a href="http://www.discuz.net/space.php?uid=17149" class="lightlink smallfont" target="_blank">Hehechuan</a>,
<a href="http://www.discuz.net/space.php?uid=9132" class="lightlink smallfont" target="_blank">Pk0909</a>,
<a href="http://www.discuz.net/space.php?uid=248" class="lightlink smallfont" target="_blank">feixin</a>,
<a href="http://www.discuz.net/space.php?uid=675" class="lightlink smallfont" target="_blank">Laobing Jiuba</a>,
<a href="http://www.discuz.net/space.php?uid=13877" class="lightlink smallfont" target="_blank">Artery</a>,
<a href="http://www.discuz.net/space.php?uid=233" class="lightlink smallfont" target="_blank">Huli Hutu</a>,
<a href="http://www.discuz.net/space.php?uid=122" class="lightlink smallfont" target="_blank">Lao Gui</a>,
<a href="http://www.discuz.net/space.php?uid=159" class="lightlink smallfont" target="_blank">Tyc</a>,
<a href="http://www.discuz.net/space.php?uid=177" class="lightlink smallfont" target="_blank">Stoneage</a>,
<a href="http://www.discuz.net/space.php?uid=7155" class="lightlink smallfont" target="_blank">Gregry</a>,
<a href="http://www.17dst.com/" class="lightlink smallfont" target="_blank">Discuz! Support Team</a>'
));
showtablerow('', array('class="vtop td24 lineheight"', 'class="lineheight"'), array(
lang('home_dev_links'),
'<a href="http://www.comsenz.com" class="lightlink" target="_blank">公司网站</a>, <a href="http://idc.comsenz.com" class="lightlink" target="_blank">虚拟主机</a>, <a href="http://www.comsenz.com/category-51" class="lightlink" target="_blank">购买授权</a>, <a href="http://www.discuz.com/" class="lightlink" target="_blank">Discuz! 产品</a>, <a href="http://www.comsenz.com/downloads/styles/discuz" class="lightlink" target="_blank">模板</a>, <a href="http://www.comsenz.com/downloads/plugins/discuz" class="lightlink" target="_blank">插件</a>, <a href="http://faq.comsenz.com" class="lightlink" target="_blank">文档</a>, <a href="http://www.discuz.net/" class="lightlink" target="_blank">讨论区</a>'
));
showtablefooter();
echo '</div>';
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/home.inc.php
|
PHP
|
asf20
| 16,288
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: global.func.php 17538 2009-01-20 07:39:49Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
@set_time_limit(0);
function istpldir($dir) {
return is_dir(DISCUZ_ROOT.'./'.$dir) && !in_array(substr($dir, -1, 1), array('/', '\\')) &&
strpos(realpath(DISCUZ_ROOT.'./'.$dir), realpath(DISCUZ_ROOT.'./templates')) === 0;
}
function isplugindir($dir) {
return !$dir || (!preg_match("/(\.\.|[\\\\]+$)/", $dir) && substr($dir, -1) =='/');
}
function ispluginkey($key) {
return preg_match("/^[a-z]+[a-z0-9_]*$/i", $key);
}
function dir_writeable($dir) {
if(!is_dir($dir)) {
@mkdir($dir, 0777);
}
if(is_dir($dir)) {
if($fp = @fopen("$dir/test.txt", 'w')) {
@fclose($fp);
@unlink("$dir/test.txt");
$writeable = 1;
} else {
$writeable = 0;
}
}
return $writeable;
}
function filemtimesort($a, $b) {
if($a['filemtime'] == $b['filemtime']) {
return 0;
}
return ($a['filemtime'] > $b['filemtime']) ? 1 : -1;
}
function checkpermission($action, $break = 1) {
if(!isset($GLOBALS['admincp'])) {
cpmsg('action_access_noexists', '', 'error');
} elseif($break && !$GLOBALS['admincp'][$action]) {
cpmsg('action_noaccess_config', '', 'error');
} else {
return $GLOBALS['admincp'][$action];
}
}
function bbsinformation() {
global $db, $timestamp, $tablepre, $charset, $bbname, $_SERVER, $siteuniqueid, $save_mastermobile, $msn;
$update = array('uniqueid' => $siteuniqueid, 'version' => DISCUZ_VERSION, 'release' => DISCUZ_RELEASE, 'php' => PHP_VERSION, 'mysql' => $db->version(), 'charset' => $charset, 'bbname' => $bbname, 'mastermobile' => $save_mastermobile);
$updatetime = @filemtime(DISCUZ_ROOT.'./forumdata/updatetime.lock');
if(empty($updatetime) || ($timestamp - $updatetime > 3600 * 4)) {
@touch(DISCUZ_ROOT.'./forumdata/updatetime.lock');
$update['members'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}members");
$update['threads'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads");
$update['posts'] = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts");
$query = $db->query("SELECT special, count(*) AS spcount FROM {$tablepre}threads GROUP BY special");
while($thread = $db->fetch_array($query)) {
$thread['special'] = intval($thread['special']);
$update['spt_'.$thread['special']] = $thread['spcount'];
}
if($msn['on'] && $msn['domain']) {
$update['msn_domain'] = $msn['domain'];
}
}
$data = '';
foreach($update as $key => $value) {
$data .= $key.'='.rawurlencode($value).'&';
}
return 'update='.rawurlencode(base64_encode($data)).'&md5hash='.substr(md5($_SERVER['HTTP_USER_AGENT'].implode('', $update).$timestamp), 8, 8).'×tamp='.$timestamp;
}
function isfounder($user = '') {
$user = empty($user) ? array('uid' => $GLOBALS['discuz_uid'], 'adminid' => $GLOBALS['adminid'], 'username' => $GLOBALS['discuz_userss']) : $user;
$founders = str_replace(' ', '', $GLOBALS['forumfounders']);
if($user['adminid'] <> 1) {
return FALSE;
} elseif(empty($founders)) {
return TRUE;
} elseif(strexists(",$founders,", ",$user[uid],")) {
return TRUE;
} elseif(!is_numeric($user['username']) && strexists(",$founders,", ",$user[username],")) {
return TRUE;
} else {
return FALSE;
}
}
function lang($name, $force = true) {
global $lang;
return isset($lang[$name]) ? $lang[$name] : ($force ? $name : '');
}
function admincustom($title, $url, $sort = 0) {
global $db, $tablepre, $discuz_uid, $timestamp, $BASESCRIPT;
$url = $BASESCRIPT.'?'.$url;
$id = $db->result_first("SELECT id FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='$sort' AND url='$url'");
if($id) {
$db->query("UPDATE {$tablepre}admincustom SET title='$title', clicks=clicks+1, dateline='$timestamp' WHERE id='$id'");
} else {
$db->query("INSERT INTO {$tablepre}admincustom (title, url, sort, uid, dateline) VALUES ('$title', '$url', '$sort', '$discuz_uid', '$timestamp')");
}
}
function cpurl($type = 'parameter', $filters = array('sid', 'frames')) {
parse_str($_SERVER['QUERY_STRING'], $getarray);
$extra = $and = '';
foreach($getarray as $key => $value) {
if(!in_array($key, $filters)) {
@$extra .= $and.$key.($type == 'parameter' ? '%3D' : '=').rawurlencode($value);
$and = $type == 'parameter' ? '%26' : '&';
}
}
return $extra;
}
function showheader($key, $url) {
echo '<li><em><a href="javascript:;" id="header_'.$key.'" hidefocus="true" onclick="toggleMenu(\''.$key.'\', \''.$url.'\');">'.lang('header_'.$key).'</a></em></li>';
}
function shownav($header = '', $menu = '', $nav = '') {
global $action, $operation, $BASESCRIPT;
$title = 'cplog_'.$action.($operation ? '_'.$operation : '');
if(in_array($action, array('home', 'custommenu'))) {
$customtitle = '';
} elseif(lang($title, false)) {
$customtitle = $title;
} else {
$customtitle = rawurlencode($nav ? $nav : ($menu ? $menu : ''));
}
echo '<script type="text/JavaScript">if(parent.$(\'admincpnav\')) parent.$(\'admincpnav\').innerHTML=\''.lang('nav_'.($header ? $header : 'index')).
($menu ? ' » '.lang($menu) : '').
($nav ? ' » '.lang($nav) : '').'\';'.
'if(parent.$(\'add2custom\')) parent.$(\'add2custom\').innerHTML='.($customtitle ? '\'<a href="'.$BASESCRIPT.'?action=misc&operation=custommenu&do=add&title='.$customtitle.'&url='.cpurl().'" target="main"><img src="images/admincp/btn_add2menu.gif" title="'.lang('custommenu_add').'" width="19" height="18" /></a>\';' : '\'\'').
'</script>';
}
function showmenu($key, $menus) {
global $BASESCRIPT;
echo '<ul id="menu_'.$key.'" style="display: none">';
if(is_array($menus)) {
foreach($menus as $menu) {
if($menu[0] && $menu[1]) {
echo '<li><a href="'.(substr($menu[1], 0, 4) == 'http' ? $menu[1] : $BASESCRIPT.'?action='.$menu[1]).'" hidefocus="true" target="'.($menu[2] ? $menu[2] : 'main').'"'.($menu[3] ? $menu[3] : '').'>'.lang($menu[0]).'</a></li>';
}
}
}
echo '</ul>';
}
function cpmsg($message, $url = '', $type = '', $extra = '', $halt = TRUE) {
extract($GLOBALS, EXTR_SKIP);
include language('admincp.msg');
eval("\$message = \"".(isset($msglang[$message]) ? $msglang[$message] : $message)."\";");
switch($type) {
case 'succeed': $classname = 'infotitle2';break;
case 'error': $classname = 'infotitle3';break;
case 'loading': $classname = 'infotitle1';break;
default: $classname = 'marginbot normal';break;
}
$message = "<h4 class=\"$classname\">$message</h4>";
if($type == 'form') {
$message = "<form method=\"post\" action=\"$url\"><input type=\"hidden\" name=\"formhash\" value=\"".FORMHASH."\">".
"<br />$message$extra<br />".
"<p class=\"margintop\"><input type=\"submit\" class=\"btn\" name=\"confirmed\" value=\"$lang[ok]\"> \n".
"<input type=\"button\" class=\"btn\" value=\"$lang[cancel]\" onClick=\"history.go(-1);\"></p></form><br />";
} elseif($type == 'loadingform') {
$message = "<form method=\"post\" action=\"$url\" id=\"loadingform\"><input type=\"hidden\" name=\"formhash\" value=\"".FORMHASH."\"><br />$message$extra<img src=\"images/admincp/ajax_loader.gif\" class=\"marginbot\" /><br />".
'<p class="marginbot"><a href="###" onclick="$(\'loadingform\').submit();" class="lightlink">'.lang('message_redirect').'</a></p></form><br /><script type="text/JavaScript">setTimeout("$(\'loadingform\').submit();", 2000);</script>';
} else {
$message .= $extra.($type == 'loading' ? '<img src="images/admincp/ajax_loader.gif" class="marginbot" />' : '');
if($url) {
if($type == 'button') {
$message = "<br />$message<br /><p class=\"margintop\"><input type=\"submit\" class=\"btn\" name=\"submit\" value=\"$lang[start]\" onclick=\"location.href='$url'\" />";
} else {
$message .= '<p class="marginbot"><a href="'.$url.'" class="lightlink">'.lang('message_redirect').'</a></p>';
$url = transsid($url);
$message .= "<script type=\"text/JavaScript\">setTimeout(\"redirect('$url');\", 2000);</script>";
}
} elseif(strpos($message, $lang['return'])) {
$message .= '<p class="marginbot"><a href="javascript:history.go(-1);" class="lightlink">'.lang('message_return').'</a></p>';
}
}
if($halt) {
echo '<h3>'.lang('discuz_message').'</h3><div class="infobox">'.$message.'</div>';
cpfooter();
dexit();
} else {
echo '<div class="infobox">'.$message.'</div>';
}
}
function cpheader() {
global $charset, $frame, $BASESCRIPT;
if(!defined('DISCUZ_CP_HEADER_OUTPUT')) {
define('DISCUZ_CP_HEADER_OUTPUT', true);
} else {
return true;
}
$IMGDIR = IMGDIR;
$STYLEID = STYLEID;
$VERHASH = VERHASH;
echo <<< EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=$charset">
<link href="./images/admincp/admincp.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script type="text/JavaScript">
function redirect(url) {
window.location.replace(url);
}
var admincpfilename = '$BASESCRIPT';
if('$frame' != 'no' && !parent.document.getElementById('leftmenu')) {
redirect(admincpfilename + '?frames=yes&' + document.URL.substr(document.URL.indexOf(admincpfilename) + 12));
}
var IMGDIR = '$IMGDIR';
var STYLEID = '$STYLEID'
var VERHASH = '$VERHASH';
var IN_ADMINCP = true;
</script>
<script src="include/js/common.js" type="text/javascript"></script>
<script type="text/JavaScript">
function checkAll(type, form, value, checkall, changestyle) {
var checkall = checkall ? checkall : 'chkall';
for(var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if(type == 'option' && e.type == 'radio' && e.value == value && e.disabled != true) {
e.checked = true;
} else if(type == 'value' && e.type == 'checkbox' && e.getAttribute('chkvalue') == value) {
e.checked = form.elements[checkall].checked;
} else if(type == 'prefix' && e.name && e.name != checkall && (!value || (value && e.name.match(value)))) {
e.checked = form.elements[checkall].checked;
if(changestyle && e.parentNode && e.parentNode.tagName.toLowerCase() == 'li') {
e.parentNode.className = e.checked ? 'checked' : '';
}
}
}
}
function altStyle(obj) {
function altStyleClear(obj) {
var input, lis, i;
lis = obj.parentNode.getElementsByTagName('li');
for(i=0; i < lis.length; i++){
lis[i].className = '';
}
}
var input, lis, i, cc, o;
cc = 0;
lis = obj.getElementsByTagName('li');
for(i=0; i < lis.length; i++){
lis[i].onclick = function(e) {
o = is_ie ? event.srcElement.tagName : e.target.tagName;
if(cc) {
return;
}
cc = 1;
input = this.getElementsByTagName('input')[0];
if(input.getAttribute('type') == 'checkbox' || input.getAttribute('type') == 'radio') {
if(input.getAttribute('type') == 'radio') {
altStyleClear(this);
}
if(is_ie || o != 'INPUT' && input.onclick) {
input.click();
}
if(this.className != 'checked') {
this.className = 'checked';
input.checked = true;
} else {
this.className = '';
input.checked = false;
}
}
}
lis[i].onmouseup = function(e) {
cc = 0;
}
}
}
var addrowdirect = 0;
function addrow(obj, type) {
var table = obj.parentNode.parentNode.parentNode.parentNode;
if(!addrowdirect) {
var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex);
} else {
var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex + 1);
}
var typedata = rowtypedata[type];
for(var i = 0; i <= typedata.length - 1; i++) {
var cell = row.insertCell(i);
cell.colSpan = typedata[i][0];
var tmp = typedata[i][1];
if(typedata[i][2]) {
cell.className = typedata[i][2];
}
tmp = tmp.replace(/\{(\d+)\}/g, function($1, $2) {return addrow.arguments[parseInt($2) + 1];});
cell.innerHTML = tmp;
}
addrowdirect = 0;
}
function dropmenu(obj){
obj.className = obj.className == 'hasdropmenu' ? 'current' : 'hasdropmenu';
$(obj.id + 'child').style.display = $(obj.id + 'child').style.display == 'none' ? '' : 'none';
}
function textareasize(obj) {
if(obj.scrollHeight > 70) {
obj.style.height = obj.scrollHeight + 'px';
}
}
if('$frame' != 'no') _attachEvent(document.documentElement, 'keydown', parent.resetEscAndF5);
function display_detail(objname) {
obj = $(objname);
if(obj.style.display == 'none') {
obj.style.display = '';
} else {
obj.style.display = 'none'
}
}
</script>
<div id="append_parent"></div>
<div class="container" id="cpcontainer">
EOT;
}
function showsubmenu($title, $menus = array()) {
global $BASESCRIPT;
if(empty($menus)) {
$s = '<div class="itemtitle"><h3>'.lang($title).'</h3></div>';
} elseif(is_array($menus)) {
$s = '<div class="itemtitle"><h3>'.lang($title).'</h3>';
if(is_array($menus)) {
$s .= '<ul class="tab1">';
foreach($menus as $k => $menu) {
if(is_array($menu[0])) {
$s .= '<li id="addjs'.$k.'" class="'.($menu[2] ? ' current' : 'hasdropmenu').'" onclick="dropmenu(this);"><a href="#"><span>'.lang($menu[0]['menu']).'<em> </em></span></a><div id="addjs'.$k.'child" class="dropmenu" style="display:none;">';
if(is_array($menu[0]['submenu'])) {
foreach($menu[0]['submenu'] as $submenu) {
$s .= '<a href="'.$BASESCRIPT.'?action='.$submenu[1].'">'.lang($submenu[0]).'</a>';
}
}
$s .= '</div></li>';
} else {
$s .= '<li'.($menu[2] ? ' class="current"' : '').'><a href="'.$BASESCRIPT.'?action='.$menu[1].'"'.($menu[3] ? ' target="_blank"' : '').'><span>'.lang($menu[0]).'</span></a></li>';
}
}
$s .= '</ul>';
}
$s .= '</div>';
}
echo $s;
}
function showsubmenusteps($title, $menus = array()) {
$s = '<div class="itemtitle">'.($title ? '<h3>'.lang($title).'</h3>' : '');
if(is_array($menus)) {
$s .= '<ul class="stepstat">';
$i = 0;
foreach($menus as $menu) {
$i++;
$s .= '<li'.($menu[1] ? ' class="current"' : '').' id="step'.$i.'">'.$i.'.'.lang($menu[0]).'</li>';
}
$s .= '</ul>';
}
$s .= '</div>';
echo $s;
}
function showsubmenuanchors($title, $menus = array()) {
if(!$title || !$menus || !is_array($menus)) {
return;
}
echo <<<EOT
<script type="text/JavaScript">
function showanchor(obj) {
var navs = $('submenu').getElementsByTagName('li');
for(var i = 0; i < navs.length; i++) {
if(navs[i].id != obj.id) {
navs[i].className = '';
$(navs[i].id.substr(4)).style.display = 'none';
if($(navs[i].id.substr(4) + '_tips')) $(navs[i].id.substr(4) + '_tips').style.display = 'none';
}
}
obj.className = 'current';
$(obj.id.substr(4)).style.display = '';
if($(obj.id.substr(4) + '_tips')) $(obj.id.substr(4) + '_tips').style.display = '';
if($(obj.id.substr(4) + 'form')) {
$(obj.id.substr(4) + 'form').anchor.value = obj.id.substr(4);
} else if($('cpform')) {
$('cpform').anchor.value = obj.id.substr(4);
}
}
</script>
EOT;
$s = '<div class="itemtitle"><h3>'.lang($title).'</h3>';
$s .= '<ul class="tab1" id="submenu">';
foreach($menus as $menu) {
if($menu && is_array($menu)) {
$s .= '<li id="nav_'.$menu[1].'" onclick="showanchor(this)"'.($menu[2] ? ' class="current"' : '').'><a href="#"><span>'.lang($menu[0]).'</span></a></li>';
}
}
$s .= '</ul>';
$s .= '</div>';
echo $s;
}
function showtips($tips, $id = 'tips', $display = TRUE) {
extract($GLOBALS, EXTR_SKIP);
if(lang($tips, false)) {
eval('$tips = "'.str_replace('"', '\\"', $lang[$tips]).'";');
}
$tmp = explode('</li><li>', substr($tips, 4, -5));
if(count($tmp) > 4) {
$tips = '<li>'.$tmp[0].'</li><li>'.$tmp[1].'</li><li id="'.$id.'_more" style="border: none; background: none; margin-bottom: 6px;"><a href="###" onclick="var tiplis = $(\''.$id.'lis\').getElementsByTagName(\'li\');for(var i = 0; i < tiplis.length; i++){tiplis[i].style.display=\'\'}$(\''.$id.'_more\').style.display=\'none\';">'.lang('tips_all').'...</a></li>';
foreach($tmp AS $k => $v) {
if($k > 1) {
$tips .= '<li style="display: none">'.$v.'</li>';
}
}
}
unset($tmp);
showtableheader('tips', '', 'id="'.$id.'"'.(!$display ? ' style="display: none;"' : ''), 0);
showtablerow('', 'class="tipsblock"', '<ul id="'.$id.'lis">'.$tips.'</ul>');
showtablefooter();
}
function showformheader($action, $extra = '', $name = 'cpform') {
global $BASESCRIPT;
echo '<form name="'.$name.'" method="post" action="'.$BASESCRIPT.'?action='.$action.'" id="'.$name.'"'.($extra == 'enctype' ? ' enctype="multipart/form-data"' : " $extra").'><input type="hidden" name="formhash" value="'.FORMHASH.'" /><input type="hidden" name="anchor" value="'.htmlspecialchars($GLOBALS['anchor']).'" />';
}
function showhiddenfields($hiddenfields = array()) {
if(is_array($hiddenfields)) {
foreach($hiddenfields as $key => $val) {
$val = is_string($val) ? htmlspecialchars($val) : $val;
echo "\n<input type=\"hidden\" name=\"$key\" value=\"$val\">";
}
}
}
function showtableheader($title = '', $classname = '', $extra = '', $titlespan = 15) {
$classname = str_replace(array('nobottom', 'notop'), array('nobdb', 'nobdt'), $classname);
echo "\n".'<table class="tb tb2 '.$classname.'"'.($extra ? " $extra" : '').'>';
if($title) {
$span = $titlespan ? 'colspan="'.$titlespan.'"' : '';
echo "\n".'<tr><th '.$span.' class="partition">'.lang($title).'</th></tr>';
}
}
function showtagheader($tagname, $id, $display = FALSE, $classname = '') {
echo '<'.$tagname.($classname ? " class=\"$classname\"" : '').' id="'.$id.'"'.($display ? '' : ' style="display: none"').'>';
}
function showtitle($title, $extra = '') {
echo "\n".'<tr'.($extra ? " $extra" : '').'><th colspan="15" class="partition">'.lang($title).'</th></tr>';
}
function showsubtitle($title = array(), $rowclass='header') {
if(is_array($title)) {
$subtitle = "\n<tr class=\"$rowclass\">";
foreach($title as $v) {
if($v !== NULL) {
$subtitle .= '<th>'.lang($v).'</th>';
}
}
$subtitle .= '</tr>';
echo $subtitle;
}
}
function showtablerow($trstyle = '', $tdstyle = array(), $tdtext = array(), $return = FALSE) {
$rowswapclass = is_array($tdtext) && count($tdtext) > 2 ? ' class="hover"' : '';
$cells = "\n".'<tr'.($trstyle ? ' '.$trstyle : '').$rowswapclass.'>';
if(isset($tdtext)) {
if(is_array($tdtext)) {
foreach($tdtext as $key => $td) {
$cells .= '<td'.(is_array($tdstyle) && !empty($tdstyle[$key]) ? ' '.$tdstyle[$key] : '').'>'.$td.'</td>';
}
} else {
$cells .= '<td'.(!empty($tdstyle) && is_string($tdstyle) ? ' '.$tdstyle : '').'>'.$tdtext.'</td>';
}
}
$cells .= '</tr>';
if($return) {
return $cells;
}
echo $cells;
}
function showsetting($setname, $varname, $value, $type = 'radio', $disabled = '', $hidden = 0, $comment = '', $extra = '') {
$s = "\n";
$check = array();
$check['disabled'] = $disabled ? ' disabled' : '';
if($type == 'radio') {
$value ? $check['true'] = "checked" : $check['false'] = "checked";
$value ? $check['false'] = '' : $check['true'] = '';
$check['hidden1'] = $hidden ? ' onclick="$(\'hidden_'.$setname.'\').style.display = \'\';"' : '';
$check['hidden0'] = $hidden ? ' onclick="$(\'hidden_'.$setname.'\').style.display = \'none\';"' : '';
$s .= '<ul onmouseover="altStyle(this);">'.
'<li'.($check['true'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="'.$varname.'" value="1" '.$check['true'].$check['hidden1'].$check['disabled'].'> '.lang('yes').'</li>'.
'<li'.($check['false'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="'.$varname.'" value="0" '.$check['false'].$check['hidden0'].$check['disabled'].'> '.lang('no').'</li>'.
'</ul>';
} elseif($type == 'text' || $type == 'password') {
$s .= '<input name="'.$varname.'" value="'.dhtmlspecialchars($value).'" type="'.$type.'" class="txt" '.$check['disabled'].' '.$extra.' />';
} elseif($type == 'file') {
$s .= '<input name="'.$varname.'" value="" type="file" class="txt uploadbtn marginbot" '.$check['disabled'].' '.$extra.' />';
} elseif($type == 'textarea') {
$readonly = $disabled ? 'readonly' : '';
$s .= "<textarea $readonly rows=\"6\" onkeyup=\"textareasize(this)\" name=\"$varname\" id=\"$varname\" cols=\"50\" class=\"tarea\" '.$extra.'>".dhtmlspecialchars($value)."</textarea>";
} elseif($type == 'select') {
$s .= '<select name="'.$varname[0].'" '.$extra.'>';
foreach($varname[1] as $option) {
$selected = $option[0] == $value ? 'selected="selected"' : '';
$s .= "<option value=\"$option[0]\" $selected>".$option[1]."</option>\n";
}
$s .= '</select>';
} elseif($type == 'mradio') {
if(is_array($varname)) {
$radiocheck = array($value => ' checked');
$s .= '<ul'.(empty($varname[2]) ? ' class="nofloat"' : '').' onmouseover="altStyle(this);">';
foreach($varname[1] as $varary) {
if(is_array($varary) && !empty($varary)) {
$onclick = '';
if(!empty($varary[2])) {
foreach($varary[2] as $ctrlid => $display) {
$onclick .= '$(\''.$ctrlid.'\').style.display = \''.$display.'\';';
}
}
$onclick && $onclick = ' onclick="'.$onclick.'"';
$s .= '<li'.($radiocheck[$varary[0]] ? ' class="checked"' : '').'><input class="radio" type="radio" name="'.$varname[0].'" value="'.$varary[0].'"'.$radiocheck[$varary[0]].$check['disabled'].$onclick.'> '.$varary[1].'</li>';
}
}
$s .= '</ul>';
}
} elseif($type == 'mcheckbox') {
$s .= '<ul class="nofloat" onmouseover="altStyle(this);">';
foreach($varname[1] as $varary) {
if(is_array($varary) && !empty($varary)) {
$onclick = !empty($varary[2]) ? ' onclick="$(\''.$varary[2].'\').style.display = $(\''.$varary[2].'\').style.display == \'none\' ? \'\' : \'none\';"' : '';
$checked = is_array($value) && in_array($varary[0], $value) ? ' checked' : '';
$s .= '<li'.($checked ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="'.$varname[0].'[]" value="'.$varary[0].'"'.$checked.$check['disabled'].$onclick.'> '.$varary[1].'</li>';
}
}
$s .= '</ul>';
} elseif($type == 'binmcheckbox') {
$checkboxs = count($varname[1]);
$value = sprintf('%0'.$checkboxs.'b', $value);$i = 1;
$s .= '<ul class="nofloat" onmouseover="altStyle(this);">';
foreach($varname[1] as $key => $var) {
$s .= '<li'.($value{$checkboxs - $i} ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="'.$varname[0].'['.$i.']" value="1"'.($value{$checkboxs - $i} ? ' checked' : '').' '.(!empty($varname[2][$key]) ? $varname[2][$key] : '').'> '.$var.'</li>';
$i++;
}
$s .= '</ul>';
} elseif($type == 'mselect') {
$s .= '<select name="'.$varname[0].'" multiple="multiple" size="10" '.$extra.'>';
foreach($varname[1] as $option) {
$selected = is_array($value) && in_array($option[0], $value) ? 'selected="selected"' : '';
$s .= "<option value=\"$option[0]\" $selected>".$option[1]."</option>\n";
}
$s .= '</select>';
} elseif($type == 'color') {
global $stylestuff;
$preview_varname = str_replace('[', '_', str_replace(']', '', $varname));
$code = explode(' ', $value);
$css = '';
for($i = 0; $i <= 1; $i++) {
if($code[$i] != '') {
if($code[$i]{0} == '#') {
$css .= strtoupper($code[$i]).' ';
} elseif(preg_match('/^http:\/\//i', $code[$i])) {
$css .= 'url(\''.$code[$i].'\') ';
} else {
$css .= 'url(\''.$stylestuff['imgdir']['subst'].'/'.$code[$i].'\') ';
}
}
}
$background = trim($css);
if(!$GLOBALS['coloridcount']) {
$s .= "<script type=\"text/JavaScript\">
function updatecolorpreview(obj) {
$(obj).style.background = $(obj + '_v').value;
}
</script>";
}
$colorid = ++$GLOBALS['coloridcount'];
$s .= "<input id=\"c{$colorid}_v\" type=\"text\" class=\"txt\" style=\"float:left; width:200px;\" value=\"$value\" name=\"$varname\" onchange=\"updatecolorpreview('c{$colorid}')\">\n".
"<input id=\"c$colorid\" onclick=\"c{$colorid}_frame.location='images/admincp/getcolor.htm?c{$colorid}';showMenu('c$colorid')\" type=\"button\" class=\"colorwd\" value=\"\" style=\"background: $background\"><span id=\"c{$colorid}_menu\" style=\"display: none\"><iframe name=\"c{$colorid}_frame\" src=\"\" frameborder=\"0\" width=\"166\" height=\"186\" scrolling=\"no\"></iframe></span>\n$extra";
} elseif($type == 'calendar') {
$s .= "<input type=\"text\" class=\"txt\" name=\"$varname\" value=\"".dhtmlspecialchars($value)."\" onclick=\"showcalendar(event, this".($extra ? ', 1' : '').")\">\n";
} elseif(in_array($type, array('multiply', 'range', 'daterange'))) {
$onclick = $type == 'daterange' ? ' onclick="showcalendar(event, this)"' : '';
$s .= "<input type=\"text\" class=\"txt\" name=\"$varname[0]\" value=\"".dhtmlspecialchars($value[0])."\" style=\"width: 108px; margin-right: 5px;\"$onclick>".($type == 'multiply' ? ' X ' : ' -- ')."<input type=\"text\" class=\"txt\" name=\"$varname[1]\" value=\"".dhtmlspecialchars($value[1])."\"class=\"txt\" style=\"width: 108px; margin-left: 5px;\"$onclick>";
} else {
$s .= $type;
}
showtablerow('', 'colspan="2" class="td27"', lang($setname));
showtablerow('class="noborder"', array('class="vtop rowform"', 'class="vtop tips2"'), array(
$s,
($comment ? $comment : lang($setname.'_comment', 0)).
($disabled ? '<br /><span class="smalltxt" style="color:#FF0000">'.lang($setname.'_disabled', 0).'</span>' : NULL)
));
if($hidden) {
showtagheader('tbody', 'hidden_'.$setname, $value, 'sub');
}
}
function mradio($name, $items = array(), $checked = '', $float = TRUE) {
$list = '<ul'.($float ? '' : ' class="nofloat"').' onmouseover="altStyle(this);">';
if(is_array($items)) {
foreach($items as $value => $item) {
$list .= '<li'.($checked == $value ? ' class="checked"' : '').'><input type="radio" name="'.$name.'" value="'.$value.'" class="radio"'.($checked == $value ? ' checked="checked"' : '').' /> '.$item.'</li>';
}
}
$list .= '</ul>';
return $list;
}
function mcheckbox($name, $items = array(), $checked = array()) {
$list = '<ul class="dblist" onmouseover="altStyle(this);">';
if(is_array($items)) {
foreach($items as $value => $item) {
$list .= '<li'.(empty($checked) || in_array($value, $checked) ? ' class="checked"' : '').'><input type="checkbox" name="'.$name.'[]" value="'.$value.'" class="checkbox"'.(empty($checked) || in_array($value, $checked) ? ' checked="checked"' : '').' /> '.$item.'</li>';
}
}
$list .= '</ul>';
return $list;
}
function showsubmit($name = '', $value = 'submit', $before = '', $after = '', $floatright = '') {
$str = '<tr>';
$str .= $name && in_array($before, array('del', 'select_all', 'td')) ? '<td class="td25">'.($before != 'td' ? '<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'delete\')" /><label for="chkall">'.lang($before) : '').'</label></td>' : '';
$str .= '<td colspan="15">';
$str .= $floatright ? '<div class="cuspages right">'.$floatright.'</div>' : '';
$str .= '<div class="fixsel">';
$str .= $before && !in_array($before, array('del', 'select_all', 'td')) ? $before.' ' : '';
$str .= $name ? '<input type="submit" class="btn" name="'.$name.'" value="'.lang($value).'" />' : '';
$after = $after == 'more_options' ? '<input class="checkbox" type="checkbox" value="1" onclick="$(\'advanceoption\').style.display = $(\'advanceoption\').style.display == \'none\' ? \'\' : \'none\'; this.value = this.value == 1 ? 0 : 1; this.checked = this.value == 1 ? false : true" id="btn_more" /><label for="btn_more">'.lang('more_options').'</label>' : $after;
$str = $after ? $str.(($before && $before != 'del') || $name ? ' ' : '').$after : $str;
$str .= '</div></td>';
$str .= '</tr>';
echo $str;
}
function showtagfooter($tagname) {
echo '</'.$tagname.'>';
}
function showtablefooter() {
echo '</table>'."\n";
}
function showformfooter() {
echo '</form>'."\n";
}
function cpfooter() {
global $version, $adminid, $db, $tablepre, $action, $bbname, $charset, $timestamp, $isfounder, $insenz;
global $_COOKIE, $_SESSION, $_DCOOKIE, $_DCACHE, $_DSESSION, $_DCACHE, $_DPLUGIN, $sqldebug, $debuginfo;
$infmessage = '';
if(debuginfo()) {
//$infmessage = '<br /><br /><div class="footer"><hr size="0" noshade color="'.BORDERCOLOR.'" width="80%"><span class="smalltxt"><br />Processed in '.$debuginfo['time'].' second(s), '.$debuginfo[queries].' queries</span></div>';
}
?>
<?=$infmessage?>
<?php echo $sqldebug;?>
</div>
</body>
<?php
if($_GET['highlight']) {
echo <<<EOT
<script type="text/JavaScript">
function parsetag(tag) {
var str = document.body.innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {
if(tag && $3.indexOf(tag) != -1) {
$3 = $3.replace(tag, '<h_>');
}
return $2 + $3;
});
document.body.innerHTML = str.replace(/<h_>/ig, function($1, $2) {
return '<font color="#c60a00">' + tag + '</font>';
});
}
EOT;
$kws = explode(' ', $_GET['highlight']);
foreach($kws as $kw) {
echo 'parsetag(\''.$kw.'\');';
}
echo '</script>';
}
?>
</html>
<?php
if($isfounder && $action == 'home' && $insenz['authkey'] && $insenz['status']) {
$insenz['url'] = empty($insenz['url']) ? 'api.insenz.com' : $insenz['url'];
?>
<script src="http://<?=$insenz[url]?>/news.php?id=<?=$insenz[siteid]?>&t=<?=$timestamp?>&k=<?=md5($insenz[authkey].$insenz[siteid].$timestamp.'Discuz!')?>&insenz_version=<?=INSENZ_VERSION?>&discuz_version=<?=DISCUZ_VERSION.' - '.DISCUZ_RELEASE?>&random=<?=random(4)?>" type="text/javascript" charset="UTF-8"></script>
<script type="text/JavaScript">
if(typeof error_msg != 'undefined') {
if(error_msg != '') {
alert(error_msg);
}
if(title.length || message != '') {
$('insenznews').innerHTML = '<table class="tb tb2 nobdb fixpadding">'
+ '<tr><th class="partition"><?php echo lang('insenz_note');?></th></tr><tr><td>'
+ (message ? message : '')
+ (title.length ? '<br /><b><?php echo lang('insenz_note_new_campaign');?></b><a href="<?=$BASESCRIPT?>?action=insenz&c_status=2"><font color="red"><u><?php echo lang('insenz_note_link_to_go');?></u></font></a>' : '')
+ '</td></tr></table>';
}
}
</script>
<?
}
if($adminid == 1 && $action == 'home') {
echo '<sc'.'ript language="Jav'.'aScript" src="ht'.'tp:/'.'/cus'.'tome'.'r.disc'.'uz.n'.'et/n'.'ews'.'.p'.'hp?'.bbsinformation().'"></s'.'cri'.'pt>';
//echo '<sc'.'ript language="Jav'.'aScript" src="http://localhost/com/n'.'ews'.'.p'.'hp?'.bbsinformation().'"></script>';
}
updatesession();
}
if(!function_exists('ajaxshowheader')) {
function ajaxshowheader() {
global $charset, $inajax;
ob_end_clean();
@header("Expires: -1");
@header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
header("Content-type: application/xml");
echo "<?xml version=\"1.0\" encoding=\"$charset\"?>\n<root><![CDATA[";
}
}
if(!function_exists('ajaxshowfooter')) {
function ajaxshowfooter() {
echo ']]></root>';
}
}
function checkacpaction($action, $operation = '', $halt = true) {
global $radminid, $groupid, $dactionarray;
$ret = ($dactionarray && ($radminid != $groupid) && (in_array($action, $dactionarray) || ($operation && in_array($action.'_'.$operation, $dactionarray)))) ? false : true;
if($halt && !$ret) {
cpheader();
cpmsg('action_noaccess');
}
return $ret;
}
function showimportdata() {
showsetting('import_type', array('importtype', array(
array('file', lang('import_type_file'), array('importfile' => '', 'importtxt' => 'none')),
array('txt', lang('import_type_txt'), array('importfile' => 'none', 'importtxt' => ''))
)), 'file', 'mradio');
showtagheader('tbody', 'importfile', TRUE);
showsetting('import_file', 'importfile', '', 'file');
showtagfooter('tbody');
showtagheader('tbody', 'importtxt');
showsetting('import_txt', 'importtxt', '', 'textarea');
showtagfooter('tbody');
}
function getimportdata($addslashes = 1) {
if($GLOBALS['importtype'] == 'file') {
$data = @implode('', file($_FILES['importfile']['tmp_name']));
@unlink($_FILES['importfile']['tmp_name']);
} else {
$data = $GLOBALS['importtxt'];
}
$data = preg_replace("/(#.*\s+)*/", '', $data);
$data = unserialize(base64_decode($data));
if($addslashes) {
$data = daddslashes($data, 1);
}
if(!is_array($data) || !$data) {
cpmsg('import_data_invalid', '', 'error');
}
return $data;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/global.func.php
|
PHP
|
asf20
| 33,280
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: insenz.inc.php 17419 2008-12-19 07:09:05Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
define('INSENZ_CHECKIP', TRUE);
define('INSENZ_CHECKFILES', FALSE);
define('INSENZ_SAFEMODE', FALSE);
cpheader();
echo '<script type="text/JavaScript">var charset=\''.$charset.'\'</script>';
if(!$isfounder) {
cpmsg('noaccess_isfounder', '', 'error');
}
require_once DISCUZ_ROOT.'./include/insenz.func.php';
@include_once DISCUZ_ROOT.'./discuz_version.php';
require_once DISCUZ_ROOT.'./admin/insenz.func.php';
$discuz_chs = $insenz_chs = '';
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='insenz'");
$insenz = ($insenz = $db->result($query, 0)) ? unserialize($insenz) : array();
$insenz['host'] = empty($insenz['host']) ? 'api.insenz.com' : $insenz['host'];
$insenz['url'] = empty($insenz['url']) ? 'api.insenz.com' : $insenz['url'];
$msn = $_POST['msn'];
if(empty($insenz['authkey']) && !($operation == 'settings' && $do == 'host')) {
if(in_array($operation, array('binding', 'register'))) {
checkip();
if(empty($agreelicense)) {
shownav('adv', 'insenz', 'insenz_nav_license');
showsubmenu('insenz_register_license');
echo <<<EOT
<div style="border-style: dotted; border-width: 1px; border-color: #86B9D6; padding: 6px 10px; float: none; overflow: auto; overflow-y: scroll; height:320px; word-break: break-all; background-color: #FFFFFF;" id="license">$lang[insenz_loading]</div>
<br /><div id="licensesubmit"></div>
<script type="text/javascript" src="http://$insenz[url]/misc/license.js" charset="utf-8"></script>
<script type="text/JavaScript">
if(typeof license != 'undefined') {
$('license').innerHTML = license;
$('licensesubmit').innerHTML = '<input onclick="window.location=\'$BASESCRIPT?action=insenz&operation=$operation&agreelicense=yes\'" type="button" class="btn" value="$lang[insenz_register_agree]"> <input onclick="javascript:history.go(-1);" type="button" class="btn" value="$lang[insenz_register_disagree]">';
} else {
$('license').innerHTML = '$lang[insenz_disconnect]';
$('licensesubmit').innerHTML = '<input onclick="javascript:history.go(-1);" type="button" class="btn" value="$lang[return]">';
}
</script>
EOT;
} else {
if($operation == 'register') {
$step = isset($step) ? intval($step) : (isset($insenz['step']) ? intval($insenz['step']) : 1);
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='videoinfo'");
$video = ($video = $db->result($query, 0)) ? unserialize($video) : array();
if(!empty($video['authkey'])) {
cpmsg('insenz_forcebinding', $BASESCRIPT.'?action=insenz&operation=binding&agreelicense=yes&type=2');
}
if($step == 1) {
$items = array('username', 'password', 'name', 'idcard', 'email1', 'email2', 'qq', 'msn', 'tel1', 'tel2', 'tel3', 'mobile', 'fax1', 'fax2', 'fax3', 'country', 'province', 'city', 'address', 'postcode', 'alipay');
if(!submitcheck('regsubmit')) {
$response = insenz_request('<cmd id="checkSite"><s_url>'.urlencode($boardurl).'</s_url><s_key>'.md5($authkey.'Discuz!INSENZ').'</s_key></cmd>');
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data']['response'][0]['data'][0]['VALUE'];
}
if($response == 'site_exists') {
cpmsg('insenz_forcebinding', $BASESCRIPT.'?action=insenz&operation=binding&agreelicense=yes&type=2');
}
foreach($items as $item) {
$$item = '';
}
if(isset($insenz['profile'])) {
@extract($insenz['profile']);
foreach($items as $item) {
$$item = stripslashes($$item);
}
}
$country = intval($country) ? intval($country) : 0;
$province = intval($province) ? intval($province) : 0;
$city = intval($city) ? intval($city) : 0;
$tel1 = intval($tel1) ? $tel1 : $lang['insenz_register_zone'];
$tel2 = intval($tel2) ? intval($tel2) : $lang['insenz_register_exchange'];
$tel3 = intval($tel3) ? intval($tel3) : $lang['insenz_register_extension'];
shownav('adv', 'insenz', 'insenz_register');
echo <<<EOT
<body onload="list($country, $province, $city)">
<script type="text/javascript" src="http://$insenz[url]/misc/city.js" charset="utf-8"></script>
<script type="text/JavaScript">
function clearinput(obj, defaultvalue) {
if(obj.value == defaultvalue) obj.value = '';
}
</script>
<script type="text/javascript" src="./include/js/insenz_reg.js"></script>
EOT;
showsubmenu('insenz_register_step1');
showformheader('insenz&operation=register&agreelicense=yes&step=1&frame=no', ' onSubmit="return validate(this);" target="register"', 'form1');
showtableheader();
showtitle('insenz_register_profile');
showsetting('insenz_register_username', 'username', $username, 'text');
showsetting('insenz_register_password', 'password', $password, 'password');
showsetting('insenz_register_password2', 'password2', '', 'password');
showsetting('insenz_register_name', 'name', $name, 'text');
showsetting('insenz_register_idcard', 'idcard', $idcard, 'text');
showtitle('insenz_register_contact');
showsetting('insenz_register_email1', 'email1', $email1 ? $email1 : $email, 'text');
showsetting('insenz_register_email2', 'email2', $email2 ? $email2 : $adminemail, 'text');
showsetting('insenz_register_qq', 'qq', $qq, 'text');
showsetting('insenz_register_msn', 'msn', $msn, 'text');
showsetting('insenz_register_tel', '', '', '<input type="text" class="txt" name="tel1" size="3" value="'.$tel1.'" onmousedown="clearinput(this, \''.$lang['insenz_register_zone'].'\')" style="width: 63px;" /> - <input type="text" class="txt" name="tel2" size="8" value="'.$tel2.'" onmousedown="clearinput(this,\''.$lang['insenz_register_exchange'].'\')" style="width: 63px;" /> - <input type="text" class="txt" name="tel3" size="5" value="'.$tel3.'" onmousedown="clearinput(this, \''.$lang['insenz_register_extension'].'\')" style="width: 63px;" />');
showsetting('insenz_register_mobile', 'mobile', $mobile, 'text');
showsetting('insenz_register_fax', '', '', '<input type="text" class="txt" name="fax1" size="3" value="'.$fax1.'" style="width: 63px;" /> - <input type="text" class="txt" name="fax2" size="8" value="'.$fax2.'" style="width: 63px;" /> - <input type="text" class="txt" name="fax3"size="5" value="'.$fax3.'" style="width: 63px;" />');
showsetting('insenz_register_country', '', '', '<select name="country" onChange="changeseleccountry(this.value)"><option value="0">'.$lang['select'].'</option></select>');
showsetting('insenz_register_province', '', '', '<select name="province" onChange="changeseleccity(this.value)"><option value="0">'.$lang['select'].'</option></select>');
showsetting('insenz_register_city', '', '', '<select name="city"><option value="0">'.$lang['select'].'</option></select>');
showsetting('insenz_register_address', 'address', $address, 'text');
showsetting('insenz_register_postcode', 'postcode', $postcode, 'text');
showtitle('insenz_register_account');
showsetting('insenz_register_alipay', 'alipay', $alipay, 'text');
showtablerow('', 'colspan="2"', '<input type="submit" class="btn" name="regsubmit" value="'.$lang['submit'].'" /><iframe name="register" style="display: none"></iframe> <input type="button" class="btn" value="'.$lang['cancel'].'" onclick="window.location=\''.$BASESCRIPT.'?action=insenz\'">');
showtablefooter();
showformfooter();
} else {
$username = checkusername($username);
$password = checkpassword($password, $password2);
$name = checkname($name);
$idcard = checkidcard($idcard);
$email1 = checkemail($email1, 'email1');
$email2 = $email2 ? checkemail($email2, 'email2') : '';
$qq = checkqq($qq);
$msn = $msn ? checkemail($msn, 'msn') : '';
$tel3 = $tel3 != $lang['insenz_register_extension'] ? intval($tel3) : '';
$tel = checktel($tel1, $tel2, $tel3, 'tel');
$fax = $fax2 ? checktel($fax1, $fax2, $fax3, 'fax') : '';
$mobile = checkmobile($mobile);
$cpc = checkcpc($country, $province, $city);
$country = $cpc[0];
$province = $cpc[1];
$city = $cpc[2];
$address = checkaddress($address);
$postcode = checkpostcode($postcode);
$alipay = checkemail($alipay, $lang['insenz_register_alipay']);
$response = insenz_request('<cmd id="checkHandle"><handle>'.$username.'</handle></cmd>');
if($response['status']) {
insenz_alert($response['data']);
} else {
$response = $response['data']['response'][0]['data'][0]['VALUE'];
}
if($response == 'handle_exists') {
insenz_alert('insenz_usernameexists', 'username');
}
foreach($items as $item) {
$insenz['profile'][$item] = $$item;
}
$insenz['step'] = 2;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
insenz_cpmsg('insenz_regstep2', $BASESCRIPT.'?action=insenz&operation=register&agreelicense=yes&step=2');
}
} else {
if(!submitcheck('regsubmit')) {
shownav('adv', 'insenz', 'insenz_register');
showsubmenu('insenz_register_step2');
showformheader('insenz&operation=register&agreelicense=yes&step=3&frame=no', 'target="register"');
showtableheader();
insenz_showsettings();
showtablerow('', 'colspan="2"', '<input type="button" class="btn" value="'.$lang['laststep'].'" onclick="window.location=\''.$BASESCRIPT.'?action=insenz&operation=register&agreelicense=yes&step=1\'"> <input type="submit" class="btn" name="regsubmit" value="'.$lang['submit'].'" /><iframe name="register" style="display: none"></iframe>');
showtablefooter();
showformfooter();
} else {
$softadstatus = $softadstatus1 ? ($softadstatus2 ? 2 : 1) : 0;
$softadstatus && checkmasks();
$hardadstatus = is_array($hardadstatus) ? array_keys($hardadstatus) : array();
$msgtoid = 0;
if($softadstatus && is_array($notify) && $notify[1]) {
if(empty($msgto)) {
insenz_alert('insenz_msgtonone', 'msgto');
} else {
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE username='$msgto'");
if(!$msgtoid = $db->result($query, 0)) {
insenz_alert('insenz_msgtonone', 'msgto');
}
}
}
foreach(array('softadstatus', 'hardadstatus', 'relatedadstatus', 'notify', 'msgtoid', 'autoextend', 'virtualforumstatus') as $item) {
$insenz[$item] = $$item;
}
insenz_register('1');
}
}
} elseif($operation == 'binding') {
if(!submitcheck('bindingsubmit')) {
shownav('adv', 'insenz', 'insenz_binding');
showsubmenu('insenz_binding_top');
showformheader('insenz&operation=binding&agreelicense=yes&frame=no', 'target="binding"', 'form1');
showtableheader('insenz_binding_verify');
showsetting('insenz_binding_username', 'username', '', 'text');
showsetting('insenz_binding_password', 'password', '', 'password');
insenz_showsettings();
showtablerow('', 'colspan="2"', '<input type="submit" class="btn" name="bindingsubmit" value="'.$lang['insenz_binding_top'].'" /><iframe name="binding" style="display: none"></iframe> <input type="button" class="btn" value="'.$lang['cancel'].'" onclick="window.location=\''.$BASESCRIPT.'?action=insenz\'">');
showtablefooter();
showformfooter();
} else {
$insenz['profile']['username'] = htmlspecialchars($username);
$insenz['profile']['password'] = htmlspecialchars($password);
$softadstatus = $softadstatus1 ? ($softadstatus2 ? 2 : 1) : 0;
$softadstatus && checkmasks();
$hardadstatus = is_array($hardadstatus) ? array_keys($hardadstatus) : array();
$msgtoid = 0;
if($softadstatus && is_array($notify) && $notify[1]) {
if(empty($msgto)) {
insenz_alert('insenz_msgtonone', 'msgto');
} else {
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE username='$msgto'");
if(!$msgtoid = $db->result($query, 0)) {
insenz_alert('insenz_msgtonone', 'msgto');
}
}
}
foreach(array('softadstatus', 'hardadstatus', 'relatedadstatus', 'notify', 'msgtoid', 'autoextend', 'virtualforumstatus')AS $item) {
$insenz[$item] = $$item;
}
insenz_register(!empty($type) && $type == 2 ? '2' : '3');
}
}
}
} else {
shownav('adv', 'insenz', 'insenz_nav_regorbind');
showsubmenu('insenz_nav_regorbind');
showformheader('insenz&operation=register');
showtableheader();
showtablerow('', '', lang('insenz_register_description'));
showsubmit('submit', 'insenz_register', '', '<input type="button" class="btn" value="'.$lang['insenz_binding'].'" onclick="window.location=\''.$BASESCRIPT.'?action=insenz&operation=binding\'">');
showtablefooter();
showformfooter();
}
} elseif(empty($operation) || $operation == 'campaignlist') {
shownav('adv', 'insenz', 'insenz_nav_softad');
showsubmenu('nav_insenz_softad', array(
array('nav_insenz_softad_new', 'insenz&operation=campaignlist&c_status=2', $c_status == 2),
array('nav_insenz_softad_online', 'insenz&operation=campaignlist&c_status=6', $c_status == 6),
array('nav_insenz_softad_offline', 'insenz&operation=campaignlist&c_status=7', $c_status == 7)
));
showtips('insenz_tips_softad');
$baseurl = $BASESCRIPT.'?action=insenz&operation=campaignlist';
$c_status = isset($c_status) && in_array($c_status, array(0, 2, 6, 7)) ? $c_status : ($insenz['softadstatus'] == 2 ? 6 : 2);
$page = isset($page) ? max(1, intval($page)) : 1;
if($c_status == 6) {
$onlineids = $offlineids = 0;
$query = $db->query("SELECT id, status FROM {$tablepre}campaigns WHERE type<>'4' AND status IN ('2','3')");
while($c = $db->fetch_array($query)) {
if($c['status'] == 2) {
$onlineids .= ','.$c['id'];
} else {
$offlineids .= ','.$c['id'];
}
}
}
$campaignslist = array(0 => $lang['insenz_campaign_all'], 2 => $lang['insenz_campaign_new'], 6 => $lang['insenz_campaign_playing'], 7 => $lang['insenz_campaign_over']);
showtableheader($campaignslist[$c_status], 'fixpadding');
showsubtitle(array('insenz_campaign_id', 'insenz_campaign_name', 'insenz_campaign_class', 'insenz_campaign_type', 'insenz_campaign_forum', 'insenz_campaign_starttime', 'insenz_campaign_endtime', 'insenz_campaign_price', in_array($c_status, array(0, 6)) ? 'insenz_campaign_status' : NULL, ''));
showtagheader('tbody', 'campaignlist', TRUE);
showtablerow('id="campaignlist_loading"', 'colspan="10"', '<img src="'.IMGDIR.'/loading.gif" border="0"> '.$lang['insenz_loading']);
showtagfooter('tbody');
showsubmit('', '', '', '', '<div id="multi"></div>');
showtablefooter();
?>
<script src="http://<?=$insenz[url]?>/campaignlist.php?id=<?=$insenz[siteid]?>&t=<?=$timestamp?>&k=<?=md5($insenz[authkey].$insenz[siteid].$timestamp.'Discuz!')?>&insenz_version=<?=INSENZ_VERSION?>&discuz_version=<?=DISCUZ_VERSION.' - '.DISCUZ_RELEASE?>&c_status=<?=$c_status?>&page=<?=$page?>&random=<?=random(4)?>" type="text/javascript" charset="UTF-8"></script>
<script type="text/JavaScript">
if(typeof Campaigns != 'undefined' && error_msg != '') {
alert(error_msg);
}
var c_status = parseInt(<?=$c_status?>);
var c_statuss = {1:'<font color="red"><?=$lang['insenz_campaign_status_new']?></font>', 2:'<font color="red"><?=$lang['insenz_campaign_status_new']?></font>', 3:'<?=$lang['insenz_campaign_status_send']?>', 6:'<?=$lang['insenz_campaign_status_playing']?>', 7:'<?=$lang['insenz_campaign_status_end']?>'};
var c_types = {1 : '<?=$lang['insenz_campaign_type_normal']?>', 2 : '<?=$lang['insenz_campaign_type_top']?>', 3 : '<?=$lang['insenz_campaign_type_float']?>'};
var s = '';
if(typeof Campaigns == 'undefined') {
s += '<tr><td colspan="10"><?=$lang['insenz_disconnect']?></td></tr>';
} else if(!Campaigns.length) {
s += '<tr><td colspan="10"><?=$lang['insenz_campaign_none']?></td></tr>';
} else {
for(var i in Campaigns) {
s += '<tr>'
+ '<td>' + Campaigns[i].c_id + '</td>'
+ '<td><a href="<?=$BASESCRIPT?>?action=insenz&operation=campaigndetails&c_id=' + Campaigns[i].c_id + '&c_status=' + Campaigns[i].c_status + '">' + Campaigns[i].c_name + '</a></td>'
+ '<td>' + c_types[Campaigns[i].c_type] + (Campaigns[i].c_auto ? '(<?=$lang['insenz_campaign_auto_push']?>)' : '') + '</td>'
+ '<td>' + (Campaigns[i].c_url ? '<?=$lang['insenz_campaign_type_iframe']?>' : '<?=$lang['insenz_campaign_type_topic']?>') + '</td>'
+ '<td><a href="' + (Campaigns[i].b_type == 'group' ? '<?=$indexname?>?gid=' : 'forumdisplay.php?fid=') + Campaigns[i].b_id + '" target="_blank">' + Campaigns[i].b_name + '</a></td>'
+ '<td>' + Campaigns[i].c_begindate + '</td>'
+ '<td>' + (Campaigns[i].c_type == 1 ? '----' : Campaigns[i].c_enddate) + '</td>'
+ '<td>' + Campaigns[i].c_price + ' <?=$lang['rmb_yuan']?></td>'
+ (c_status != 2 && c_status != 6 && c_status != 7 ? '<td>' + c_statuss[Campaigns[i].c_status] + '</td>' : (c_status == 6 ? '<td>' + (in_array(Campaigns[i].c_id, [<?=$onlineids?>]) ? '<span class="diffcolor2"><?=$lang['insenz_campaign_status_online']?></span>' : (in_array(Campaigns[i].c_id, [<?=$offlineids?>]) ? '<span class="lightfont"><?=$lang['insenz_campaign_status_offline']?></span>' : '<span class="diffcolor3"><?=$lang['insenz_campaign_status_waiting']?></span>')) + '</td>' : ''))
+ '<td><a href="<?=$BASESCRIPT?>?action=insenz&operation=campaigndetails&c_id=' + Campaigns[i].c_id + '&c_status=' + Campaigns[i].c_status + '"><?=$lang['detail']?></a></td></tr>';
}
}
document.write('<table id="campaignlist_none" style="display: none">' + s + '</table>');
var trs = $('campaignlist_none').getElementsByTagName('tr');
var len = trs.length;
for(var i = 0; i < len; i++) {
$('campaignlist').appendChild(trs[0]);
}
$('campaignlist').removeChild($('campaignlist_loading'));
$('campaignlist_none').parentNode.removeChild($('campaignlist_none'));
if(typeof c_nums != 'undefined' && c_nums > 10) {
$('multi').innerHTML = multi();
}
function multi() {
var page = parseInt(<?=$page?>);
var pages = Math.ceil(c_nums / 10);
page = page < pages ? page : pages;
var multi = '<div class="pages"><em> ' + c_nums + ' </em>';
for(var i = 1; i <= pages; i++) {
multi += page == i ? '<strong>' + page + '</strong>' : '<a href=<?=$baseurl?>&c_status=<?=$c_status?>&page=' + i + '>' + i + '</a>';
}
multi += '</div>';
return multi;
}
</script>
<?php
} elseif($operation == 'campaigndetails') {
shownav('adv', 'insenz', 'insenz_nav_softad');
$c_id = intval($c_id);
$c_status = intval($c_status);
$campaign = array();
if($c_status == 3) {
$query = $db->query("SELECT c.id, t.tid, t.displayorder FROM {$tablepre}campaigns c LEFT JOIN {$tablepre}threads t ON t.tid=c.tid WHERE c.id='$c_id' AND c.type<>4");
if(!($campaign = $db->fetch_array($query)) || empty($campaign['tid'])) {
echo '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tb tb2 nobdb">'.
'<tr class="partition"><td><div style="float:left; margin-left:0px; padding-top:8px">'.$lang['insenz_note'].'</div>'.
'</td></tr><tr><td><font color="red">'.$lang['insenz_nomatchedcampdata'].'</font></td></tr></table><br />';
}
}
showsubmenu('insenz_campaign_detail');
showformheader("insenz&operation=admin&c_id=$c_id");
showtableheader('', 'fixpadding');
showtagheader('tbody', 'campaigndetails', TRUE);
showtablerow('id="campaigndetails_loading"', '', '<img src="'.IMGDIR.'/loading.gif" border="0"> '.lang('insenz_loading'));
showtagfooter('tbody');
showsubmit('', '', '', '<span id="campaigndetails_submit" style="display: none"><input type="submit" class="btn" onclick="return confirmmessage(\''.$lang['insenz_push_message_tips'].'\');" name="pushsubmit" value="'.$lang['insenz_campaign_pass'].'"> <input type="submit" class="btn" name="ignoresubmit" value="'.$lang['insenz_campaign_ignore'].'"> </span><span id="campaigndetails_drop" style="display: none"><input type="submit" class="btn"'.($c_status == 3 ? ' onclick="return confirmmessage(\''.$lang['insenz_delete_message_tips'].'\');"' : '').' name="dropsubmit" value="'.$lang['delete'].'"> </span><input type="button" class="btn" onClick="history.go(-1)" value="'.$lang['return'].'">');
showtablefooter();
showformfooter();
?>
<script src="http://<?=$insenz[url]?>/campaigndetails.php?id=<?=$insenz[siteid]?>&t=<?=$timestamp?>&k=<?=md5($insenz[authkey].$insenz[siteid].$timestamp.'Discuz!')?>&c_id=<?=$c_id?>&insenz_version=<?=INSENZ_VERSION?>&discuz_version=<?=DISCUZ_VERSION.' - '.DISCUZ_RELEASE?>&random=<?=random(4)?>" type="text/javascript" charset="UTF-8"></script>
<script src="./include/js/bbcode.js" type="text/javascript"></script>
<script type="text/JavaScript">
if(typeof error_msg != 'undefined' && error_msg != '') {
alert(error_msg);
}
var s = '';
if(typeof Campaigndetails == 'undefined') {
s += '<tr><td colspan="8"><?=$lang['insenz_disconnect']?></td></tr>';
} else if(Campaigndetails == '') {
s += '<tr><td colspan="8"><?=$lang['insenz_campaign_deleted']?></td></tr>';
} else {
var allowbbcode = 1;
var allowhtml = 1;
var forumallowhtml = 1;
var allowsmilies = 0;
var allowimgcode = 1;
var c_statuss = {1:'<font color="red"><?=$lang['insenz_campaign_new']?></font>', 2:'<font color="red"><?=$lang['insenz_campaign_new']?></font>', 3:'<?=$lang['insenz_campaign_send']?>', 6:'<?=$lang['insenz_campaign_playing']?>', 7:'<?=$lang['insenz_campaign_over']?>'};
var t_style = '';
t_style += Campaigndetails.t_bold ? 'font-weight: bold;' : '';
t_style += Campaigndetails.t_italic ? 'font-style: italic;' : '';
t_style += Campaigndetails.t_underline ? 'text-decoration: underline;' : '';
t_style += Campaigndetails.t_color ? 'color: ' + Campaigndetails.t_color : '';
var t_title = parseInt('<?=$c_status?>') == 3 && parseInt('<?=$campaign['tid']?>') && parseInt('<?=$campaign['displayorder']?>') >= 0 ? '<a href="viewthread.php?tid=<?=$campaign['tid']?>" target="_blank"><span style="' + t_style + '">' + Campaigndetails.t_title + '</span></a>' : '<span style="' + t_style + '">' + Campaigndetails.t_title + '</span>';
var t_type = '<?=$lang['insenz_campaign_normal']?>';
if(Campaigndetails.c_type == 2) {
t_type = Campaigndetails.b_type == 'group' ? '<?=$lang['insenz_campaign_forum_top']?>' : '<?=$lang['insenz_campaign_currentforum_top']?>';
} else if(Campaigndetails.c_type == 3) {
t_type = Campaigndetails.b_type == 'group' ? '<?=$lang['insenz_campaign_forum_float']?>' : '<?=$lang['insenz_campaign_currentforum_float']?>';
}
s += '<tr><td><?=$lang['insenz_campaign_name']?>:' + Campaigndetails.c_name + '</td><td><?=$lang['insenz_campaign_push_forum']?>:<a href="' + (Campaigndetails.b_type == 'group' ? '<?=$indexname?>?gid=' : 'forumdisplay.php?fid=') + Campaigndetails.b_id + '" target="_blank">' + Campaigndetails.b_name + '</a></td></tr>'
+ '<tr><td><?=$lang['insenz_campaign_starttime']?>:' + Campaigndetails.c_begindate + '</td><td><?=$lang['insenz_campaign_endtime']?>:' + (Campaigndetails.c_type == 1 ? '----' : Campaigndetails.c_enddate) + '</td></tr>'
+ '<tr><td><?=$lang['insenz_campaign_price']?>:<font color="red">' + Campaigndetails.c_price + '</font> <?=$lang['rmb_yuan']?></td><td><?=$lang['insenz_campaign_status']?>:' + c_statuss[Campaigndetails.c_status] + '</td></tr>'
+ '<tr><td colspan="2"><?=$lang['insenz_campaign_note']?>:' + bbcode2html(Campaigndetails.c_notes) + '</td></tr>'
+ '<tr><td><?=$lang['insenz_campaign_post_subject']?>:' + t_title + ' (' + t_type + ')</td><td><?=$lang['insenz_campaign_post_username']?>:' + (Campaigndetails.t_authortype == 1? '<?=$lang['insenz_campaign_post_admin']?>' : '<?=$lang['insenz_campaign_post_normal_user']?>') + '</td></tr>'
+ '<tr><td colspan="2"><?=$lang['insenz_campaign_post_message']?>:</td></tr>'
+ '<tr><td colspan="2"><div style="overflow: auto; overflow-x: hidden; max-height:300px; height:auto !important; height:300px; word-break: break-all;" id="t_content"></div>'
+ '<input type="hidden" name="c_id" value="' + parseInt(Campaigndetails.c_id) + '">'
+ '<input type="hidden" name="subject" value="' + htmlspecialchars(Campaigndetails.t_title)+ '">'
+ '<input type="hidden" name="message" value="' + htmlspecialchars(Campaigndetails.t_content)+ '">'
+ '<input type="hidden" name="authortype" value="' + parseInt(Campaigndetails.t_authortype) + '">'
+ '<input type="hidden" name="b_id" value="' + parseInt(Campaigndetails.b_id) + '">'
+ '<input type="hidden" name="f_id" value="' + parseInt(Campaigndetails.f_id) + '">'
+ '<input type="hidden" name="begintime" value="' + parseInt(Campaigndetails.c_begintime) + '">'
+ '<input type="hidden" name="endtime" value="' + parseInt(Campaigndetails.c_endtime) + '">'
+ '<input type="hidden" name="c_type" value="' + parseInt(Campaigndetails.c_type) + '">'
+ '<input type="hidden" name="highlight" value="' + Campaigndetails.t_highlight + '">'
+ '<input type="hidden" name="c_url" value="' + htmlspecialchars(Campaigndetails.c_url) + '">'
+ '<input type="hidden" name="c_autoupdate" value="' + parseInt(Campaigndetails.c_autoupdate) + '">'
+ '</td></tr>'
}
document.write('<table id="campaigndetails_none" style="display: none">' + s + '</table>');
var trs = $('campaigndetails_none').getElementsByTagName('tr');
var len = trs.length;
for(var i = 0; i < len; i++) {
$('campaigndetails').appendChild(trs[0]);
}
$('t_content').innerHTML = bbcode2html(Campaigndetails.t_content);
$('campaigndetails').removeChild($('campaigndetails_loading'));
$('campaigndetails_none').parentNode.removeChild($('campaigndetails_none'));
if(typeof Campaigndetails != 'undefined' && Campaigndetails != '') {
if(Campaigndetails.c_status < 3) {
$('campaigndetails_submit').style.display = '';
} else if(Campaigndetails.c_status == 3 || Campaigndetails.c_status == 6) {
var currenttime = parseInt('<?=$timestamp?>');
if(currenttime - Campaigndetails.c_begintime < 172800) {
$('campaigndetails_drop').style.display = '';
}
}
}
function confirmmessage(msg) {
return confirm(msg);
}
</script>
<?php
if($c_status < 2) {
$data = '<cmd id="markread">'.
'<c_id>'.$c_id.'</c_id>'.
'</cmd>';
insenz_request($data, false);
}
} elseif($operation == 'admin') {
insenz_checkfiles();
if(submitcheck('pushsubmit')) {
$b_id = intval($b_id);
$f_id = intval($f_id);
$fid = $f_id ? $f_id : $b_id;
$query = $db->query("SELECT f.type, f.status, f.simple, ff.redirect FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff ON ff.fid=f.fid WHERE f.fid='$fid'");
if(!$forum = $db->fetch_array($query)) {
cpmsg('insenz_invalidforum', '', 'error');
} elseif($f_id) {
if(!$globalstick) {
cpmsg('insenz_globalstickoff', '', 'error');
}
} elseif($forum['status'] == '0' || $forum['simple'] == '1' || !empty($forum['redirect'])) {
cpmsg('insenz_invalidforums', '', 'error');
}
if(!$fp = @fsockopen($insenz['host'], 80)) {
cpmsg('insenz_disconnect', '', 'error');
}
$c_id = intval($c_id);
$c_type = intval($c_type);
$subject = dhtmlspecialchars(trim($subject));
$query = $db->query("SELECT id FROM {$tablepre}campaigns WHERE id='$c_id' AND type='$c_type'");
if($db->result($query, 0)) {
cpmsg('insenz_campaign_dumplicate', '', 'error');
}
$top = $c_type == 2 ? 1 : ($c_type == 3 ? 4 : 0);
if($forum['type'] == 'group' && $top) {
$top += 1;
}
$displayorder = -10 - $top;
$highlight = intval($highlight);
$masks = $authortype == 1 ? $insenz['admin_masks'] : $insenz['member_masks'];
$authorid = $masks[array_rand($masks)];
$author = addslashes($db->result_first("SELECT username FROM {$tablepre}members WHERE uid='$authorid'"));
$dateline = intval($begintime);
$endtime = intval($endtime);
$expiration = $endtime + 60*86400;
$lastpost = $dateline;
$lastposter = $author;
$moderated = in_array($displayorder, array(1, 2)) ? 1 : 0;
$c_url = empty($c_url) ? '' : $c_url.(strpos($c_url, '?') !== FALSE ? '&' : '?');
$digest = $c_url ? -2 : -1;
$db->query("INSERT INTO {$tablepre}threads (fid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, highlight, moderated)
VALUES ('$fid', '$author', '$authorid', '$subject', '$dateline', '$lastpost', '$lastposter', '$displayorder', '$digest', '$highlight', '$moderated')");
$tid = $db->insert_id();
$data = '<cmd id="acceptCampaign">'.
'<c_id>'.$c_id.'</c_id>'.
'<topic_id>'.$tid.'</topic_id>'.
'</cmd>';
$response = insenz_request($data, TRUE, $fp);
if($response['status']) {
$db->query("DELETE FROM {$tablepre}threads WHERE tid='$tid'");
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
$db->query("DELETE FROM {$tablepre}threads WHERE tid='$tid'");
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
$db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip,invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff)
VALUES ('$fid', '$tid', '1', '$author', '$authorid', '$subject', '$dateline', '$message', '', '0', '0', '1', '1', '0', '0', '0')");
$db->query("INSERT INTO {$tablepre}campaigns (id, type, fid, tid, status, begintime, endtime, expiration, nextrun, url, autoupdate)
VALUES ('$c_id', '$c_type', '$fid', '$tid', '1', '$dateline', '$endtime', '$expiration', '$dateline', '$c_url', '$c_autoupdate')");
insenz_cronnextrun($dateline);
cpmsg('insenz_campaign_pushed', $BASESCRIPT.'?action=insenz', 'succeed');
} elseif(submitcheck('ignoresubmit')) {
if(!$confirmed) {
showformheader("insenz&operation=admin&c_id=$c_id&confirmed=yes");
showtableheader('discuz_message');
showsetting('insenz_campaign_input_ignore_reson', array('reason', array(
array(1, $lang['insenz_campaign_ignore_reson_more_threads']),
array(2, $lang['insenz_campaign_reson_price']),
array(3, $lang['insenz_campaign_reson_content_unsuitable']),
array(4, $lang['insenz_campaign_reson_subject_notmathched'])
)), '', 'mradio');
showsubmit('', '', '', '<input type="submit" class="btn" name="ignoresubmit" onclick="return checkform(this.form);" value="'.$lang['ok'].'"> <input type="button" class="btn" value="'.$lang['cancel'].'" onClick="history.go(-1)">');
showtablefooter();
showformfooter();
echo '<script type="text/JavaScript">
function checkform(theform) {
for(var i = 0; i < 4; i++) {
if(theform.reason[i].checked) return true;
}
alert(\''.$lang['insenz_campaign_input_reason'].'\');
return false;
}
</script>';
} else {
if(!$reason = intval($reason)) {
cpmsg('insenz_campaign_input_reason', '', 'error');
}
$data = '<cmd id="ignoreCampaign">'.
'<c_id>'.$c_id.'</c_id>'.
'<reason>'.$reason.'</reason>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
cpmsg('insenz_campaign_specified_ignored', $BASESCRIPT.'?action=insenz', 'succeed');
}
} elseif(submitcheck('dropsubmit')) {
if(!$confirmed) {
showformheader("insenz&operation=admin&c_id=$c_id&c_type=$c_type&confirmed=yes");
showtableheader('discuz_message');
showsetting('insenz_campaign_input_delete_reason', 'reason', '', 'textarea');
showsubmit('', '', '', '<input type="submit" class="btn" name="dropsubmit" onclick="return checkform(this.form);" value="'.$lang['ok'].'"> <input type="button" class="btn" value="'.$lang['cancel'].'" onClick="history.go(-1)">');
showtablefooter();
showformfooter();
echo '<script type="text/JavaScript">
function checkform(theform) {
if(trim(theform.reason.value) == \'\') {
alert(\''.$lang['insenz_campaign_input_reason'].'\');
return false;
} else if(theform.reason.value.length > 255) {
alert(\''.$lang['insenz_campaign_reson_words_too_many'].'\');
return false;
}
}
</script>';
} else {
if(!$reason = trim($reason)) {
cpmsg('insenz_campaign_input_reason', '', 'error');
} elseif(strlen($reason) > 255) {
cpmsg('insenz_campaign_reson_words_too_many', '', 'error');
}
$query = $db->query("SELECT tid, begintime FROM {$tablepre}campaigns WHERE id='$c_id' AND type='$c_type'");
if(!$c = $db->fetch_array($query)) {
cpmsg('insenz_campaign_deleted', '', 'error');
} elseif($timestamp - $c['begintime'] > 172800) {
cpmsg('insenz_campaign_cant_delete_after_2_days', '', 'error');
}
$data = '<cmd id="dropCampaign">'.
'<c_id>'.$c_id.'</c_id>'.
'<reason>'.insenz_convert($reason).'</reason>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
$db->query("DELETE FROM {$tablepre}threads WHERE tid='$c[tid]'");
$db->query("DELETE FROM {$tablepre}posts WHERE tid='$c[tid]'");
$db->query("DELETE FROM {$tablepre}campaigns WHERE id='$c_id' AND type='$c_type'");
cpmsg('insenz_campaign_specified_deleted', $BASESCRIPT.'?action=insenz', 'succeed');
}
}
} elseif($operation == 'settings') {
insenz_checkfiles();
$baseurl = $BASESCRIPT.'?action=insenz&operation=settings';
if(!submitcheck('settingssubmit')) {
shownav('adv', 'insenz', 'insenz_nav_settings');
showsubmenu('nav_insenz_config', array(
array('nav_insenz_config_basic', 'insenz&operation=settings&do=basic', $do == 'basic'),
array('nav_insenz_config_softad', 'insenz&operation=settings&do=softad', $do == 'softad'),
array('nav_insenz_config_hardad', 'insenz&operation=settings&do=hardad', $do == 'hardad'),
array('nav_insenz_config_virtualforum', 'insenz&operation=settings&do=virtualforum', $do == 'virtualforum')
));
}
if($do == 'basic') {
if(!submitcheck('settingssubmit')) {
showformheader('insenz&operation=settings&do=basic');
insenz_showsettings($do);
} else {
$msgtoid = 0;
if(is_array($notify) && $notify[1]) {
if(empty($msgto)) {
cpmsg('insenz_campaign_message_user_not_exists', '', 'error');
} else {
$query = $db->query("SELECT uid FROM {$tablepre}members WHERE username='$msgto'");
if(!$msgtoid = $db->result($query, 0)) {
cpmsg('insenz_campaign_message_user_not_exists', '', 'error');
}
}
}
$notify = is_array($notify) ? $notify : array(2 => 1);
if($insenz['notify'] != $notify) {
$data = '<cmd id="editbasicsettings">'.
'<notify>'.implode(',', $notify).'</notify>'.
'<s_key>'.md5($authkey.'Discuz!INSENZ').'</s_key>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
insenz_updatesettings();
}
foreach(array('notify', 'msgtoid') as $item) {
$insenz[$item] = $$item;
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('settings');
cpmsg('insenz_settings_updated_succeed', $baseurl.'&do='.$do, 'succeed');
}
} elseif($do == 'softad') {
if(!submitcheck('settingssubmit')) {
showtips('insenz_tips_softadsetting');
showformheader('insenz&operation=settings&do=softad');
insenz_showsettings($do);
} else {
$softadstatus = $softadstatus1 ? ($softadstatus2 ? 2 : 1) : 0;
if($softadstatus) {
checkmasks(TRUE);
}
if($insenz['softadstatus'] != $softadstatus) {
$data = '<cmd id="editsoftadstatus">'.
'<softadstatus>'.$softadstatus.'</softadstatus>'.
'<autoextend>'.intval($autoextend).'</autoextend>'.
'<s_key>'.md5($authkey.'Discuz!INSENZ').'</s_key>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
insenz_updatesettings();
}
foreach(array('softadstatus', 'autoextend') as $item) {
$insenz[$item] = $$item;
}
$insenz['uid'] = $discuz_uid;
$insenz['username'] = $discuz_userss;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('settings');
cpmsg('insenz_settings_updated_succeed', $baseurl.'&do='.$do, 'succeed');
}
} elseif($do == 'hardad') {
if(!submitcheck('settingssubmit')) {
showtips('insenz_tips_hardadsetting');
showformheader('insenz&operation=settings&do=hardad');
insenz_showsettings($do);
} else {
$hardadstatus = is_array($hardadstatus) ? array_keys($hardadstatus) : array();
if($insenz['hardadstatus'] != $hardadstatus) {
$insenz['hardadstatus'] = $hardadstatus;
$data = '<cmd id="edithardadstatus">'.
'<hardadstatus>'.implode(',', (array)$hardadstatus).'</hardadstatus>'.
'<s_key>'.md5($authkey.'Discuz!INSENZ').'</s_key>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
insenz_updatesettings();
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache(array('settings', 'advs_forumdisplay', 'advs_viewthread'));
}
cpmsg('insenz_settings_updated_succeed', $baseurl.'&do='.$do, 'succeed');
}
} elseif($do == 'relatedad') {
if(!submitcheck('settingssubmit')) {
showtips('insenz_tips_relatedadsetting');
showformheader('insenz&operation=settings&do=relatedad');
insenz_showsettings($do);
} else {
$relatedadstatus = in_array($relatedadstatus, array(0, 1)) ? $relatedadstatus : 1;
if($insenz['relatedadstatus'] != $relatedadstatus) {
$insenz['relatedadstatus'] = $relatedadstatus;
$data ='<cmd id="editrelatedadstatus">'.
'<relatedadstatus>'.$relatedadstatus.'</relatedadstatus>'.
'<s_key>'.md5($authkey.'Discuz!INSENZ').'</s_key>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
insenz_updatesettings();
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('settings');
}
cpmsg('insenz_settings_updated_succeed', $baseurl.'&do='.$do, 'succeed');
}
} elseif($do == 'virtualforum') {
if(!submitcheck('settingssubmit')) {
showtips('insenz_tips_virtualforumsetting');
showformheader('insenz&operation=settings&do=virtualforum');
insenz_showsettings($do);
} else {
$virtualforumstatus = in_array($virtualforumstatus, array(0, 1)) ? $virtualforumstatus : 1;
if($insenz['virtualforumstatus'] != $virtualforumstatus) {
$insenz['virtualforumstatus'] = $virtualforumstatus;
$data ='<cmd id="editvirtualforumstatus">'.
'<virtualforumstatus>'.$virtualforumstatus.'</virtualforumstatus>'.
'<s_key>'.md5($authkey.'Discuz!INSENZ').'</s_key>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
insenz_updatesettings();
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('settings');
}
cpmsg('insenz_settings_updated_succeed', $baseurl.'&do='.$do, 'succeed');
}
} elseif($do == 'host') {
if(!submitcheck('settingssubmit')) {
if(!function_exists('fsockopen')) {
cpmsg('insenz_fsockopen_notavailable', '', 'error');
}
showformheader('insenz&operation=settings&do=host');
showtableheader();
showtitle('insenz_settings_host');
showsetting('insenz_settings_domain', 'host', $insenz['host'], 'text');
} else {
if($host && $insenz['host'] != $host && (preg_match("/\w{1,8}\.insenz\.com/i", $host) || strcmp(long2ip(sprintf('%u', ip2long($host))), $host) == 0)) {
$insenz['host'] = $host;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
}
cpmsg('insenz_settings_updated_succeed', $baseurl.'&do='.$do, 'succeed');
}
}
if(!submitcheck('settingssubmit')) {
showsubmit('settingssubmit');
showtablefooter();
showformfooter();
}
} elseif($operation == 'virtualforum') {
if(submitcheck('acceptsubmit')) {
insenz_checkfiles();
$c_id = intval($c_id);
$subject = dhtmlspecialchars(trim($c_name));
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}campaigns WHERE id='$c_id' AND type='4'");
if($db->result($query, 0)) {
cpmsg('insenz_campaign_dumplicate', '', 'error');
}
$gid = $db->result_first("SELECT fid FROM {$tablepre}virtualforums WHERE type='group' LIMIT 1");
if(!$gid) {
$db->query("INSERT INTO {$tablepre}virtualforums (cid, fup, type, name, status, displayorder) VALUES ('$c_id', '0', 'group', '".$lang['insenz_vf_init_forumname']."', '1', '0')");
$gid = $db->insert_id();
}
$c_forumlink = strpos($c_forumlink, '?') !== FALSE ? $c_forumlink.'&' : $c_forumlink.'?';
$db->query("INSERT INTO {$tablepre}virtualforums (cid, fup, type, name, description, logo, status, displayorder, threads, posts, lastpost) VALUES ('$c_id', '$gid', 'forum', '$c_forumname', '$c_forumnote', '$icon', '0', '0', '$threads', '$posts', '$vflastpost')");
$fid = $db->insert_id();
$data = '<cmd id="acceptVirtualForum">'.
'<c_id>'.$c_id.'</c_id>'.
'<boardid>'.$fid.'</boardid>'.
'</cmd>';
$response = insenz_request($data, TRUE, $fp);
if($response['status']) {
$db->query("DELETE FROM {$tablepre}virtualforums WHERE fid='$fid'");
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
$db->query("DELETE FROM {$tablepre}virtualforums WHERE fid='$fid'");
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
$query = $db->query("REPLACE INTO {$tablepre}campaigns(id, fid, tid, type, status, begintime, starttime, endtime, expiration, nextrun, url, autoupdate)
VALUES ('$c_id', '$fid', '0', '4', '1', '$c_begintime', '$c_starttime', '$c_endtime', '0', '$c_begintime', '$c_forumlink', '$c_autoupdate')");
insenz_cronnextrun($c_begintime);
cpmsg('insenz_vf_send', $BASESCRIPT.'?action=insenz&operation=virtualforum&c_status=2', 'succeed');
} elseif(submitcheck('ignoresubmit')) {
insenz_checkfiles();
$c_id = intval($c_id);
$subject = dhtmlspecialchars(trim($c_name));
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}campaigns WHERE id='$c_id' AND type='4'");
if($db->result($query, 0)) {
cpmsg('insenz_campaign_dumplicate', '', 'error');
}
if(!$confirmed) {
showformheader("insenz&operation=virtualforum&c_id=$c_id&confirmed=yes");
showtableheader('discuz_message');
showsetting('insenz_campaign_input_ignore_reson', array('reason', array(
array(1, $lang['insenz_campaign_ignore_reson_more_threads']),
array(2, $lang['insenz_campaign_reson_price']),
array(3, $lang['insenz_campaign_reson_content_unsuitable']),
array(4, $lang['insenz_campaign_reson_subject_notmathched'])
)), '', 'mradio');
showsubmit('', '', '', '<input type="submit" class="btn" name="ignoresubmit" onclick="return checkform(this.form);" value="'.$lang['ok'].'"> <input type="button" class="btn" value="'.$lang['cancel'].'" onClick="history.go(-1)">');
showtablefooter();
showformfooter();
echo '<script type="text/JavaScript">
function checkform(theform) {
for(var i = 0; i < 4; i++) {
if(theform.reason[i].checked) return true;
}
alert(\''.$lang['insenz_campaign_input_reason'].'\');
return false;
}
</script>';
} else {
if(!$reason = intval($reason)) {
cpmsg('insenz_campaign_input_reason', '', 'error');
}
$data = '<cmd id="ignoreVirtualForum">'.
'<c_id>'.$c_id.'</c_id>'.
'<reason>'.$reason.'</reason>'.
'</cmd>';
$response = insenz_request($data);
if($response['status']) {
cpmsg($response['data'], '', 'error');
} else {
$response = $response['data'];
if($response['response'][0]['status'][0]['VALUE'] == 1) {
cpmsg(insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0), '', 'error');
}
}
cpmsg('insenz_campaign_specified_ignored', $BASESCRIPT.'?action=insenz&operation=virtualforum&c_status=2', 'succeed');
}
} else {
shownav('adv', 'insenz', 'insenz_nav_virtualforum');
showsubmenu('nav_insenz_vf', array(
array('nav_insenz_vf_new', 'insenz&operation=virtualforum&c_status=2', $c_status == 2),
array('nav_insenz_vf_online', 'insenz&operation=virtualforum&c_status=6', $c_status == 6),
array('nav_insenz_vf_offline', 'insenz&operation=virtualforum&c_status=7', $c_status == 7)
));
if($c_status == 6) {
$onlineids = $offlineids = 0;
$query = $db->query("SELECT id, status FROM {$tablepre}campaigns WHERE type='4' AND status IN ('2','3')");
while($c = $db->fetch_array($query)) {
if($c['status'] == 2) {
$onlineids .= ','.$c['id'];
} else {
$offlineids .= ','.$c['id'];
}
}
}
showtips('insenz_tips_virtualforum');
$statuslist = array('2'=>$lang['insenz_campaign_new'], '6'=>$lang['insenz_campaign_playing'], '7'=>$lang['insenz_campaign_over']);
showtableheader($statuslist[$c_status], 'fixpadding');
showsubtitle(array('insenz_campaign_id', 'insenz_campaign_name', 'insenz_campaign_price', 'insenz_campaign_starttime', 'insenz_campaign_endtime', 'insenz_vf_name', $c_status == 6 ? 'insenz_campaign_status' : NULL, ''));
showtagheader('tbody', 'tbody1', TRUE);
showtablerow('', 'colspan="8" id="loading"', '<img src="'.IMGDIR.'/loading.gif" border="0"> '.$lang['insenz_loading']);
showtagfooter('tbody');
showtablefooter();
echo ' <script src="./include/js/bbcode.js" type="text/javascript"></script>
<script src="http://'.$insenz['url'].'/virtualforum.php?action=list&c_status='.$c_status.'&id='.$insenz['siteid'].'&t='.$timestamp.'&k='.md5($insenz['authkey'].$insenz['siteid'].$timestamp.'Discuz!').'&insenz_version='.INSENZ_VERSION.'&discuz_version='.DISCUZ_VERSION.'-'.DISCUZ_RELEASE.'&c_status='.$c_status.'&page='.$page.'&random='.random(4).'" type="text/javascript" charset="UTF-8"></script>
<script type="text/JavaScript">
if(typeof error_msg != "undefined" && error_msg) {
$("loading").innerHTML = error_msg;
alert(error_msg);
} else {
var s = "";
for(k in Camps) {
var camp = Camps[k];
s += "<tr><td align=\"left\">"+camp.c_id+"</td>";
s += "<td align=\"left\">"+camp.c_name+"</td>";
s += "<td>"+camp.c_price+"</td>";
s += "<td>"+camp.c_begindate+"</td>";
s += "<td>"+camp.c_enddate+"</td>";
s += "<td>"+camp.c_forumname+"</td>";
'.($c_status == 6 ? 's += "<td>"+(in_array(camp.c_id, ['.$onlineids.']) ? "<span class=\"diffcolor2\">'.$lang[insenz_campaign_status_online].'</span>" : (in_array(camp.c_id, ['.$offlineids.']) ? "<span class=\"lightfont\">'.$lang[insenz_campaign_status_offline].'</span>" : "<span class=\"diffcolor3\">'.$lang[insenz_campaign_status_waiting].'</span>"))+"</td>";' : '').'
s += "<td><a href=\"javascript:showdetail("+camp.c_id+")\">'.$lang['detail'].'</a></td></tr>";
s += "<tr><td colspan=\"8\" id=\"detail_"+camp.c_id+"\" style=\"display: none;\"></td></tr>";
}
$("loading").style.display = "none";
ajaxinnerhtml($("tbody1"), s);
}
function showdetail(id) {
var camp = Camps[id];
var obj = $("detail_" + id);
obj.style.display = obj.style.display == "" ? "none" : "";
obj.style.padding = "10px";
s = "<b>'.$lang['insenz_vf_note'].':</b><br>" + camp.c_forumnote;
s += "<br><b>'.$lang['insenz_vf_camp_note'].':</b><br>" + camp.c_note;
s += "<form name=\"form\" action=\"'.$BASESCRIPT.'?action=insenz&operation=virtualforum\" method=\"post\">";
s += "<input type=\"hidden\" name=\"formhash\" value=\"'.FORMHASH.'\">";
s += "<input type=\"hidden\" name=\"c_id\" value=\""+parseInt(camp.c_id)+"\">";
s += "<input type=\"hidden\" name=\"c_name\" value=\""+htmlspecialchars(camp.c_name)+"\">";
s += "<input type=\"hidden\" name=\"c_note\" value=\""+htmlspecialchars(camp.c_note)+"\">";
s += "<input type=\"hidden\" name=\"c_price\" value=\""+parseInt(camp.c_price)+"\">";
s += "<input type=\"hidden\" name=\"c_begintime\" value=\""+parseInt(camp.c_begintime)+"\">";
s += "<input type=\"hidden\" name=\"c_endtime\" value=\""+parseInt(camp.c_endtime)+"\">";
s += "<input type=\"hidden\" name=\"c_forumname\" value=\""+htmlspecialchars(camp.c_forumname)+"\">";
s += "<input type=\"hidden\" name=\"c_forumlink\" value=\""+htmlspecialchars(camp.c_forumlink)+"\">";
s += "<input type=\"hidden\" name=\"c_forumnote\" value=\""+htmlspecialchars(camp.c_forumnote)+"\">";
s += "<input type=\"hidden\" name=\"threads\" value=\""+parseInt(camp.threads)+"\">";
s += "<input type=\"hidden\" name=\"posts\" value=\""+parseInt(camp.posts)+"\">";
s += "<input type=\"hidden\" name=\"vflastpost\" value=\""+htmlspecialchars(camp.lastpost)+"\">";
s += "<input type=\"hidden\" name=\"c_autoupdate\" value=\""+parseInt(camp.c_autoupdate)+"\">";
s += "<input type=\"hidden\" name=\"icon\" value=\""+htmlspecialchars(camp.c_icon)+"\">";
s += '.($c_status == 2 ? "'<input type=\"submit\" class=\"btn\" name=\"acceptsubmit\" value=\"".$lang['insenz_campaign_pass']."\"> <input type=\"submit\" class=\"btn\" name=\"ignoresubmit\" value=\"".$lang['insenz_campaign_ignore']."\">'" : "''").';
obj.innerHTML = s;
}
</script>';
}
} else {
cpmsg('noaccess', '', 'error');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/insenz.inc.php
|
PHP
|
asf20
| 52,842
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: moderate.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
cpheader();
if($operation == 'members') {
$do = empty($do) ? 'mod' : $do;
if($do == 'mod') {
if(!submitcheck('modsubmit')) {
$query = $db->query("SELECT status, COUNT(*) AS count FROM {$tablepre}validating GROUP BY status");
while($num = $db->fetch_array($query)) {
$count[$num['status']] = $num['count'];
}
$sendemail = isset($sendemail) ? $sendemail : 1;
$checksendemail = $sendemail ? 'checked' : '';
$page = max(1, intval($page));
$start_limit = ($page - 1) * $memberperpage;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}validating WHERE status='0'");
$multipage = multi($db->result($query, 0), $memberperpage, $page, $BASESCRIPT.'?action=moderate&operation=members&sendemail=$sendemail');
$vuids = '0';
$members = '';
$query = $db->query("SELECT m.uid, m.username, m.groupid, m.email, m.regdate, m.regip, v.message, v.submittimes, v.submitdate, v.moddate, v.admin, v.remark
FROM {$tablepre}validating v, {$tablepre}members m
WHERE v.status='0' AND m.uid=v.uid ORDER BY v.submitdate DESC LIMIT $start_limit, $memberperpage");
while($member = $db->fetch_array($query)) {
if($member['groupid'] != 8) {
$vuids .= ','.$member['uid'];
continue;
}
$member['regdate'] = gmdate("$dateformat $timeformat", $member['regdate'] + $timeoffset * 3600);
$member['submitdate'] = gmdate("$dateformat $timeformat", $member['submitdate'] + $timeoffset * 3600);
$member['moddate'] = $member['moddate'] ? gmdate("$dateformat $timeformat", $member['moddate'] + $timeoffset * 3600) : $lang['none'];
$member['admin'] = $member['admin'] ? "<a href=\"space.php?username=".rawurlencode($member['admin'])."\" target=\"_blank\">$member[admin]</a>" : $lang['none'];
$members .= "<tr class=\"smalltxt\"><td><input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"invalidate\"> $lang[invalidate]<br /><input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"validate\" checked> $lang[validate]<br />\n".
"<input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"delete\"> $lang[delete]<br /><input class=\"radio\" type=\"radio\" name=\"mod[$member[uid]]\" value=\"ignore\"> $lang[ignore]</td><td><b><a href=\"space.php?uid=$member[uid]\" target=\"_blank\">$member[username]</a></b>\n".
"<br />$lang[members_edit_regdate] $member[regdate]<br />$lang[members_edit_regip] $member[regip]<br />Email: $member[email]</td>\n".
"<td align=\"center\"><textarea rows=\"4\" name=\"remark[$member[uid]]\" style=\"width: 95%; word-break: break-all\">$member[message]</textarea></td>\n".
"<td>$lang[moderate_members_submit_times]: $member[submittimes]<br />$lang[moderate_members_submit_time]: $member[submitdate]<br />$lang[moderate_members_admin]: $member[admin]<br />\n".
"$lang[moderate_members_mod_time]: $member[moddate]</td><td><textarea rows=\"4\" name=\"remark[$member[uid]]\" style=\"width: 95%; word-break: break-all\">$member[remark]</textarea></td></tr>\n";
}
if($vuids) {
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($vuids)", 'UNBUFFERED');
}
shownav('user', 'nav_modmembers');
showsubmenu('nav_moderate_users', array(
array('nav_moderate_users_mod', 'moderate&operation=members&do=mod', 1),
array('clean', 'moderate&operation=members&do=del', 0)
));
showtips('moderate_members_tips');
showformheader('moderate&operation=members&do=mod');
showtableheader('moderate_members', 'fixpadding');
showsubtitle(array('operation', 'members_edit_info', 'moderate_members_message', 'moderate_members_info', 'moderate_members_remark'));
echo $members;
showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'invalidate\')">'.lang('moderate_all_invalidate').'</a> <a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'validate\')">'.lang('moderate_all_validate').'</a> <a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'delete\')">'.lang('moderate_all_delete').'</a> <a href="#all" onclick="checkAll(\'option\', $(\'cpform\'), \'ignore\')">'.lang('moderate_all_ignore').'</a> <input class="checkbox" type="checkbox" name="sendemail" id="sendemail" value="1" '.$checksendemail.' /><label for="sendemail"> '.lang('moderate_members_email').'</label>', $multipage);
showtablefooter();
showformfooter();
} else {
$moderation = array('invalidate' => array(), 'validate' => array(), 'delete' => array(), 'ignore' => array());
$uids = 0;
if(is_array($mod)) {
foreach($mod as $uid => $act) {
$uid = intval($uid);
$uids .= ','.$uid;
$moderation[$act][] = $uid;
}
}
$members = array();
$uidarray = array(0);
$query = $db->query("SELECT v.*, m.uid, m.username, m.email, m.regdate FROM {$tablepre}validating v, {$tablepre}members m
WHERE v.uid IN ($uids) AND m.uid=v.uid AND m.groupid='8'");
while($member = $db->fetch_array($query)) {
$members[$member['uid']] = $member;
$uidarray[] = $member['uid'];
}
$uids = implode(',', $uidarray);
$numdeleted = $numinvalidated = $numvalidated = 0;
if(!empty($moderation['delete']) && is_array($moderation['delete'])) {
$deleteuids = '\''.implode('\',\'', $moderation['delete']).'\'';
$db->query("DELETE FROM {$tablepre}members WHERE uid IN ($deleteuids) AND uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($deleteuids) AND uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($deleteuids) AND uid IN ($uids)");
} else {
$moderation['delete'] = array();
}
if(!empty($moderation['validate']) && is_array($moderation['validate'])) {
$newgroupid = $db->result_first("SELECT groupid FROM {$tablepre}usergroups WHERE creditshigher<=0 AND 0<creditslower LIMIT 1");
$validateuids = '\''.implode('\',\'', $moderation['validate']).'\'';
$db->query("UPDATE {$tablepre}members SET adminid='0', groupid='$newgroupid' WHERE uid IN ($validateuids) AND uid IN ($uids)");
$numvalidated = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($validateuids) AND uid IN ($uids)");
} else {
$moderation['validate'] = array();
}
if(!empty($moderation['invalidate']) && is_array($moderation['invalidate'])) {
foreach($moderation['invalidate'] as $uid) {
$numinvalidated++;
$db->query("UPDATE {$tablepre}validating SET moddate='$timestamp', admin='$discuz_user', status='1', remark='".dhtmlspecialchars($remark[$uid])."' WHERE uid='$uid' AND uid IN ($uids)");
}
} else {
$moderation['invalidate'] = array();
}
if($sendemail) {
foreach(array('delete', 'validate', 'invalidate') as $o) {
foreach($moderation[$o] as $uid) {
if(isset($members[$uid])) {
$member = $members[$uid];
$member['regdate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $member['regdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
$member['submitdate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $member['submitdate'] + $_DCACHE['settings']['timeoffset'] * 3600);
$member['moddate'] = gmdate($_DCACHE['settings']['dateformat'].' '.$_DCACHE['settings']['timeformat'], $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$member['operation'] = $lang[$o];
$member['remark'] = $remark[$uid] ? dhtmlspecialchars($remark[$uid]) : $lang['none'];
sendmail("$member[username] <$member[email]>", 'moderate_member_subject', 'moderate_member_message');
}
}
}
}
cpmsg('moderate_members_succeed', "$BASESCRIPT?action=moderate&operation=members&page=$page", 'succeed');
}
} elseif($do == 'del') {
if(!submitcheck('prunesubmit', 1)) {
shownav('user', 'nav_modmembers');
showsubmenu('nav_moderate_users', array(
array('nav_moderate_users_mod', 'moderate&operation=members&do=mod', 0),
array('clean', 'moderate&operation=members&do=del', 1)
));
showtips('moderate_members_tips');
showformheader('moderate&operation=members&do=del');
showtableheader('moderate_members_prune');
showsetting('moderate_members_prune_submitmore', 'submitmore', '5', 'text');
showsetting('moderate_members_prune_regbefore', 'regbefore', '30', 'text');
showsetting('moderate_members_prune_modbefore', 'modbefore', '15', 'text');
showsetting('moderate_members_prune_regip', 'regip', '', 'text');
showsubmit('prunesubmit');
showtablefooter();
showformfooter();
} else {
$sql = '1';
$sql .= $submitmore ? " AND v.submittimes>'$submitmore'" : '';
$sql .= $regbefore ? " AND m.regdate<'".($timestamp - $regbefore * 86400)."'" : '';
$sql .= $modbefore ? " AND v.moddate<'".($timestamp - $modbefore * 86400)."'" : '';
$sql .= $regip ? " AND m.regip LIKE '$regip%'" : '';
$query = $db->query("SELECT v.uid FROM {$tablepre}validating v, {$tablepre}members m
WHERE $sql AND m.uid=v.uid AND m.groupid='8'");
if(!$membernum = $db->num_rows($query)) {
cpmsg('members_search_noresults', '', 'error');
} elseif(!$confirmed) {
cpmsg('members_delete_confirm', "$BASESCRIPT?action=moderate&operation=members&do=del&submitmore=".rawurlencode($submitmore)."®before=".rawurlencode($regbefore)."®ip=".rawurlencode($regip)."&prunesubmit=yes", 'form');
} else {
$uids = 0;
while($member = $db->fetch_array($query)) {
$uids .= ','.$member['uid'];
}
$db->query("DELETE FROM {$tablepre}members WHERE uid IN ($uids)");
$numdeleted = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}memberfields WHERE uid IN ($uids)");
$db->query("DELETE FROM {$tablepre}validating WHERE uid IN ($uids)");
cpmsg('members_delete_succeed', '', 'succeed');
}
}
}
} else {
require_once DISCUZ_ROOT.'./include/forum.func.php';
require_once DISCUZ_ROOT.'./include/post.func.php';
$modfid = !empty($modfid) ? intval($modfid) : 0;
$fids = 0;
$recyclebins = $forumlist = array();
if($adminid == 3) {
$query = $db->query("SELECT m.fid, f.name, f.recyclebin FROM {$tablepre}moderators m LEFT JOIN {$tablepre}forums f ON f.fid=m.fid WHERE m.uid='$discuz_uid'");
while($forum = $db->fetch_array($query)) {
$fids .= ','.$forum['fid'];
$recyclebins[$forum['fid']] = $forum['recyclebin'];
$forumlist[$forum['fid']] = strip_tags($forum['name']);
}
if(empty($forumlist)) {
cpmsg('moderate_posts_no_access_all', '', 'error');
} elseif($modfid && empty($forumlist[$modfid])) {
cpmsg('moderate_posts_no_access_this', '', 'error');
}
} else {
$query = $db->query("SELECT fid, name, recyclebin FROM {$tablepre}forums WHERE status>0 AND type<>'group'");
while($forum = $db->fetch_array($query)) {
$recyclebins[$forum['fid']] = $forum['recyclebin'];
$forumlist[$forum['fid']] = $forum['name'];
}
}
if($modfid) {
$fidadd = array('fids' => "fid='$modfid'", 'and' => ' AND ', 't' => 't.', 'p' => 'p.');
} else {
$fidadd = $fids ? array('fids' => "fid IN ($fids)", 'and' => ' AND ', 't' => 't.', 'p' => 'p.') : array();
}
if(isset($filter) && $filter == 'ignore') {
$displayorder = -3;
$filteroptions = '<option value="normal">'.$lang['moderate_none'].'</option><option value="ignore" selected>'.$lang['moderate_ignore'].'</option>';
} else {
$displayorder = -2;
$filter = 'normal';
$filteroptions = '<option value="normal" selected>'.$lang['moderate_none'].'</option><option value="ignore">'.$lang['moderate_ignore'].'</option>';
}
$forumoptions = '<option value="all"'.(empty($modfid) ? ' selected' : '').'>'.$lang['moderate_all_fields'].'</option>';
foreach($forumlist as $fid => $forumname) {
$selected = $modfid == $fid ? ' selected' : '';
$forumoptions .= '<option value="'.$fid.'" '.$selected.'>'.$forumname.'</option>'."\n";
}
require_once DISCUZ_ROOT.'./include/misc.func.php';
$modreasonoptions = '<option value="">'.$lang['none'].'</option><option value="">--------</option>'.modreasonselect();
echo <<<EOT
<style type="text/css">
.mod_validate td{ background: #FFFFFF !important; }
.mod_delete td{ background: #FFEBE7 !important; }
.mod_ignore td{ background: #EEEEEE !important; }
</style>
<script type="text/JavaScript">
function mod_setbg(tid, value) {
$('mod_' + tid + '_row1').className = 'mod_' + value;
$('mod_' + tid + '_row2').className = 'mod_' + value;
$('mod_' + tid + '_row3').className = 'mod_' + value;
}
function mod_setbg_all(value) {
checkAll('option', $('cpform'), value);
var trs = $('cpform').getElementsByTagName('TR');
for(var i in trs) {
if(trs[i].id && trs[i].id.substr(0, 4) == 'mod_') {
trs[i].className = 'mod_' + value;
}
}
}
function attachimg() {}
</script>
EOT;
}
if($operation == 'threads') {
if(!submitcheck('modsubmit')) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$tpp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $tpp;
$modcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE $fidadd[fids]$fidadd[and] displayorder='$displayorder'");
$multipage = multi($modcount, $tpp, $page, "$BASESCRIPT?action=moderate&operation=threads&filter=$filter&modfid=$modfid");
shownav('topic', $lang['moderate_threads']);
showsubmenu('nav_moderate_posts', array(
array('nav_moderate_threads', 'moderate&operation=threads', 1),
array('nav_moderate_replies', 'moderate&operation=replies', 0)
));
showformheader("moderate&operation=threads&page=$page");
showhiddenfields(array('ignore' => $ignore, 'filter' => $filter, 'modfid' => $modfid));
showtableheader("$lang[select]: <select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=threads&modfid=$modfid&filter='+this.options[this.selectedIndex].value;}\">$filteroptions</select>
<select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=threads&filter=$filter&modfid='+this.options[this.selectedIndex].value;}\">$forumoptions</select>");
$threadsortinfo = '';
$query = $db->query("SELECT f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode,
t.tid, t.fid, t.sortid, t.author, t.authorid, t.subject, t.dateline, t.attachment,
p.pid, p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff
FROM {$tablepre}threads t
LEFT JOIN {$tablepre}posts p ON p.tid=t.tid AND p.first=1
LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
WHERE $fidadd[t]$fidadd[fids]$fidadd[and] t.displayorder='$displayorder'
ORDER BY t.dateline DESC LIMIT $start_limit, $tpp");
while($thread = $db->fetch_array($query)) {
if($thread['authorid'] && $thread['author']) {
$thread['author'] = "<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>";
} elseif($thread['authorid'] && !$thread['author']) {
$thread['author'] = "<a href=\"space.php?uid=$thread[authorid]\" target=\"_blank\">$lang[anonymous]</a>";
} else {
$thread['author'] = $lang['guest'];
}
$thread['dateline'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
$thread['message'] = discuzcode($thread['message'], $thread['smileyoff'], $thread['bbcodeoff'], sprintf('%00b', $thread['htmlon']), $thread['allowsmilies'], $thread['allowbbcode'], $thread['allowimgcode'], $thread['allowhtml']);
$thread['modthreadkey'] = modthreadkey($thread['tid']);
if($thread['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$queryattach = $db->query("SELECT aid, filename, filetype, filesize, attachment, isimage, remote FROM {$tablepre}attachments WHERE tid='$thread[tid]'");
while($attach = $db->fetch_array($queryattach)) {
$attachurl = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
$attach['url'] = $attach['isimage']
? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"$attachurl/$attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">"
: "<a href=\"$attachurl/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
$thread['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($thread['filename'])."\t".$attach['filetype']).$attach['url'];
}
}
$optiondata = $optionlist = array();
if($thread['sortid']) {
if(@include DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$thread['sortid'].'.php') {
$query = $db->query("SELECT optionid, value FROM {$tablepre}typeoptionvars WHERE tid='$thread[tid]'");
while($option = $db->fetch_array($query)) {
$optiondata[$option['optionid']] = $option['value'];
}
foreach($_DTYPE as $optionid => $option) {
$optionlist[$option['identifier']]['title'] = $_DTYPE[$optionid]['title'];
if($_DTYPE[$optionid]['type'] == 'checkbox') {
$optionlist[$option['identifier']]['value'] = '';
foreach(explode("\t", $optiondata[$optionid]) as $choiceid) {
$optionlist[$option['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].' ';
}
} elseif(in_array($_DTYPE[$optionid]['type'], array('radio', 'select'))) {
$optionlist[$option['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$optiondata[$optionid]];
} elseif($_DTYPE[$optionid]['type'] == 'image') {
$maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : '';
$maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : '';
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$optiondata[$optionid]\" $maxwidth $maxheight border=\"0\"></a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'url') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\">$optiondata[$optionid]</a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'textarea') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? nl2br($optiondata[$optionid]) : '';
} else {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid];
}
}
}
foreach($optionlist as $option) {
$threadsortinfo .= $option['title'].' '.$option['value']."<br />";
}
}
showtablerow("id=\"mod_$thread[tid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_1\" value=\"validate\" checked=\"checked\" onclick=\"mod_setbg($thread[tid], 'validate');\"><label for=\"mod_$thread[tid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_2\" value=\"delete\" onclick=\"mod_setbg($thread[tid], 'delete');\"><label for=\"mod_$thread[tid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$thread[tid]]\" id=\"mod_$thread[tid]_3\" value=\"ignore\" onclick=\"mod_setbg($thread[tid], 'ignore');\"><label for=\"mod_$thread[tid]_3\">$lang[ignore]</label></li></ul>",
"<h3><a href=\"forumdisplay.php?fid=$thread[fid]\" target=\"_blank\">$thread[forumname]</a> » <a href=\"viewthread.php?tid=$thread[tid]&modthreadkey=$thread[modthreadkey]\" target=\"_blank\">$thread[subject]</a></h3><p><span class=\"bold\">$lang[author]:</span> $thread[author] ($thread[useip]) <span class=\"bold\">$lang[time]:</span> $thread[dateline]</p>"
));
showtablerow("id=\"mod_$thread[tid]_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">'.$thread['message'].'<br /><br />'.$threadsortinfo.'</div>');
showtablerow("id=\"mod_$thread[tid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "<a href=\"post.php?action=edit&fid=$thread[fid]&tid=$thread[tid]&pid=$thread[pid]&page=1&modthreadkey=$thread[modthreadkey]\" target=\"_blank\">".$lang['moderate_edit_thread']."</a> | ".$lang['moderate_reasonpm']." <input type=\"text\" class=\"txt\" name=\"pm_$thread[tid]\" id=\"pm_$thread[tid]\" style=\"margin: 0px;\"> <select style=\"margin: 0px;\" onchange=\"$('pm_$thread[tid]').value=this.value\">$modreasonoptions</select>");
}
showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="mod_setbg_all(\'validate\')">'.lang('moderate_all_validate').'</a> <a href="#all" onclick="mod_setbg_all(\'delete\')">'.lang('moderate_all_delete').'</a> <a href="#all" onclick="mod_setbg_all(\'ignore\')">'.lang('moderate_all_ignore').'</a>', $multipage);
showtablefooter();
showformfooter();
} else {
$validates = $ignores = $recycles = $deletes = 0;
$validatedthreads = $pmlist = array();
$moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
if(is_array($mod)) {
foreach($mod as $tid => $act) {
$moderation[$act][] = intval($tid);
}
}
if($moderation['ignore']) {
$ignoretids = '\''.implode('\',\'', $moderation['ignore']).'\'';
$db->query("UPDATE {$tablepre}threads SET displayorder='-3' WHERE tid IN ($ignoretids) AND displayorder='-2'");
$ignores = $db->affected_rows();
}
if($moderation['delete']) {
$deletetids = '0';
$recyclebintids = '0';
$query = $db->query("SELECT tid, fid, authorid, subject FROM {$tablepre}threads WHERE tid IN ('".implode('\',\'', $moderation['delete'])."') AND displayorder='$displayorder' $fidadd[and]$fidadd[fids]");
while($thread = $db->fetch_array($query)) {
if($recyclebins[$thread['fid']]) {
$recyclebintids .= ','.$thread['tid'];
} else {
$deletetids .= ','.$thread['tid'];
}
$pm = 'pm_'.$thread['tid'];
if(isset($$pm) && $$pm <> '' && $thread['authorid']) {
$pmlist[] = array(
'action' => 'modthreads_delete_',
'authorid' => $thread['authorid'],
'thread' => $thread['subject'],
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($recyclebintids) {
$db->query("UPDATE {$tablepre}threads SET displayorder='-1', moderated='1' WHERE tid IN ($recyclebintids)");
$recycles = $db->affected_rows();
updatemodworks('MOD', $recycles);
$db->query("UPDATE {$tablepre}posts SET invisible='-1' WHERE tid IN ($recyclebintids)");
updatemodlog($recyclebintids, 'DEL');
}
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($deletetids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($deletetids)", 'UNBUFFERED');
$deletes = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}posts WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}polloptions WHERE tid IN ($deletetids)");
$db->query("DELETE FROM {$tablepre}polls WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}trades WHERE tid IN ($deletetids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($deletetids)", 'UNBUFFERED');
}
if($moderation['validate']) {
$forums = array();
$validatetids = '\''.implode('\',\'', $moderation['validate']).'\'';
$tids = $comma = $comma2 = '';
$authoridarray = $moderatedthread = array();
$query = $db->query("SELECT t.fid, t.tid, t.authorid, t.subject, t.author, t.dateline, ff.postcredits FROM {$tablepre}threads t
LEFT JOIN {$tablepre}forumfields ff USING(fid)
WHERE t.tid IN ($validatetids) AND t.displayorder='$displayorder' $fidadd[and]$fidadd[t]$fidadd[fids]");
while($thread = $db->fetch_array($query)) {
$tids .= $comma.$thread['tid'];
$comma = ',';
if($thread['postcredits']) {
updatepostcredits('+', $thread['authorid'], unserialize($thread['postcredits']));
} else {
$authoridarray[] = $thread['authorid'];
}
$forums[] = $thread['fid'];
$validatedthreads[] = $thread;
$pm = 'pm_'.$thread['tid'];
if(isset($$pm) && $$pm <> '' && $thread['authorid']) {
$pmlist[] = array(
'action' => 'modthreads_validate_',
'authorid' => $thread['authorid'],
'tid' => $thread['tid'],
'thread' => $thread['subject'],
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($tids) {
if($authoridarray) {
updatepostcredits('+', $authoridarray, $creditspolicy['post']);
}
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE tid IN ($tids)");
$db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ($tids)");
$validates = $db->affected_rows();
foreach(array_unique($forums) as $fid) {
updateforumcount($fid);
}
updatemodworks('MOD', $validates);
updatemodlog($tids, 'MOD');
}
}
if($pmlist) {
foreach($pmlist as $pm) {
$reason = $pm['reason'];
$threadsubject = $pm['thread'];
$tid = intval($pm['tid']);
sendpm($pm['authorid'], $pm['action'].'subject', $pm['action'].'message', 0);
}
}
if($validates) {
eval("\$lang[moderate_validate_list] = \"".$lang['moderate_validate_list']."\";");
showsubmenu('nav_moderate_posts', array(
array('nav_moderate_threads', 'moderate&operation=threads', 0),
array('nav_moderate_replies', 'moderate&operation=replies', 0)
));
echo '<form id="topicadmin" name="topicadmin" method="post" action="topicadmin.php" target="_blank">';
showhiddenfields(array('action'=> '', 'fid'=> '', 'tid'=> ''));
showtableheader();
showtablerow('', 'class="lineheight" colspan="5"', lang('moderate_validate_list'));
showsubtitle(array('Tid', 'subject', 'author', 'dateline', 'admin'));
if(!empty($validatedthreads)) {
foreach($validatedthreads as $thread) {
showtablerow('', '', array(
$thread['tid'],
'<a href="viewthread.php?tid='.$thread['tid'].'&modthreadkey='.modthreadkey($thread['tid']).'" target="_blank">'.$thread['subject'].'</a>',
'<a href="space.php?uid='.$thread['authorid'].'" target="_blank">'.$thread['author'].'</a>',
gmdate("$dateformat $timeformat", $thread['dateline'] + 3600 * $timeoffset),
'<select name="action2" id="action2" onchange="if(this.options[this.selectedIndex].value != \'\') {$(\'topicadmin\').action.value= this.options[this.selectedIndex].value; $(\'topicadmin\').tid.value='.$thread['tid'].'; $(\'topicadmin\').fid.value='.$thread['fid'].'; $(\'topicadmin\').submit();}">
<option value="" selected>'.$lang['select'].'</option>
<option value="delete">'.$lang['moderate_delthread'].'</option>
<option value="close">'.$lang['moderate_close'].'</option>
<option value="move">'.$lang['moderate_move'].'</option>
<option value="copy">'.$lang['moderate_copy'].'</option>
<option value="highlight">'.$lang['moderate_highlight'].'</option>
<option value="digest">'.$lang['moderate_digest'].'</option>
<option value="stick">'.$lang['moderate_stick'].'</option>
<option value="merge">'.$lang['moderate_merge'].'</option>
<option value="bump">'.$lang['moderate_bump'].'</option>
<option value="repair">'.$lang['moderate_repair'].'</option>
</select>'
));
}
}
showtablefooter();
showformfooter();
} else {
cpmsg('moderate_threads_succeed', $BASESCRIPT.'?action=moderate&operation=threads', 'succeed');
}
}
} elseif($operation == 'replies') {
if(!submitcheck('modsubmit')) {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$ppp = 10;
$page = max(1, intval($page));
$start_limit = ($page - 1) * $ppp;
$modcount = $db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE invisible='$displayorder' AND first='0' $fidadd[and]$fidadd[fids]");
$multipage = multi($modcount, $ppp, $page, "$BASESCRIPT?action=moderate&operation=replies&filter=$filter&modfid=$modfid");
shownav('topic', $lang['moderate_replies']);
showsubmenu('nav_moderate_posts', array(
array('nav_moderate_threads', 'moderate&operation=threads', 0),
array('nav_moderate_replies', 'moderate&operation=replies', 1)
));
showformheader("moderate&operation=replies&page=$page");
showhiddenfields(array('filter' => $filter, 'modfid' => $modfid));
showtableheader("$lang[select]: <select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=replies&modfid=$modfid&filter='+this.options[this.selectedIndex].value+'&sid=5ScwCd';}\">$filteroptions</select> <select style=\"margin: 0px;\" onchange=\"if(this.options[this.selectedIndex].value != '') {window.location='$BASESCRIPT?action=moderate&operation=replies&filter=$filter&modfid='+this.options[this.selectedIndex].value+'&sid=5ScwCd';}\">$forumoptions</select>");
$query = $db->query("SELECT f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode,
p.pid, p.fid, p.tid, p.author, p.authorid, p.subject, p.dateline, p.message, p.useip, p.attachment,
p.htmlon, p.smileyoff, p.bbcodeoff, t.subject AS tsubject
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
LEFT JOIN {$tablepre}forums f ON f.fid=p.fid
WHERE p.invisible='$displayorder' AND p.first='0' $fidadd[and]$fidadd[p]$fidadd[fids]
ORDER BY p.dateline DESC LIMIT $start_limit, $ppp");
while($post = $db->fetch_array($query)) {
$post['dateline'] = gmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['subject'] = $post['subject'] ? '<b>'.$post['subject'].'</b>' : '<i>'.$lang['nosubject'].'</i>';
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $post['allowsmilies'], $post['allowbbcode'], $post['allowimgcode'], $post['allowhtml']);
$post['modthreadkey'] = modthreadkey($post['tid']);
if($post['attachment']) {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
$queryattach = $db->query("SELECT aid, filename, filetype, filesize, attachment, isimage, remote FROM {$tablepre}attachments WHERE pid='$post[pid]'");
while($attach = $db->fetch_array($queryattach)) {
$attachurl = $attach['remote'] ? $ftp['attachurl'] : $attachurl;
$attach['url'] = $attach['isimage']
? " $attach[filename] (".sizecount($attach['filesize']).")<br /><br /><img src=\"$attachurl/$attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">"
: "<a href=\"$attachurl/$attach[attachment]\" target=\"_blank\">$attach[filename]</a> (".sizecount($attach['filesize']).")";
$post['message'] .= "<br /><br />$lang[attachment]: ".attachtype(fileext($attach['filename'])."\t".$attach['filetype']).$attach['url'];
}
}
showtablerow("id=\"mod_$post[pid]_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array(
"<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"mod[$post[pid]]\" id=\"mod_$post[pid]_1\" value=\"validate\" checked=\"checked\" onclick=\"mod_setbg($post[pid], 'validate');\"><label for=\"mod_$post[pid]_1\">$lang[validate]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$post[pid]]\" id=\"mod_$post[pid]_2\" value=\"delete\" onclick=\"mod_setbg($post[pid], 'delete');\"><label for=\"mod_$post[pid]_2\">$lang[delete]</label></li><li><input class=\"radio\" type=\"radio\" name=\"mod[$post[pid]]\" id=\"mod_$post[pid]_3\" value=\"ignore\" onclick=\"mod_setbg($post[pid], 'ignore');\"><label for=\"mod_$post[pid]_3\">$lang[ignore]</label></li></ul>",
"<h3><a href=\"forumdisplay.php?fid=$post[fid]\" target=\"_blank\">$post[forumname]</a> » <a href=\"viewthread.php?tid=$post[tid]&modthreadkey=$post[modthreadkey]\" target=\"_blank\">$post[tsubject]</a> » <b>$post[subject]</b></h3><p><span class=\"bold\">$lang[author]:</span> $post[author] ($post[useip]) <span class=\"bold\">$lang[time]:</span> $post[dateline]</p>"
));
showtablerow("id=\"mod_$post[pid]_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:100px; word-break: break-all;">'.$post[message].'</div>');
showtablerow("id=\"mod_$post[pid]_row3\"", 'class="threadopt threadtitle" colspan="2"', "<a href=\"post.php?action=edit&fid=$post[fid]&tid=$post[tid]&pid=$post[pid]&page=1&modthreadkey=$post[modthreadkey]\" target=\"_blank\">".$lang['moderate_edit_post']."</a> | ".$lang['moderate_reasonpm']." <input type=\"text\" class=\"txt\" name=\"pm_$post[pid]\" id=\"pm_$post[pid]\" style=\"margin: 0px;\"> <select style=\"margin: 0px;\" onchange=\"$('pm_$post[pid]').value=this.value\">$modreasonoptions</select>");
}
showsubmit('modsubmit', 'submit', '', '<a href="#all" onclick="mod_setbg_all(\'validate\')">'.lang('moderate_all_validate').'</a> <a href="#all" onclick="mod_setbg_all(\'delete\')">'.lang('moderate_all_delete').'</a> <a href="#all" onclick="mod_setbg_all(\'ignore\')">'.lang('moderate_all_ignore').'</a>', $multipage);
showtablefooter();
showformfooter();
} else {
$moderation = array('validate' => array(), 'delete' => array(), 'ignore' => array());
$pmlist = array();
$validates = $ignores = $deletes = 0;
if(is_array($mod)) {
foreach($mod as $pid => $act) {
$moderation[$act][] = intval($pid);
}
}
if($ignorepids = implodeids($moderation['ignore'])) {
$db->query("UPDATE {$tablepre}posts SET invisible='-3' WHERE pid IN ($ignorepids) AND invisible='-2' AND first='0' $fidadd[and]$fidadd[fids]");
$ignores = $db->affected_rows();
}
if($deletepids = implodeids($moderation['delete'])) {
$query = $db->query("SELECT pid, authorid, tid, message FROM {$tablepre}posts WHERE pid IN ($deletepids) AND invisible='$displayorder' AND first='0' $fidadd[and]$fidadd[fids]", 'UNBUFFERED');
$pids = '0';
while($post = $db->fetch_array($query)) {
$pids .= ','.$post['pid'];
$pm = 'pm_'.$post['pid'];
if(isset($$pm) && $$pm <> '' && $post['authorid']) {
$pmlist[] = array(
'action' => 'modreplies_delete_',
'authorid' => $post['authorid'],
'tid' => $post['tid'],
'post' => dhtmlspecialchars(cutstr($post['message'], 30)),
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($pids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE pid IN ($deletepids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
$db->query("DELETE FROM {$tablepre}attachments WHERE pid IN ($pids)", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}posts WHERE pid IN ($pids)", 'UNBUFFERED');
$deletes = $db->affected_rows();
$db->query("DELETE FROM {$tablepre}trades WHERE pid IN ($pids)", 'UNBUFFERED');
}
updatemodworks('DLP', count($moderation['delete']));
}
if($validatepids = implodeids($moderation['validate'])) {
$forums = $threads = $lastpost = $attachments = $pidarray = $authoridarray = array();
$query = $db->query("SELECT t.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, ff.replycredits
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}forumfields ff ON ff.fid=p.fid
LEFT JOIN {$tablepre}threads t ON t.tid=p.tid
WHERE p.pid IN ($validatepids) AND p.invisible='$displayorder' AND first='0' $fidadd[and]$fidadd[p]$fidadd[fids]");
while($post = $db->fetch_array($query)) {
$pidarray[] = $post['pid'];
if($post['replycredits']) {
updatepostcredits('+', $post['authorid'], unserialize($post['replycredits']));
} else {
$authoridarray[] = $post['authorid'];
}
$forums[] = $post['fid'];
$threads[$post['tid']]['posts']++;
$threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ?
", lastpost='$post[dateline]', lastposter='".($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author]))."'" : '';
$threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : '';
$pm = 'pm_'.$post['pid'];
if(isset($$pm) && $$pm <> '' && $post['authorid']) {
$pmlist[] = array(
'action' => 'modreplies_validate_',
'authorid' => $post['authorid'],
'tid' => $post['tid'],
'post' => dhtmlspecialchars(cutstr($post['message'], 30)),
'reason' => dhtmlspecialchars($$pm)
);
}
}
if($authoridarray) {
updatepostcredits('+', $authoridarray, $creditspolicy['reply']);
}
foreach($threads as $tid => $thread) {
$db->query("UPDATE {$tablepre}threads SET replies=replies+$thread[posts] $thread[lastpostadd] $thread[attachadd] WHERE tid='$tid'", 'UNBUFFERED');
}
foreach(array_unique($forums) as $fid) {
updateforumcount($fid);
}
if(!empty($pidarray)) {
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE pid IN (0,".implode(',', $pidarray).")");
$validates = $db->affected_rows();
updatemodworks('MOD', $validates);
} else {
updatemodworks('MOD', 1);
}
}
if($pmlist) {
foreach($pmlist as $pm) {
$reason = $pm['reason'];
$post = $pm['post'];
$tid = intval($pm['tid']);
sendpm($pm['authorid'], $pm['action'].'subject', $pm['action'].'message', 0);
}
}
cpmsg('moderate_replies_succeed', "$BASESCRIPT?action=moderate&operation=replies&page=$page&filter=$filter&modfid=$modfid", 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/moderate.inc.php
|
PHP
|
asf20
| 39,120
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: plugins.inc.php 17025 2008-12-03 07:37:56Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!empty($identifier) && !empty($mod)) {
$operation = 'config';
}
if(!$operation) {
if(!submitcheck('submit')) {
shownav('extended', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('config', 'plugins&operation=config', 0),
array('admin', 'plugins', 1),
array('import', 'plugins&operation=import', 0)
));
showtips('plugins_config_tips');
showformheader('plugins');
showtableheader();
showsubtitle(array('', 'available', 'plugins_name', 'plugins_identifier', 'plugins_directory', ''));
$query = $db->query("SELECT * FROM {$tablepre}plugins");
while($plugin = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td25"', 'class="bold"', 'width="20%"', 'width="30%"', 'width="10%"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$plugin[pluginid]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$plugin[pluginid]]\" value=\"1\" ".(!$plugin['name'] || !$plugin['identifier'] ? 'disabled' : ($plugin['available'] ? 'checked' : '')).">",
$plugin['name'],
$plugin['identifier'],
$plugin['directory'],
"<a href=\"$BASESCRIPT?action=plugins&operation=export&pluginid=$plugin[pluginid]\" class=\"act\">$lang[export]</a> <a href=\"$BASESCRIPT?action=plugins&operation=edit&pluginid=$plugin[pluginid]\" target=\"_blank\" class=\"act\">$lang[detail]</a>"
));
}
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1,''],
[1,''],
[1,'<input type="text" class="txt" name="newname[]" size="12">'],
[1,'<input type="text" class="txt" name="newidentifier[]" size="8">'],
[1,''],
[1,'']
]
];
</script>
<?
echo '<tr><td></td><td colspan="5"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['plugins_add'].'</a></div></td></tr>';
showsubmit('submit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
$db->query("UPDATE {$tablepre}plugins SET available='0'");
if(is_array($availablenew)) {
foreach($availablenew as $id => $available) {
$db->query("UPDATE {$tablepre}plugins SET available='$available' WHERE pluginid='$id'");
}
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}plugins WHERE pluginid IN ($ids)");
$db->query("DELETE FROM {$tablepre}pluginvars WHERE pluginid IN ($ids)");
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
$newname1 = trim($value);
$newidentifier1 = trim($newidentifier[$key]);
if($newname1 || $newidentifier1) {
if(!$newname1) {
cpmsg('plugins_edit_name_invalid', '', 'error');
}
$query = $db->query("SELECT pluginid FROM {$tablepre}plugins WHERE identifier='$newidentifier1' LIMIT 1");
if($db->num_rows($query) || !$newidentifier1 || !ispluginkey($newidentifier1)) {
cpmsg('plugins_edit_identifier_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}plugins (name, identifier, available) VALUES ('".dhtmlspecialchars(trim($newname1))."', '$newidentifier1', '0')");
}
}
}
updatecache('plugins');
updatecache('settings');
cpmsg('plugins_edit_succeed', $BASESCRIPT.'?action=plugins', 'succeed');
}
} elseif($operation == 'export' && $pluginid) {
$plugin = $db->fetch_first("SELECT * FROM {$tablepre}plugins WHERE pluginid='$pluginid'");
if(!$plugin) {
cpheader();
cpmsg('undefined_action', '', 'error');
}
unset($plugin['pluginid']);
$pluginarray = array();
$pluginarray['plugin'] = $plugin;
$pluginarray['version'] = strip_tags($version);
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
$query = $db->query("SELECT * FROM {$tablepre}pluginhooks WHERE pluginid='$pluginid'");
while($hook = $db->fetch_array($query)) {
unset($hook['pluginhookid'], $hook['pluginid']);
$pluginarray['hooks'][] = $hook;
}
$query = $db->query("SELECT * FROM {$tablepre}pluginvars WHERE pluginid='$pluginid'");
while($var = $db->fetch_array($query)) {
unset($var['pluginvarid'], $var['pluginid']);
$pluginarray['vars'][] = $var;
}
$plugin_export = "# Discuz! Plugin Dump\n".
"# Version: Discuz! $version\n".
"# Time: $time \n".
"# From: $bbname ($boardurl) \n".
"#\n".
"# Discuz! Community: http://www.Discuz.net\n".
"# Please visit our website for latest news about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
wordwrap(base64_encode(serialize($pluginarray)), 60, "\n", 1);
ob_end_clean();
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
dheader('Cache-Control: no-cache, must-revalidate');
dheader('Pragma: no-cache');
dheader('Content-Encoding: none');
dheader('Content-Length: '.strlen($plugin_export));
dheader('Content-Disposition: attachment; filename=discuz_plugin_'.$plugin['identifier'].'.txt');
dheader('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
echo $plugin_export;
dexit();
} elseif($operation == 'import') {
if(!submitcheck('importsubmit')) {
shownav('extended', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('config', 'plugins&operation=config', 0),
array('admin', 'plugins', 0),
array('import', 'plugins&operation=import', 1)
));
showformheader('plugins&operation=import', 'enctype');
showtableheader('plugins_import', 'fixpadding');
showimportdata();
showtablerow('', '', '<input type="checkbox" name="ignoreversion" value="1" class="checkbox" /> '.lang('plugins_import_ignore_version'));
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
$pluginarray = getimportdata();
if(empty($ignoreversion) && strip_tags($pluginarray['version']) != strip_tags($version)) {
cpmsg('plugins_import_version_invalid', '', 'error');
}
$query = $db->query("SELECT pluginid FROM {$tablepre}plugins WHERE identifier='{$pluginarray[plugin][identifier]}' LIMIT 1");
if($db->num_rows($query)) {
cpmsg('plugins_import_identifier_duplicated', '', 'error');
}
$sql1 = $sql2 = $comma = '';
foreach($pluginarray['plugin'] as $key => $val) {
if($key == 'directory') {
//compatible for old versions
$val .= (!empty($val) && substr($val, -1) != '/') ? '/' : '';
}
$sql1 .= $comma.$key;
$sql2 .= $comma.'\''.$val.'\'';
$comma = ',';
}
$db->query("INSERT INTO {$tablepre}plugins ($sql1) VALUES ($sql2)");
$pluginid = $db->insert_id();
foreach(array('hooks', 'vars') as $pluginconfig) {
if(is_array($pluginarray[$pluginconfig])) {
foreach($pluginarray[$pluginconfig] as $config) {
$sql1 = 'pluginid';
$sql2 = '\''.$pluginid.'\'';
foreach($config as $key => $val) {
$sql1 .= ','.$key;
$sql2 .= ',\''.$val.'\'';
}
$db->query("INSERT INTO {$tablepre}plugin$pluginconfig ($sql1) VALUES ($sql2)");
}
}
}
updatecache('plugins');
updatecache('settings');
cpmsg('plugins_import_succeed', $BASESCRIPT.'?action=plugins', 'succeed');
}
} elseif($operation == 'config') {
if(!$pluginid && !$identifier) {
shownav('extended', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('config', 'plugins&operation=config', 1),
array('admin', 'plugins', 0),
array('import', 'plugins&operation=import', 0)
));
$plugins = '';
$query = $db->query("SELECT p.*, pv.pluginvarid FROM {$tablepre}plugins p
LEFT JOIN {$tablepre}pluginvars pv USING(pluginid)
GROUP BY p.pluginid
ORDER BY p.available DESC, p.pluginid");
if(!$db->num_rows($query)) {
dheader("location: $BASESCRIPT?action=plugins");
}
while($plugin = $db->fetch_array($query)) {
if(!$plugin['adminid'] || $plugin['adminid'] >= $adminid) {
$plugin['edit'] = $plugin['pluginvarid'] ? "<a href=\"$BASESCRIPT?action=plugins&operation=config&pluginid=$plugin[pluginid]\" class=\"act\">$lang[plugins_config]</a> " : '';
if(is_array($plugin['modules'] = unserialize($plugin['modules']))) {
foreach($plugin['modules'] as $module) {
if($module['type'] == 3 && (!$module['adminid'] || $module['adminid'] >= $adminid)) {
$plugin['edit'] .= "<a href=\"$BASESCRIPT?action=plugins&operation=config&identifier=$plugin[identifier]&mod=$module[name]\" class=\"act\">$module[menu]</a> ";
}
}
}
} else {
$plugin['edit'] = lang('detail');
}
echo '<div class="colorbox"><h4>'.$plugin['name'].(!$plugin['available'] ? ' ('.$lang['plugins_unavailable'].')' : '').'</h4>'.nl2br($plugin['description']).'<br><div style="width:95%" style="clear:both"><div style="float:right">'.$plugin['copyright'].'</div>'.$plugin['edit'].'</div></div><br /><br />';
}
} else {
$plugin = $db->fetch_first("SELECT * FROM {$tablepre}plugins WHERE ".($identifier ? "identifier='$identifier'" : "pluginid='$pluginid'"));
if(!$plugin) {
cpmsg('undefined_action', '', 'error');
} else {
$pluginid = $plugin['pluginid'];
}
$pluginvars = array();
$query = $db->query("SELECT * FROM {$tablepre}pluginvars WHERE pluginid='$pluginid' ORDER BY displayorder");
while($var = $db->fetch_array($query)) {
$pluginvars[$var['variable']] = $var;
}
if(empty($mod)) {
if(($plugin['adminid'] && $adminid > $plugin['adminid']) || !$pluginvars) {
cpmsg('noaccess', '', 'error');
}
if(!submitcheck('editsubmit')) {
shownav('extended', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('config', 'plugins&operation=config', 0),
array('admin', 'plugins', 0),
array('import', 'plugins&operation=import', 0)
));
showformheader("plugins&operation=config&pluginid=$pluginid");
showtableheader();
showtitle($lang['plugins_config'].' - '.$plugin['name']);
$extra = array();
foreach($pluginvars as $var) {
$var['variable'] = 'varsnew['.$var['variable'].']';
if($var['type'] == 'number') {
$var['type'] = 'text';
} elseif($var['type'] == 'select') {
$var['type'] = "<select name=\"$var[variable]\">\n";
foreach(explode("\n", $var['extra']) as $key => $option) {
$option = trim($option);
if(strpos($option, '=') === FALSE) {
$key = $option;
} else {
$item = explode('=', $option);
$key = trim($item[0]);
$option = trim($item[1]);
}
$var['type'] .= "<option value=\"".dhtmlspecialchars($key)."\" ".($var['value'] == $key ? 'selected' : '').">$option</option>\n";
}
$var['type'] .= "</select>\n";
$var['variable'] = $var['value'] = '';
} elseif($var['type'] == 'date') {
$var['type'] = 'calendar';
$extra['date'] = '<script type="text/javascript" src="include/js/calendar.js"></script>';
} elseif($var['type'] == 'datetime') {
$var['type'] = 'calendar';
$var['extra'] = 1;
$extra['date'] = '<script type="text/javascript" src="include/js/calendar.js"></script>';
} elseif($var['type'] == 'forum') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$var['type'] = '<select name="'.$var['variable'].'">'.forumselect(FALSE, 0, $var['value']).'</select>';
$var['variable'] = $var['value'] = '';
} elseif($var['type'] == 'forums') {
$var['description'] = $lang['plugins_edit_vars_multiselect_comment'].'<br />'.$var['comment'];
$var['value'] = unserialize($var['value']);
$var['value'] = is_array($var['value']) ? $var['value'] : array();
require_once DISCUZ_ROOT.'./include/forum.func.php';
$var['type'] = '<select name="'.$var['variable'].'[]" size="10" multiple="multiple">'.forumselect().'</select>';
foreach($var['value'] as $v) {
$var['type'] = str_replace('<option value="'.$v.'">', '<option value="'.$v.'" selected>', $var['type']);
}
$var['variable'] = $var['value'] = '';
} elseif(substr($var['type'], 0, 5) == 'group') {
if($var['type'] == 'groups') {
$var['description'] = $lang['plugins_edit_vars_multiselect_comment'].'<br />'.$var['comment'];
$var['value'] = unserialize($var['value']);
$var['type'] = '<select name="'.$var['variable'].'[]" size="10" multiple="multiple">';
} else {
$var['type'] = '<select name="'.$var['variable'].'">';
}
$var['value'] = is_array($var['value']) ? $var['value'] : array($var['value']);
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups ORDER BY groupid");
while($group = $db->fetch_array($query)) {
$var['type'] .= '<option value="'.$group['groupid'].'"'.(in_array($group['groupid'], $var['value']) ? ' selected' : '').'>'.$group['grouptitle'].'</option>';
}
$var['type'] .= '</select>';
$var['variable'] = $var['value'] = '';
} elseif($var['type'] == 'extcredit') {
$var['type'] = '<select name="'.$var['variable'].'">';
foreach($extcredits as $id => $credit) {
$var['type'] .= '<option value="'.$id.'"'.($var['value'] == $id ? ' selected' : '').'>'.$credit['title'].'</option>';
}
$var['type'] .= '</select>';
$var['variable'] = $var['value'] = '';
}
showsetting(isset($lang[$var['title']]) ? $lang[$var['title']] : $var['title'], $var['variable'], $var['value'], $var['type'], '', 0, isset($lang[$var['description']]) ? $lang[$var['description']] : $var['description'], $var['extra']);
}
showsubmit('editsubmit');
showtablefooter();
showformfooter();
echo implode('', $extra);
} else {
if(is_array($varsnew)) {
foreach($varsnew as $variable => $value) {
if(isset($pluginvars[$variable])) {
if($pluginvars[$variable]['type'] == 'number') {
$value = (float)$value;
} elseif(in_array($pluginvars[$variable]['type'], array('forums', 'groups'))) {
$value = addslashes(serialize($value));
}
$db->query("UPDATE {$tablepre}pluginvars SET value='$value' WHERE pluginid='$pluginid' AND variable='$variable'");
}
}
}
updatecache('plugins');
cpmsg('plugins_settings_succeed', $BASESCRIPT.'?action=plugins&operation=config', 'succeed');
}
} else {
$modfile = '';
if(is_array($plugin['modules'] = unserialize($plugin['modules']))) {
foreach($plugin['modules'] as $module) {
if($module['type'] == 3 && $module['name'] == $mod && (!$module['adminid'] || $module['adminid'] >= $adminid)) {
$plugin['directory'] .= (!empty($plugin['directory']) && substr($plugin['directory'], -1) != '/') ? '/' : '';
$modfile = './plugins/'.$plugin['directory'].$module['name'].'.inc.php';
break;
}
}
}
if($modfile) {
if(!@include DISCUZ_ROOT.$modfile) {
cpmsg('plugins_settings_module_nonexistence', '', 'error');
} else {
dexit();
}
} else {
cpmsg('undefined_action', '', 'error');
}
}
}
} elseif($operation == 'edit') {
if(empty($pluginid) ) {
$pluginlist = '<select name="pluginid">';
$query = $db->query("SELECT pluginid, name FROM {$tablepre}plugins");
while($plugin = $db->fetch_array($query)) {
$pluginlist .= '<option value="'.$plugin['pluginid'].'">'.$plugin['name'].'</option>';
}
$pluginlist .= '</select>';
cpmsg('plugins_nonexistence', $BASESCRIPT.'?action=plugins&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $pluginlist);
} else {
$condition = !empty($uid) ? "uid='$uid'" : "username='$username'";
}
$plugin = $db->fetch_first("SELECT * FROM {$tablepre}plugins WHERE pluginid='$pluginid'");
if(!$plugin) {
cpmsg('undefined_action', '', 'error');
}
$plugin['modules'] = unserialize($plugin['modules']);
if(!submitcheck('editsubmit')) {
$adminidselect = array($plugin['adminid'] => 'selected');
shownav('extended', 'nav_plugins');
$anchor = in_array($anchor, array('config', 'modules', 'hooks', 'vars')) ? $anchor : 'config';
showsubmenuanchors($lang['plugins_edit'].' - '.$plugin['name'], array(
array('config', 'config', $anchor == 'config'),
array('plugins_config_module', 'modules', $anchor == 'modules'),
array('plugins_config_hooks', 'hooks', $anchor == 'hooks'),
array('plugins_config_vars', 'vars', $anchor == 'vars'),
));
showtips('plugins_edit_tips');
showtagheader('div', 'config', $anchor == 'config');
showformheader("plugins&operation=edit&type=common&pluginid=$pluginid", '', 'configform');
showtableheader();
showsetting('plugins_edit_name', 'namenew', $plugin['name'], 'text');
if(!$plugin['copyright']) {
showsetting('plugins_edit_copyright', 'copyrightnew', $plugin['copyright'], 'text');
}
showsetting('plugins_edit_identifier', 'identifiernew', $plugin['identifier'], 'text');
showsetting('plugins_edit_adminid', '', '', '<select name="adminidnew"><option value="1" '.$adminidselect[1].'>'.$lang['usergroups_system_1'].'</option><option value="2" '.$adminidselect[2].'>'.$lang['usergroups_system_2'].'</option><option value="3" '.$adminidselect[3].'>'.$lang['usergroups_system_3'].'</option></select>');
showsetting('plugins_edit_directory', 'directorynew', $plugin['directory'], 'text');
showsetting('plugins_edit_datatables', 'datatablesnew', $plugin['datatables'], 'text');
showsetting('plugins_edit_description', 'descriptionnew', $plugin['description'], 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'modules', $anchor == 'modules');
showformheader("plugins&operation=edit&type=modules&pluginid=$pluginid", '', 'modulesform');
showtableheader('plugins_edit_modules');
showsubtitle(array('', 'display_order', 'plugins_edit_modules_name', 'plugins_edit_modules_menu', 'plugins_edit_modules_menu_url', 'plugins_edit_modules_type', 'plugins_edit_modules_adminid'));
if(is_array($plugin['modules'])) {
foreach($plugin['modules'] as $moduleid => $module) {
$adminidselect = array($module['adminid'] => 'selected');
$includecheck = empty($val['include']) ? $lang['no'] : $lang['yes'];
$typeselect = '';
for($i = 1; $i <= 6; $i++) {
$typeselect .= "<option value=\"$i\" ".($module['type'] == $i ? 'selected' : '').">".$lang['plugins_edit_modules_type_'.$i]."</option>";
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$moduleid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"ordernew[$moduleid]\" value=\"$module[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$moduleid]\" value=\"$module[name]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"menunew[$moduleid]\" value=\"$module[menu]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"urlnew[$moduleid]\" value=\"".dhtmlspecialchars($module['url'])."\">",
"<select name=\"typenew[$moduleid]\">$typeselect</select>",
"<select name=\"adminidnew[$moduleid]\">\n".
"<option value=\"0\" $adminidselect[0]>$lang[usergroups_system_0]</option>\n".
"<option value=\"1\" $adminidselect[1]>$lang[usergroups_system_1]</option>\n".
"<option value=\"2\" $adminidselect[2]>$lang[usergroups_system_2]</option>\n".
"<option value=\"3\" $adminidselect[3]>$lang[usergroups_system_3]</option>\n".
"</select>"
));
}
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
lang('add_new'),
'<input type="text" class="txt" size="2" name="neworder">',
'<input type="text" class="txt" size="15" name="newname">',
'<input type="text" class="txt" size="15" name="newmenu">',
'<input type="text" class="txt" size="15" name="newurl">',
'<select name="newtype">
<option value="1">'.lang('plugins_edit_modules_type_1').'</option>
<option value="2">'.lang('plugins_edit_modules_type_2').'</option>
<option value="3">'.lang('plugins_edit_modules_type_3').'</option>
<option value="4">'.lang('plugins_edit_modules_type_4').'</option>
<option value="5">'.lang('plugins_edit_modules_type_5').'</option>
<option value="6">'.lang('plugins_edit_modules_type_6').'</option>
</select>',
'<select name="newadminid">
<option value="0">'.lang('usergroups_system_0').'</option>
<option value="1" selected>'.lang('usergroups_system_1').'</option>
<option value="2">'.lang('usergroups_system_2').'</option>
<option value="3">'.lang('usergroups_system_3').'</option>
</select>'
));
showsubmit('editsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'hooks', $anchor == 'hooks');
showformheader("plugins&operation=edit&type=hooks&pluginid=$pluginid", '', 'hooksform');
showtableheader('plugins_edit_hooks');
showsubtitle(array('', 'available', 'plugins_hooks_title', 'plugins_hooks_callback', 'plugins_hooks_description', ''));
$query = $db->query("SELECT pluginhookid, title, description, available FROM {$tablepre}pluginhooks WHERE pluginid='$plugin[pluginid]'");
while($hook = $db->fetch_array($query)) {
$hook['description'] = nl2br(cutstr($hook['description'], 50));
$hook['evalcode'] = 'eval($hooks[\''.$plugin['identifier'].'_'.$hook['title'].'\']);';
showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[$hook[pluginhookid]]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$hook[pluginhookid]]\" value=\"1\" ".($hook['available'] ? 'checked' : '')." onclick=\"if(this.checked) {\$('hookevalcode{$hook[pluginhookid]}').value='".addslashes($hook[evalcode])."';}else{\$('hookevalcode{$hook[pluginhookid]}').value='N/A';}\">",
"<input type=\"text\" class=\"txt\" name=\"titlenew[$hook[pluginhookid]]\" size=\"15\" value=\"$hook[title]\"></td>\n".
"<td><input type=\"text\" class=\"txt\" name=\"hookevalcode{$hook[pluginhookid]}\" id=\"hookevalcode{$hook[pluginhookid]}\"size=\"30\" value=\"".($hook['available'] ? $hook[evalcode] : 'N/A')."\" readonly>",
$hook[description],
"<a href=\"$BASESCRIPT?action=plugins&operation=hooks&pluginid=$plugin[pluginid]&pluginhookid=$hook[pluginhookid]\" class=\"act\">$lang[edit]</a>"
));
}
showtablerow('', array('', '', '', 'colspan="3"'), array(
lang('add_new'),
'',
'<input type="text" class="txt" name="newtitle" size="15">',
''
));
showsubmit('editsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'vars', $anchor == 'vars');
showformheader("plugins&operation=edit&type=vars&pluginid=$pluginid", '', 'varsform');
showtableheader('plugins_edit_vars');
showsubtitle(array('', 'display_order', 'plugins_vars_title', 'plugins_vars_variable', 'plugins_vars_type', ''));
$query = $db->query("SELECT * FROM {$tablepre}pluginvars WHERE pluginid='$plugin[pluginid]' ORDER BY displayorder");
while($var = $db->fetch_array($query)) {
$var['type'] = $lang['plugins_edit_vars_type_'. $var['type']];
$var['title'] .= isset($lang[$var['title']]) ? '<br />'.$lang[$var['title']] : '';
showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$var[pluginvarid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$var[pluginvarid]]\" value=\"$var[displayorder]\">",
$var['title'],
$var['variable'],
$var['type'],
"<a href=\"$BASESCRIPT?action=plugins&operation=vars&pluginid=$plugin[pluginid]&pluginvarid=$var[pluginvarid]\" class=\"act\">$lang[detail]</a>"
));
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
lang('add_new'),
'<input type="text" class="txt" size="2" name="newdisplayorder" value="0">',
'<input type="text" class="txt" size="15" name="newtitle">',
'<input type="text" class="txt" size="15" name="newvariable">',
'<select name="newtype">
<option value="number">'.lang('plugins_edit_vars_type_number').'</option>
<option value="text" selected>'.lang('plugins_edit_vars_type_text').'</option>
<option value="textarea">'.lang('plugins_edit_vars_type_textarea').'</option>
<option value="radio">'.lang('plugins_edit_vars_type_radio').'</option>
<option value="select">'.lang('plugins_edit_vars_type_select').'</option>
<option value="color">'.lang('plugins_edit_vars_type_color').'</option>
<option value="date">'.lang('plugins_edit_vars_type_date').'</option>
<option value="datetime">'.lang('plugins_edit_vars_type_datetime').'</option>
<option value="forum">'.lang('plugins_edit_vars_type_forum').'</option>
<option value="forums">'.lang('plugins_edit_vars_type_forums').'</option>
<option value="group">'.lang('plugins_edit_vars_type_group').'</option>
<option value="groups">'.lang('plugins_edit_vars_type_groups').'</option>
<option value="extcredit">'.lang('plugins_edit_vars_type_extcredit').'</option>
</seletc>',
''
));
showsubmit('editsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($type == 'common') {
$namenew = dhtmlspecialchars(trim($namenew));
$directorynew = dhtmlspecialchars($directorynew);
$identifiernew = trim($identifiernew);
$datatablesnew = dhtmlspecialchars(trim($datatablesnew));
$descriptionnew = dhtmlspecialchars($descriptionnew);
$copyrightnew = $plugin['copyright'] ? addslashes($plugin['copyright']) : dhtmlspecialchars($copyrightnew);
$adminidnew = ($adminidnew > 0 && $adminidnew <= 3) ? $adminidnew : 1;
if(!$namenew) {
cpmsg('plugins_edit_name_invalid', '', 'error');
} elseif(!isplugindir($directorynew)) {
cpmsg('plugins_edit_directory_invalid', '', 'error');
} elseif($identifiernew != $plugin['identifier']) {
$query = $db->query("SELECT pluginid FROM {$tablepre}plugins WHERE identifier='$identifiernew' LIMIT 1");
if($db->num_rows($query) || !ispluginkey($identifiernew)) {
cpmsg('plugins_edit_identifier_invalid', '', 'error');
}
}
$db->query("UPDATE {$tablepre}plugins SET adminid='$adminidnew', name='$namenew', identifier='$identifiernew', description='$descriptionnew', datatables='$datatablesnew', directory='$directorynew', copyright='$copyrightnew' WHERE pluginid='$pluginid'");
} elseif($type == 'modules') {
$modulesnew = array();
$newname = trim($newname);
if(is_array($plugin['modules'])) {
foreach($plugin['modules'] as $moduleid => $module) {
if(!isset($delete[$moduleid])) {
$modulesnew[] = array
(
'name' => $namenew[$moduleid],
'menu' => $menunew[$moduleid],
'url' => $urlnew[$moduleid],
'type' => $typenew[$moduleid],
'adminid' => ($adminidnew[$moduleid] >= 0 && $adminidnew[$moduleid] <= 3) ? $adminidnew[$moduleid] : $module['adminid'],
'displayorder' => intval($ordernew[$moduleid]),
);
}
}
}
$newmodule = array();
if(!empty($newname)) {
$modulesnew[] = array
(
'name' => $newname,
'menu' => $newmenu,
'url' => $newurl,
'type' => $newtype,
'adminid' => $newadminid,
'displayorder' => intval($neworder),
);
}
usort($modulesnew, 'modulecmp');
$namesarray = array();
foreach($modulesnew as $key => $module) {
if(!ispluginkey($module['name'])) {
cpmsg('plugins_edit_modules_name_invalid', '', 'error');
} elseif(in_array($module['name'], $namesarray)) {
cpmsg('plugins_edit_modules_duplicated', '', 'error');
}
$namesarray[] = $module['name'];
$module['menu'] = trim($module['menu']);
$module['url'] = trim($module['url']);
$module['adminid'] = $module['adminid'] >= 0 && $module['adminid'] <= 3 ? $module['adminid'] : 1 ;
switch($module['type']) {
case 5:
case 1:
if(empty($module['url'])) {
cpmsg('plugins_edit_modules_url_invalid', '', 'error');
}
break;
case 6:
case 2:
case 3:
if(empty($module['menu'])) {
cpmsg('plugins_edit_modules_menu_invalid', '', 'error');
}
unset($module['url']);
break;
case 4:
unset($module['menu'], $module['url']);
break;
default:
cpmsg('undefined_action', '', 'error');
}
$modulesnew[$key] = $module;
}
$db->query("UPDATE {$tablepre}plugins SET modules='".addslashes(serialize($modulesnew))."' WHERE pluginid='$pluginid'");
} elseif($type == 'hooks') {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id => $val) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}pluginhooks WHERE pluginid='$pluginid' AND pluginhookid IN ($ids)");
}
if(is_array($titlenew)) {
$titlearray = array();
foreach($titlenew as $id => $val) {
if(!ispluginkey($val) || in_array($val, $titlearray)) {
cpmsg('plugins_edit_hooks_title_invalid', '', 'error');
}
$titlearray[] = $val;
$db->query("UPDATE {$tablepre}pluginhooks SET title='".dhtmlspecialchars($titlenew[$id])."', available='".intval($availablenew[$id])."' WHERE pluginid='$pluginid' AND pluginhookid='$id'");
}
}
if($newtitle) {
if(!ispluginkey($newtitle) || (is_array($titlenew) && in_array($newtitle, $titlenew))) {
cpmsg('plugins_edit_hooks_title_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}pluginhooks (pluginid, title, description, code, available)
VALUES ('$pluginid', '".dhtmlspecialchars($newtitle)."', '', '', 0)");
}
} elseif($type == 'vars') {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}pluginvars WHERE pluginid='$pluginid' AND pluginvarid IN ($ids)");
}
if(is_array($displayordernew)) {
foreach($displayordernew as $id => $displayorder) {
$db->query("UPDATE {$tablepre}pluginvars SET displayorder='$displayorder' WHERE pluginid='$pluginid' AND pluginvarid='$id'");
}
}
$newtitle = dhtmlspecialchars(trim($newtitle));
$newvariable = trim($newvariable);
if($newtitle && $newvariable) {
$query = $db->query("SELECT pluginvarid FROM {$tablepre}pluginvars WHERE pluginid='$pluginid' AND variable='$newvariable' LIMIT 1");
if($db->num_rows($query) || strlen($newvariable) > 40 || !ispluginkey($newvariable)) {
cpmsg('plugins_edit_var_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}pluginvars (pluginid, displayorder, title, variable, type)
VALUES ('$pluginid', '$newdisplayorder', '$newtitle', '$newvariable', '$newtype')");
}
}
updatecache('plugins');
updatecache('settings');
cpmsg('plugins_edit_succeed', "$BASESCRIPT?action=plugins&operation=edit&pluginid=$pluginid&anchor=$anchor", 'succeed');
}
} elseif($operation == 'hooks') {
$pluginhook = $db->fetch_first("SELECT * FROM {$tablepre}plugins p, {$tablepre}pluginhooks ph WHERE p.pluginid='$pluginid' AND ph.pluginid=p.pluginid AND ph.pluginhookid='$pluginhookid'");
if(!$pluginhook) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('hooksubmit')) {
shownav('extended', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('config', 'plugins&operation=config', 1),
array('admin', 'plugins', 0),
array('import', 'plugins&operation=import', 0)
));
showtips('plugins_edit_hooks_tips');
showformheader("plugins&operation=hooks&pluginid=$pluginid&pluginhookid=$pluginhookid");
showtableheader();
showtitle($lang['plugins_edit_hooks'].' - '.$pluginhook['title']);
showsetting('plugins_edit_hooks_description', 'descriptionnew', $pluginhook['description'], 'textarea');
showsetting('plugins_edit_hooks_code', 'codenew', $pluginhook['code'], 'textarea');
showsubmit('hooksubmit');
showtablefooter();
showformfooter();
} else {
$descriptionnew = dhtmlspecialchars(trim($descriptionnew));
$codenew = trim($codenew);
$db->query("UPDATE {$tablepre}pluginhooks SET description='$descriptionnew', code='$codenew' WHERE pluginid='$pluginid' AND pluginhookid='$pluginhookid'");
updatecache('settings');
cpmsg('plugins_edit_hooks_succeed', "$BASESCRIPT?action=plugins&operation=edit&pluginid=$pluginid", 'succeed');
}
} elseif($operation == 'vars') {
$pluginvar = $db->fetch_first("SELECT * FROM {$tablepre}plugins p, {$tablepre}pluginvars pv WHERE p.pluginid='$pluginid' AND pv.pluginid=p.pluginid AND pv.pluginvarid='$pluginvarid'");
if(!$pluginvar) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('varsubmit')) {
shownav('extended', 'nav_plugins');
showsubmenu('nav_plugins', array(
array('config', 'plugins&operation=config', 1),
array('admin', 'plugins', 0),
array('import', 'plugins&operation=import', 0)
));
$typeselect = '<select name="typenew">';
foreach(array('number', 'text', 'radio', 'textarea', 'select', 'color', 'date', 'datetime', 'forum', 'forums', 'group', 'groups', 'extcredit') as $type) {
$typeselect .= '<option value="'.$type.'" '.($pluginvar['type'] == $type ? 'selected' : '').'>'.$lang['plugins_edit_vars_type_'.$type].'</option>';
}
$typeselect .= '</select>';
showformheader("plugins&operation=vars&pluginid=$pluginid&pluginvarid=$pluginvarid");
showtableheader();
showtitle($lang['plugins_edit_vars'].' - '.$pluginvar['title']);
showsetting('plugins_edit_vars_title', 'titlenew', $pluginvar['title'], 'text');
showsetting('plugins_edit_vars_description', 'descriptionnew', $pluginvar['description'], 'textarea');
showsetting('plugins_edit_vars_type', '', '', $typeselect);
showsetting('plugins_edit_vars_variable', 'variablenew', $pluginvar['variable'], 'text');
showsetting('plugins_edit_vars_extra', 'extranew', $pluginvar['extra'], 'textarea');
showsubmit('varsubmit');
showtablefooter();
showformfooter();
} else {
$titlenew = cutstr(dhtmlspecialchars(trim($titlenew)), 25);
$descriptionnew = cutstr(dhtmlspecialchars(trim($descriptionnew)), 255);
$variablenew = trim($variablenew);
$extranew = dhtmlspecialchars(trim($extranew));
if(!$titlenew) {
cpmsg('plugins_edit_vars_title_invalid', '', 'error');
} elseif($variablenew != $pluginvar['variable']) {
$query = $db->query("SELECT pluginvarid FROM {$tablepre}pluginvars WHERE variable='$variablenew'");
if($db->num_rows($query) || !$variablenew || strlen($variablenew) > 40 || !ispluginkey($variablenew)) {
cpmsg('plugins_edit_vars_invalid', '', 'error');
}
}
$db->query("UPDATE {$tablepre}pluginvars SET title='$titlenew', description='$descriptionnew', type='$typenew', variable='$variablenew', extra='$extranew' WHERE pluginid='$pluginid' AND pluginvarid='$pluginvarid'");
updatecache('plugins');
cpmsg('plugins_edit_vars_succeed', "$BASESCRIPT?action=plugins&operation=edit&pluginid=$pluginid", 'succeed');
}
}
function modulecmp($a, $b) {
return $a['displayorder'] > $b['displayorder'] ? 1 : -1;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/plugins.inc.php
|
PHP
|
asf20
| 35,843
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: cpanel.share.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class AdminSession {
var $uid = 0;
var $panel = 0;
var $inadmincp = false;
var $isfounder = false;
var $cpaccess = 0;
var $checkip = 1;
var $logfile = 'cplog';
var $timelimit;
var $errorcount = 0;
var $storage = array();
var $db = null;
var $tablepre = '';
function adminsession($uid, $groupid, $adminid, $ip) {
global $adminipaccess, $db, $tablepre;
$this->panel = defined('IN_ADMINCP') ? 1 : (defined('IN_MODCP') ? 2 : -1);
$this->inadmincp = defined('IN_ADMINCP');
$this->uid = $uid;
$this->timelimit = time() - 1800;
$this->db = &$db;
$this->tablepre = &$tablepre;
if($uid < 1 || $adminid < 1 || ($this->inadmincp && $adminid != 1)) {
$cpaccess = 0;
}elseif($this->inadmincp && $adminipaccess && !ipaccess($ip, $adminipaccess)) {
$cpaccess = 2;
} else {
$session = $this->_loadsession($uid, $ip, $GLOBALS['admincp']['checkip']);
$this->errorcount = $session['errorcount'];
$this->storage = $session['storage'];
if(empty($session)) {
$this->creatsession($uid, $adminid, $ip);
$cpaccess = 1;
} elseif($session['errorcount'] == -1) {
$this->update();
$cpaccess = 3;
} elseif($session['errorcount'] <= 3) {
$cpaccess = 1;
} else {
$cpaccess = -1;
}
}
if($cpaccess == 0) {
clearcookies();
showmessage('admin_cpanel_noaccess', 'logging.php?action=login', 'HALTED');
} elseif($cpaccess == 2) {
showmessage('admin_cpanel_noaccess_ip', NULL, 'HALTED');
} elseif($cpaccess == -1) {
showmessage('admin_cpanel_locked', NULL, 'HALTED');
}
$this->cpaccess = $cpaccess;
}
function _loadsession($uid, $ip, $checkip = 1) {
$session = array();
$query = $this->db->query("SELECT uid, adminid, panel, ip, dateline, errorcount, storage FROM {$this->tablepre}adminsessions
WHERE uid='$uid' ".($checkip ? "AND ip='$ip'" : '')." AND panel='{$this->panel}' AND dateline>'{$this->timelimit}'", 'SILENT');
if(!$this->db->error()) {
$session = $this->db->fetch_array($query);
if(isset($session['storage'])) {
$session['storage'] = $session['storage'] ? unserialize(base64_decode($session['storage'])) : array();
}
} else {
$this->db->query("DROP TABLE IF EXISTS {$this->tablepre}adminsessions");
$this->db->query("CREATE TABLE {$this->tablepre}adminsessions (
uid mediumint(8) UNSIGNED NOT NULL default '0',
adminid smallint(6) unsigned NOT NULL DEFAULT '0',
panel tinyint(1) NOT NULL DEFAULT '0',
ip varchar(15) NOT NULL default '',
dateline int(10) unsigned NOT NULL default '0',
errorcount tinyint(1) NOT NULL default '0',
`storage` mediumtext NOT NULL,
PRIMARY KEY (`uid`, `panel`))".(mysql_get_server_info() > '4.1' ? " ENGINE=MYISAM DEFAULT CHARSET=$GLOBALS[dbcharset]" : " TYPE=MYISAM")
);
}
return $session;
}
function creatsession($uid, $adminid, $ip) {
$url_forward = !empty($_SERVER['QUERY_STRING']) ? addslashes($_SERVER['QUERY_STRING']) : '';
$this->destroy($uid);
$this->db->query("INSERT INTO {$this->tablepre}adminsessions (uid, adminid, panel, ip, dateline, errorcount)
VALUES ('$uid', '$adminid', '$this->panel', '$ip', '".time()."', '0')");
$this->set('url_forward', $url_forward, true);
}
function destroy($uid = 0) {
empty($uid) && $uid = $this->uid;
$this->db->query("DELETE FROM {$this->tablepre}adminsessions WHERE (uid='$uid' AND panel='$this->panel') OR dateline<'$this->timelimit'");
}
function _loadstorage() {
$storage = $this->db->result_first("SELECT storage FROM {$this->tablepre}adminsessions WHERE uid='{$this->uid}' AND panel='$this->panel'");
if(!empty($storage)) {
$this->storage = unserialize(base64_decode($storage));
} else {
$this->storage = array();
}
}
function isfounder($user = '') {
$user = empty($user) ? array('uid' => $GLOBALS['discuz_uid'], 'adminid' => $GLOBALS['adminid'], 'username' => $GLOBALS['discuz_userss']) : $user;
$founders = str_replace(' ', '', $GLOBALS['forumfounders']);
if($user['adminid'] <> 1) {
return FALSE;
} elseif(empty($founders)) {
return TRUE;
} elseif(strexists(",$founders,", ",$user[uid],")) {
return TRUE;
} elseif(!is_numeric($user['username']) && strexists(",$founders,", ",$user[username],")) {
return TRUE;
} else {
return FALSE;
}
}
function set($varname, $value, $updatedb = false) {
$this->storage[$varname] = $value;
$updatedb && $this->update();
}
function get($varname, $fromdb = false) {
$return = null;
$fromdb && $this->_loadstorage();
if(isset($this->storage[$varname])) {
$return = $this->storage[$varname];
}
return $return;
}
function clear($updatedb = false) {
$this->storage = array();
$updatedb && $this->update();
}
function update() {
if($this->uid) {
$timestamp = time();
$storage = !empty($this->storage) ? base64_encode((serialize($this->storage))) : '';
$this->db->query("UPDATE {$this->tablepre}adminsessions SET dateline='$timestamp', errorcount='{$this->errorcount}', storage='{$storage}'
WHERE uid='{$this->uid}' AND panel='$this->panel'", 'UNBUFFERED');
}
}
}
function acpmsg($message, $url = '', $type = '', $extra = '') {
if(defined('IN_ADMINCP')) {
!defined('CPHEADER_SHOWN') && cpheader();
cpmsg($message, $url, $type, $extra);
} else {
showmessage($message, $url, $extra);
}
}
function savebanlog($username, $origgroupid, $newgroupid, $expiration, $reason) {
global $discuz_userss, $groupid, $onlineip, $timestamp, $forum, $reason;
writelog('banlog', dhtmlspecialchars("$timestamp\t$discuz_userss\t$groupid\t$onlineip\t$username\t$origgroupid\t$newgroupid\t$expiration\t$reason"));
}
function clearlogstring($str) {
if(!empty($str)) {
if(!is_array($str)) {
$str = dhtmlspecialchars(trim($str));
$str = str_replace(array("\t", "\r\n", "\n", " ", " "), ' ', $str);
} else {
foreach ($str as $key => $val) {
$str[$key] = clearlogstring($val);
}
}
}
return $str;
}
function implodearray($array, $skip = array()) {
$return = '';
if(is_array($array) && !empty($array)) {
foreach ($array as $key => $value) {
if(empty($skip) || !in_array($key, $skip)) {
if(is_array($value)) {
$return .= "$key={".implodearray($value, $skip)."}; ";
} else {
$return .= "$key=$value; ";
}
}
}
}
return $return;
}
function deletethreads($tids = array()) {
global $db, $tablepre, $losslessdel, $creditspolicy;
static $cleartable = array(
'threadsmod', 'relatedthreads', 'posts', 'polls',
'polloptions', 'trades', 'activities', 'activityapplies', 'debates',
'videos', 'debateposts', 'attachments', 'favorites', 'mythreads',
'myposts', 'subscriptions', 'typeoptionvars', 'forumrecommend'
);
$threadsdel = 0;
if($tids = implodeids($tids)) {
$auidarray = array();
$query = $db->query("SELECT uid, attachment, dateline, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
if($attach['dateline'] > $losslessdel) {
$auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
}
}
if($auidarray) {
updateattachcredits('-', $auidarray, $creditspolicy['postattach']);
}
$videoopen && videodelete($moderate, TRUE);
foreach($cleartable as $tb) {
$db->query("DELETE FROM {$tablepre}$tb WHERE tid IN ($tids)", 'UNBUFFERED');
}
$db->query("DELETE FROM {$tablepre}threads WHERE tid IN ($tids)");
$threadsdel = $db->affected_rows();
}
return $threadsdel;
}
function undeletethreads($tids) {
global $db, $tablepre, $creditspolicy;
$threadsundel = 0;
if($tids && is_array($tids)) {
$tids = '\''.implode('\',\'', $tids).'\'';
$tuidarray = $ruidarray = $fidarray = array();
$query = $db->query("SELECT fid, first, authorid FROM {$tablepre}posts WHERE tid IN ($tids)");
while($post = $db->fetch_array($query)) {
if($post['first']) {
$tuidarray[] = $post['authorid'];
} else {
$ruidarray[] = $post['authorid'];
}
if(!in_array($post['fid'], $fidarray)) {
$fidarray[] = $post['fid'];
}
}
if($tuidarray) {
updatepostcredits('+', $tuidarray, $creditspolicy['post']);
}
if($ruidarray) {
updatepostcredits('+', $ruidarray, $creditspolicy['reply']);
}
$db->query("UPDATE {$tablepre}posts SET invisible='0' WHERE tid IN ($tids)", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET displayorder='0', moderated='1' WHERE tid IN ($tids)");
$threadsundel = $db->affected_rows();
updatemodlog($tids, 'UDL');
updatemodworks('UDL', $threadsundel);
foreach($fidarray as $fid) {
updateforumcount($fid);
}
}
return $threadsundel;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/cpanel.share.php
|
PHP
|
asf20
| 9,192
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: threadtypes.inc.php 17546 2009-01-21 07:35:21Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if($special) {
$special = 1;
$navlang = 'threadtype_infotypes';
$operation = 'type';
$changetype = 'threadsorts';
} else {
$special = 0;
$navlang = 'forums_edit_threadtypes';
$changetype = 'threadtypes';
}
if(!submitcheck('typesubmit')) {
$forumsarray = $fidsarray = array();
$query = $db->query("SELECT f.fid, f.name, ff.$changetype FROM {$tablepre}forums f , {$tablepre}forumfields ff WHERE ff.$changetype<>'' AND f.fid=ff.fid");
while($forum = $db->fetch_array($query)) {
$forum[$changetype] = unserialize($forum[$changetype]);
if(is_array($forum[$changetype]['types'])) {
foreach($forum[$changetype]['types'] as $typeid => $name) {
$forumsarray[$typeid][] = '<a href="'.$BASESCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'&anchor=threadtypes">'.$forum['name'].'</a>';
$fidsarray[$typeid][] = $forum['fid'];
}
}
}
if($special) {
$typemodelopt = '';
$query = $db->query("SELECT id, name FROM {$tablepre}typemodels ORDER BY displayorder");
while($typemodel = $db->fetch_array($query)) {
$typemodelopt .= "<option value=\"$typemodel[id]\" ".($typemodel['id'] == $threadtype['special'] ? 'selected="selected"' : '').">$typemodel[name]</option>";
}
}
$threadtypes = '';
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE ".($special ? "special!='0'" : "special='0'")." ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$threadtypes .= showtablerow('', array('class="td25"', 'class="td28"', '', 'class="td29"', 'title="'.lang('forums_threadtypes_forums_comment').'"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[typeid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$type[typeid]]\" value=\"$type[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$type[typeid]]\" value=\"".dhtmlspecialchars($type['name'])."\">",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"descriptionnew[$type[typeid]]\" value=\"$type[description]\">",
is_array($forumsarray[$type['typeid']]) ? '<ul class="nowrap lineheight"><li>'.implode(',</li><li> ', $forumsarray[$type['typeid']])."</li></ul><input type=\"hidden\" name=\"fids[$type[typeid]]\" value=\"".implode(', ', $fidsarray[$type['typeid']])."\">" : '',
$special ? "<a href=\"$BASESCRIPT?action=threadtypes&operation=sortdetail&sortid=$type[typeid]\" class=\"act nowrap\">$lang[detail]</a>" : ''
), TRUE);
}
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1, '', 'td25'],
[1, '<input type="text" class="txt" name="newdisplayorder[]" size="2" value="">', 'td28'],
[1, '<input type="text" class="txt" name="newname[]" size="15">'],
[1, '<input type="text" class="txt" name="newdescription[]" size="30" value="">', 'td29'],
[2, '']
],
];
</script>
<?
shownav('forum', $navlang);
showsubmenu($navlang);
!$special ? showtips('forums_edit_threadtypes_tips') : '';
showformheader("threadtypes&");
showhiddenfields(array('special' => $special));
showtableheader('');
showsubtitle(array('', 'display_order', 'name', 'description', 'forums_relation', ''));
echo $threadtypes;
?>
<tr>
<td class="td25"></td>
<td colspan="4"><div><a href="###" onclick="addrow(this, 0)" class="addtr"><?=$lang['threadtype_infotypes_add']?></a></div></td>
<?
echo $special ? '<td> </td>' : '<td></td>';
?>
</tr>
<?
showsubmit('typesubmit', 'submit', 'del');
showformfooter();
} else {
$updatefids = $modifiedtypes = array();
if(is_array($delete)) {
if($deleteids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typeoptionvars WHERE sortid IN ($deleteids)");
$db->query("DELETE FROM {$tablepre}tradeoptionvars WHERE sortid IN ($deleteids)");
$db->query("DELETE FROM {$tablepre}typevars WHERE sortid IN ($deleteids)");
$db->query("DELETE FROM {$tablepre}threadtypes WHERE typeid IN ($deleteids) AND special='$special'");
}
if($deleteids && $db->affected_rows()) {
$db->query("UPDATE {$tablepre}threads SET typeid='0' WHERE typeid IN ($deleteids)");
foreach($delete as $id) {
if(is_array($namenew) && isset($namenew[$id])) {
unset($namenew[$id]);
}
if(!empty($fids[$id])) {
foreach(explode(',', $fids[$id]) as $fid) {
if($fid = intval($fid)) {
$updatefids[$fid]['deletedids'][] = intval($id);
}
}
}
}
}
}
if(is_array($namenew) && $namenew) {
foreach($namenew as $typeid => $val) {
$db->query("UPDATE {$tablepre}threadtypes SET name='".trim($namenew[$typeid])."', description='".dhtmlspecialchars(trim($descriptionnew[$typeid]))."', displayorder='$displayordernew[$typeid]', special='$special' WHERE typeid='$typeid'");
if($db->affected_rows()) {
$modifiedtypes[] = $typeid;
}
}
if($modifiedtypes = array_unique($modifiedtypes)) {
foreach($modifiedtypes as $id) {
if(!empty($fids[$id])) {
foreach(explode(',', $fids[$id]) as $fid) {
if($fid = intval($fid)) {
$updatefids[$fid]['modifiedids'][] = $id;
}
}
}
}
}
}
if($updatefids) {
$query = $db->query("SELECT fid, $changetype FROM {$tablepre}forumfields WHERE fid IN (".implodeids(array_keys($updatefids)).") AND $changetype<>''");
while($forum = $db->fetch_array($query)) {
$fid = $forum['fid'];
$forum[$changetype] = unserialize($forum[$changetype]);
if($updatefids[$fid]['deletedids']) {
foreach($updatefids[$fid]['deletedids'] as $id) {
unset($forum[$changetype]['types'][$id], $forum[$changetype]['flat'][$id], $forum[$changetype]['selectbox'][$id]);
}
}
if($updatefids[$fid]['modifiedids']) {
foreach($updatefids[$fid]['modifiedids'] as $id) {
if(isset($forum[$changetype]['types'][$id])) {
$namenew[$id] = trim($namenew[$id]);
$forum[$changetype]['types'][$id] = $namenew[$id];
if(isset($forum[$changetype]['selectbox'][$id])) {
$forum[$changetype]['selectbox'][$id] = $namenew[$id];
} else {
$forum[$changetype]['flat'][$id] = $namenew[$id];
}
}
}
}
$db->query("UPDATE {$tablepre}forumfields SET $changetype='".addslashes(serialize($forum[$changetype]))."' WHERE fid='$fid'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
if($newname1 = trim($value)) {
$query = $db->query("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$newname1'");
if($db->num_rows($query)) {
cpmsg('forums_threadtypes_duplicate', '', 'error');
}
$db->query("INSERT INTO {$tablepre}threadtypes (name, description, displayorder, special) VALUES
('$newname1', '".dhtmlspecialchars(trim($newdescription[$key]))."', '$newdisplayorder[$key]', '$special')");
}
}
}
cpmsg('forums_threadtypes_succeed', $BASESCRIPT.'?action=threadtypes&special='.$special, 'succeed');
}
} elseif($operation == 'typeoption') {
if(!submitcheck('typeoptionsubmit')) {
$classid = $classid ? intval($classid) : $db->result_first("SELECT * FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder LIMIT 1");
$classoptions = array();
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$classoptions[] = array($option[title], "threadtypes&operation=typeoption&classid=$option[optionid]", $classid == $option[optionid]);
}
if($classid) {
if(!$typetitle = $db->result_first("SELECT title FROM {$tablepre}typeoptions WHERE optionid='$classid'")) {
cpmsg('threadtype_infotypes_noexist', $BASESCRIPT.'?action=threadtypes', 'error');
}
$typeoptions = '';
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='$classid' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$option['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$typeoptions .= showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"title[$option[optionid]]\" value=\"".dhtmlspecialchars($option['title'])."\">",
"$option[identifier]<input type=\"hidden\" name=\"identifier[$option[optionid]]\" value=\"$option[identifier]\">",
$option['type'],
"<a href=\"$BASESCRIPT?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1, '', 'td25'],
[1, '<input type="text" class="txt" size="2" name="newdisplayorder[]" value="0">', 'td28'],
[1, '<input type="text" class="txt" size="15" name="newtitle[]">'],
[1, '<input type="text" class="txt" size="15" name="newidentifier[]">'],
[1, '<select name="newtype[]"><option value="number">$lang[threadtype_edit_vars_type_number]</option><option value="text" selected>$lang[threadtype_edit_vars_type_text]</option><option value="textarea">$lang[threadtype_edit_vars_type_textarea]</option><option value="radio">$lang[threadtype_edit_vars_type_radio]</option><option value="checkbox">$lang[threadtype_edit_vars_type_checkbox]</option><option value="select">$lang[threadtype_edit_vars_type_select]</option><option value="calendar">$lang[threadtype_edit_vars_type_calendar]</option><option value="email">$lang[threadtype_edit_vars_type_email]</option><option value="image">$lang[threadtype_edit_vars_type_image]</option><option value="url">$lang[threadtype_edit_vars_type_url]</option></select>'],
[1, '']
],
];
</script>
EOT;
shownav('forum', 'threadtype_infotypes_option');
showsubmenu('threadtype_cat_manage', $classoptions);
showformheader("threadtypes&operation=typeoption&typeid=$typeid");
showhiddenfields(array('classid' => $classid));
showtableheader();
showsubtitle(array('', 'display_order', 'name', 'threadtype_variable', 'threadtype_type', ''));
echo $typeoptions;
echo '<tr><td></td><td colspan="5"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['threadtype_infotypes_add_option'].'</a></div></td></tr>';
showsubmit('typeoptionsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typeoptions WHERE optionid IN ($ids)");
$db->query("DELETE FROM {$tablepre}typevars WHERE optionid IN ($ids)");
}
if(is_array($title)) {
foreach($title as $id => $val) {
$db->query("UPDATE {$tablepre}typeoptions SET displayorder='$displayorder[$id]', title='$title[$id]', identifier='$identifier[$id]' WHERE optionid='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $key => $value) {
$newtitle1 = dhtmlspecialchars(trim($value));
$newidentifier1 = trim($newidentifier[$key]);
if($newtitle1 && $newidentifier1) {
$query = $db->query("SELECT optionid FROM {$tablepre}typeoptions WHERE identifier='$newidentifier1' LIMIT 1");
if($db->num_rows($query) || strlen($newidentifier1) > 40 || !ispluginkey($newidentifier1)) {
cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}typeoptions (classid, displayorder, title, identifier, type)
VALUES ('$classid', '$newdisplayorder[$key]', '$newtitle1', '$newidentifier1', '$newtype[$key]')");
} elseif($newtitle1 && !$newidentifier1) {
cpmsg('threadtype_infotypes_option_invalid', $BASESCRIPT.'?action=threadtypes&operation=typeoption&classid='.$classid, 'error');
}
}
}
updatecache('threadsorts');
cpmsg('threadtype_infotypes_succeed', $BASESCRIPT.'?action=threadtypes&operation=typeoption&classid='.$classid, 'succeed');
}
} elseif($operation == 'optiondetail') {
$option = $db->fetch_first("SELECT * FROM {$tablepre}typeoptions WHERE optionid='$optionid'");
if(!$option) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
shownav('forum', 'threadtype_infotypes_option');
showsubmenu('threadtype_infotypes_option');
$typeselect = '<select name="typenew" onchange="var styles, key;styles=new Array(\'number\',\'text\',\'radio\', \'checkbox\', \'textarea\', \'select\', \'image\'); for(key in styles) {var obj=$(\'style_\'+styles[key]); obj.style.display=styles[key]==this.options[this.selectedIndex].value?\'\':\'none\';}">';
foreach(array('number', 'text', 'radio', 'checkbox', 'textarea', 'select', 'calendar', 'email', 'url', 'image') as $type) {
$typeselect .= '<option value="'.$type.'" '.($option['type'] == $type ? 'selected' : '').'>'.$lang['threadtype_edit_vars_type_'.$type].'</option>';
}
$typeselect .= '</select>';
$option['rules'] = unserialize($option['rules']);
showformheader("threadtypes&operation=optiondetail&optionid=$optionid");
showtableheader();
showtitle('threadtype_infotypes_option_config');
showsetting('name', 'titlenew', $option['title'], 'text');
showsetting('threadtype_variable', 'identifiernew', $option['identifier'], 'text');
showsetting('type', '', '', $typeselect);
showsetting('threadtype_edit_desc', 'descriptionnew', $option['description'], 'textarea');
showtagheader('tbody', "style_number", $option['type'] == 'number');
showtitle('threadtype_edit_vars_type_number');
showsetting('threadtype_edit_maxnum', 'rules[number][maxnum]', $option['rules']['maxnum'], 'text');
showsetting('threadtype_edit_minnum', 'rules[number][minnum]', $option['rules']['minnum'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_text", $option['type'] == 'text');
showtitle('threadtype_edit_vars_type_text');
showsetting('threadtype_edit_textmax', 'rules[text][maxlength]', $option['rules']['maxlength'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_textarea", $option['type'] == 'textarea');
showtitle('threadtype_edit_vars_type_textarea');
showsetting('threadtype_edit_textmax', 'rules[textarea][maxlength]', $option['rules']['maxlength'], 'text');
showtagfooter('tbody');
showtagheader('tbody', "style_select", $option['type'] == 'select');
showtitle('threadtype_edit_vars_type_select');
showsetting('threadtype_edit_choices', 'rules[select][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_radio", $option['type'] == 'radio');
showtitle('threadtype_edit_vars_type_radio');
showsetting('threadtype_edit_choices', 'rules[radio][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_checkbox", $option['type'] == 'checkbox');
showtitle('threadtype_edit_vars_type_checkbox');
showsetting('threadtype_edit_choices', 'rules[checkbox][choices]', $option['rules']['choices'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', "style_image", $option['type'] == 'image');
showtitle('threadtype_edit_vars_type_image');
showsetting('threadtype_edit_images_weight', 'rules[image][maxwidth]', $option['rules']['maxwidth'], 'text');
showsetting('threadtype_edit_images_height', 'rules[image][maxheight]', $option['rules']['maxheight'], 'text');
showtagfooter('tbody');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$titlenew = trim($titlenew);
if(!$titlenew || !$identifiernew) {
cpmsg('threadtype_infotypes_option_invalid', '', 'error');
}
$query = $db->query("SELECT optionid FROM {$tablepre}typeoptions WHERE identifier='$identifiernew' AND optionid!='$optionid' LIMIT 1");
if($db->num_rows($query) || strlen($identifiernew) > 40 || !ispluginkey($identifiernew)) {
cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}typeoptions SET title='$titlenew', description='$descriptionnew', identifier='$identifiernew', type='$typenew', rules='".addslashes(serialize($rules[$typenew]))."' WHERE optionid='$optionid'");
updatecache('threadsorts');
cpmsg('threadtype_infotypes_option_succeed', $BASESCRIPT.'?action=threadtypes&operation=optiondetail&optionid='.$optionid, 'succeed');
}
} elseif($operation == 'sortdetail') {
if(!submitcheck('sortdetailsubmit') && !submitcheck('sortpreviewsubmit')) {
$threadtype = $db->fetch_first("SELECT name, template, modelid, expiration FROM {$tablepre}threadtypes WHERE typeid='$sortid'");
$threadtype['modelid'] = isset($modelid) ? intval($modelid) : $threadtype['modelid'];
$typemodelopt = '';
$existoption = $showoption = array();
$query = $db->query("SELECT id, name, options, customoptions FROM {$tablepre}typemodels ORDER BY displayorder");
while($typemodel = $db->fetch_array($query)) {
if($typemodel['id'] == $threadtype['modelid']) {
foreach(explode("\t", $typemodel['customoptions']) as $id) {
$existoption[$id] = 0;
}
foreach(explode("\t", $typemodel['options']) as $id) {
$existoption[$id] = 1;
}
}
$typemodelopt .= "<option value=\"$typemodel[id]\" ".($typemodel['id'] == $threadtype['modelid'] ? 'selected="selected"' : '').">$typemodel[name]</option>";
}
$sortoptions = $jsoptionids = '';
$query = $db->query("SELECT t.optionid, t.displayorder, t.available, t.required, t.unchangeable, t.search, tt.title, tt.type, tt.identifier
FROM {$tablepre}typevars t, {$tablepre}typeoptions tt
WHERE t.sortid='$sortid' AND t.optionid=tt.optionid ORDER BY t.displayorder");
while($option = $db->fetch_array($query)) {
$jsoptionids .= "optionids.push($option[optionid]);\r\n";
$optiontitle[$option['identifier']] = $option['title'];
$showoption[$option['optionid']]['optionid'] = $option['optionid'];
$showoption[$option['optionid']]['title'] = $option['title'];
$showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$showoption[$option['optionid']]['identifier'] = $option['identifier'];
$showoption[$option['optionid']]['displayorder'] = $option['displayorder'];
$showoption[$option['optionid']]['available'] = $option['available'];
$showoption[$option['optionid']]['required'] = $option['required'];
$showoption[$option['optionid']]['unchangeable'] = $option['unchangeable'];
$showoption[$option['optionid']]['search'] = $option['search'];
}
if($existoption && is_array($existoption)) {
$optionids = $comma = '';
foreach($existoption as $optionid => $val) {
$optionids .= $comma.$optionid;
$comma = '\',\'';
}
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN ('$optionids')");
while($option = $db->fetch_array($query)) {
$showoption[$option['optionid']]['optionid'] = $option['optionid'];
$showoption[$option['optionid']]['title'] = $option['title'];
$showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$showoption[$option['optionid']]['identifier'] = $option['identifier'];
$showoption[$option['optionid']]['required'] = $existoption[$option['optionid']];
$showoption[$option['optionid']]['available'] = 1;
$showoption[$option['optionid']]['unchangeable'] = 0;
$showoption[$option['optionid']]['model'] = 1;
}
}
$searchtitle = $searchvalue = array();
foreach($showoption as $optionid => $option) {
$sortoptions .= showtablerow('id="optionid'.$optionid.'"', array('class="td25"', 'class="td28 td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\" ".($option['model'] ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$option[optionid]]\" value=\"1\" ".($option['available'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
dhtmlspecialchars($option['title']),
$option['type'],
"<input class=\"checkbox\" type=\"checkbox\" name=\"required[$option[optionid]]\" value=\"1\" ".($option['required'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"unchangeable[$option[optionid]]\" value=\"1\" ".($option['unchangeable'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"search[$option[optionid]]\" value=\"1\" ".($option['search'] ? 'checked' : '').">",
"<a href=\"###\" onclick=\"insertvar('$option[identifier]');doane(event);return false;\" class=\"act\">".$lang['threadtype_infotypes_add_template']."</a>",
"<a href=\"$BASESCRIPT?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">".$lang['edit']."</a>"
), TRUE);
$searchtitle[] = '/{('.$option['identifier'].')}/e';
$searchvalue[] = '/\[('.$option['identifier'].')value\]/e';
}
if($threadtype['template']) {
$previewtemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $threadtype['template']);
$previewtemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $previewtemplate);
}
shownav('forum', 'forums_edit_threadsorts');
showsubmenu('forums_edit_threadsorts');
showformheader("threadtypes&operation=sortdetail&sortid=$sortid");
showtableheader('threadtype_models', 'nobottom');
showsetting('threadtype_models_select', '', '', '<select name="modelid" onchange="window.location=\''.$BASESCRIPT.'?action=threadtypes&operation=sortdetail&sortid='.$sortid.'&modelid=\'+this.options[this.selectedIndex].value"><option value="0">'.$lang['none'].'</option>'.$typemodelopt.'</select>');
showsetting('threadtype_infotypes_validity', 'typeexpiration', $threadtype['expiration'], 'radio');
showtablefooter();
showtableheader("$threadtype[name] - $lang[threadtype_infotypes_add_option]", 'noborder fixpadding');
showtablerow('', 'id="classlist"', '');
showtablerow('', 'id="optionlist"', '');
showtablefooter();
showtableheader("$threadtype[name] - $lang[threadtype_infotypes_exist_option]", 'noborder fixpadding', 'id="sortlist"');
showsubtitle(array('<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form,\'delete\')" /><label for="chkall">'.lang('del').'</label>', 'display_order', 'available', 'name', 'type', 'required', 'unchangeable', 'threadtype_infotypes_search', '', ''));
echo $sortoptions;
showtablefooter();
?>
<a name="template"></a>
<div class="colorbox">
<h4 style="margin-bottom:15px;"><?=$threadtype['name']?> - <?=$lang['threadtype_infotypes_template']?></h4>
<textarea cols="100" rows="5" id="typetemplate" name="typetemplate" style="width: 95%;" onkeyup="textareasize(this)"><?=$threadtype['template']?></textarea>
<br /><br />
<b><?=$lang['threadtype_infotypes_template']?>:</b>
<ul class="tpllist"><?=$lang['threadtype_infotypes_template_tips']?></ul>
<?php
if($previewtemplate) {
echo '<fieldset style="margin:1em 0; padding:1em 1.5em;"><legend><b>'.$lang['threadtype_infotypes_template_preview'].':</b></legend>';
echo $previewtemplate;
echo '</fieldset>';
}
?>
<input type="submit" class="btn" name="sortdetailsubmit" value="<?=$lang['submit']?>"> <input type="submit" class="btn" name="sortpreviewsubmit" value="<?=$lang['threadtype_infotypes_template_preview']?>">
</div>
</form>
<script type="text/JavaScript">
var optionids = new Array();
<?=$jsoptionids?>
function insertvar(text) {
$('typetemplate').focus();
selection = document.selection;
if(selection && selection.createRange) {
var sel = selection.createRange();
sel.text = '<li><b>{' + text + '}</b>: [' + text + "value]</li>\r\n";
sel.moveStart('character', -strlen(text));
} else {
$('typetemplate').value += '<li><b>{' + text + '}<b>: [' + text + "value]</li>\r\n";
}
}
function checkedbox() {
var tags = $('optionlist').getElementsByTagName('input');
for(var i=0; i<tags.length; i++) {
if(in_array(tags[i].value, optionids)) {
tags[i].checked = true;
}
}
}
function insertoption(optionid) {
var x = new Ajax();
x.optionid = optionid;
x.get('<?=$BASESCRIPT?>?action=threadtypes&operation=sortlist&inajax=1&optionid=' + optionid, function(s, x) {
if(!in_array(x.optionid, optionids)) {
var div = document.createElement('div');
div.style.display = 'none';
$('append_parent').appendChild(div);
div.innerHTML = '<table>' + s + '</table>';
var tr = div.getElementsByTagName('tr');
var trs = $('sortlist').getElementsByTagName('tr');
tr[0].id = 'optionid' + optionid;
trs[trs.length - 1].parentNode.appendChild(tr[0]);
$('append_parent').removeChild(div);
optionids.push(x.optionid);
} else {
$('optionid' + x.optionid).parentNode.removeChild($('optionid' + x.optionid));
for(var i=0; i<optionids.length; i++) {
if(optionids[i] == x.optionid) {
optionids[i] = 0;
}
}
}
});
}
</script>
<script type="text/JavaScript">ajaxget('<?=$BASESCRIPT?>?action=threadtypes&operation=classlist', 'classlist');</script>
<script type="text/JavaScript">ajaxget('<?=$BASESCRIPT?>?action=threadtypes&operation=optionlist&sortid=<?=$sortid?>', 'optionlist', '', '', '', checkedbox);</script>
<?
} else {
$db->query("UPDATE {$tablepre}threadtypes SET special='1', modelid='".intval($modelid)."', template='$typetemplate', expiration='$typeexpiration' WHERE typeid='$sortid'");
if(submitcheck('sortdetailsubmit')) {
$orgoption = $orgoptions = $addoption = array();
$query = $db->query("SELECT optionid FROM {$tablepre}typevars WHERE sortid='$sortid'");
while($orgoption = $db->fetch_array($query)) {
$orgoptions[] = $orgoption['optionid'];
}
if(intval($modelid)) {
$modelopt = $db->fetch_first("SELECT options, customoptions FROM {$tablepre}typemodels WHERE id='$modelid'");
if($modelopt['customoptions']) {
foreach(explode("\t", $modelopt['customoptions']) as $id) {
$addoption[$id] = $required[$id] = 0;
$available[$id] = 1;
}
}
if($modelopt['options']) {
foreach(explode("\t", $modelopt['options']) as $id) {
$addoption[$id] = $available[$id] = $required[$id] = 1;
}
}
}
$addoption = $addoption ? (array)$addoption + (array)$displayorder : (array)$displayorder;
@$newoptions = array_keys($addoption);
if(empty($addoption)) {
cpmsg('threadtype_infotypes_invalid', '', 'error');
}
@$delete = array_merge((array)$delete, array_diff($orgoptions, $newoptions));
if($delete) {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typevars WHERE sortid='$sortid' AND optionid IN ($ids)");
}
foreach($delete as $id) {
unset($addoption[$id]);
}
}
if(is_array($addoption)) {
foreach($addoption as $id => $val) {
$optionid = $db->fetch_first("SELECT optionid FROM {$tablepre}typeoptions WHERE optionid='$id'");
if($optionid) {
$db->query("INSERT INTO {$tablepre}typevars (sortid, optionid, available, required) VALUES ('$sortid', '$id', '1', '".intval($val)."')", 'SILENT');
$db->query("UPDATE {$tablepre}typevars SET displayorder='$displayorder[$id]', available='$available[$id]', required='$required[$id]', unchangeable='$unchangeable[$id]', search='$search[$id]' WHERE sortid='$sortid' AND optionid='$id'");
} else {
$db->query("DELETE FROM {$tablepre}typevars WHERE sortid='$sortid' AND optionid IN ($id)");
}
}
}
updatecache('threadsorts');
cpmsg('threadtype_infotypes_succeed', $BASESCRIPT.'?action=threadtypes&operation=sortdetail&sortid='.$sortid, 'succeed');
} elseif(submitcheck('sortpreviewsubmit')) {
header("Location: $boardurl$BASESCRIPT?action=threadtypes&operation=sortdetail&sortid=$sortid#template");
}
}
} elseif($operation == 'typemodel') {
if(!submitcheck('modelsubmit')) {
$typemodels = '';
$query = $db->query("SELECT * FROM {$tablepre}typemodels ORDER BY displayorder");
while($model = $db->fetch_array($query)) {
$typemodels .= showtablerow('', array('class="td25"', 'class="td28 td23"', 'class="td24"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$model[id]\" ".($model['type'] ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"displayorder[$model[id]]\" value=\"$model[displayorder]\">",
"<input type=\"text\" class=\"txt\" name=\"name[$model[id]]\" value=\"$model[name]\">",
"<a href=\"$BASESCRIPT?action=threadtypes&operation=modeldetail&modelid=$model[id]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1, '', 'td25'],
[1, '<input type="text" class="txt" size="10" name="newdisplayorder[]">', 'td28 td23'],
[1, '<input type="text" class="txt" name="newtitle[]">', 'td24'],
[1, '']
],
];
</script>
EOT;
shownav('forum', 'threadtype_models');
showsubmenu('threadtype_models', '');
showformheader('threadtypes&operation=typemodel');
showtableheader();
showsubtitle(array('', 'display_order', 'name', ''));
echo $typemodels;
echo '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['threadtype_infotypes_add_model'].'</a></div></td></tr>';
showsubmit('modelsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}typemodels WHERE id IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}typemodels SET displayorder='$displayorder[$id]', name='$name[$id]' WHERE id='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $key => $value) {
if($value) {
$db->query("INSERT INTO {$tablepre}typemodels (name, displayorder, type)
VALUES ('$value', '$newdisplayorder[$key]', '0')");
}
}
}
cpmsg('threadtype_infotypes_model_succeed', $BASESCRIPT.'?action=threadtypes&operation=typemodel', 'succeed');
}
} elseif($operation == 'modeldetail') {
if(!submitcheck('modeldetailsubmit')) {
$classoptions = $modeloption = $sysoption = $sysoptselect = '';
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid!='0' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$classoptions .= "<option value=\"$option[optionid]\">$option[title]</option>";
}
$model = $db->fetch_first("SELECT * FROM {$tablepre}typemodels WHERE id='".intval($modelid)."'");
if(!$model) {
cpmsg('undefined_action', '', 'error');
}
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN (".implodeids(explode("\t", $model['customoptions'])).")");
while($modelopt = $db->fetch_array($query)){
$modeloption .= "<option value=\"$modelopt[optionid]\">$modelopt[title]</option>";
}
if($model['type']) {
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE optionid IN (".implodeids(explode("\t", $model['options'])).")");
while($modelopt = $db->fetch_array($query)){
$sysoption .= "<option value=\"$modelopt[optionid]\">$modelopt[title]</option>";
}
$sysoptselect = '<select name="" size="10" multiple="multiple">'.$sysoption.'</select>';
}
$optselect = '<select name="" size="10" multiple="multiple" id="coptselect">'.$classoptions.'</select>';
$hoptselect = '<select name="customoptions[]" size="10" multiple="multiple" id="moptselect">'.$modeloption.'</select>';
echo <<<EOT
<script type="text/JavaScript">
function copyoption(s1, s2) {
var s1 = $(s1);
var s2 = $(s2);
var len = s1.options.length;
for(var i=0; i<len; i++) {
op = s1.options[i];
if(op.selected == true && !optionexists(s2, op.value)) {
o = op.cloneNode(true);
s2.appendChild(o);
}
}
}
function optionexists(s1, value) {
var len = s1.options.length;
for(var i=0; i<len; i++) {
if(s1.options[i].value == value) {
return true;
}
}
return false;
}
function removeoption(s1) {
var s1 = $(s1);
var len = s1.options.length;
for(var i=s1.options.length - 1; i>-1; i--) {
op = s1.options[i];
if(op.selected && op.selected == true) {
s1.removeChild(op);
}
}
return false;
}
function selectalloption(s1) {
var s1 = $(s1);
var len = s1.options.length;
for(var i=s1.options.length - 1; i>-1; i--) {
op = s1.options[i];
op.selected = true;
}
}
</script>
EOT;
showsubmenu('threadtype_models_option_setting');
showformheader("threadtypes&operation=modeldetail&modelid=$modelid", 'onsubmit="selectalloption(\'moptselect\');"');
showtableheader();
showsetting('name', 'namenew', $model['name'], 'text');
if($model['type']) {
showsetting('threadtype_models_option_model', '', '', $sysoptselect);
}
showsetting('threadtype_models_option_user', '', '', $hoptselect.'<br /><a href="###" onclick="removeoption(\'moptselect\')">['.$lang['del'].']</a>');
showsetting('threadtype_models_option_system', '', '', $optselect.'<br /><a href="###" onclick="copyoption(\'coptselect\', \'moptselect\')">['.$lang['threadtype_models_option_copy'].']</a>');
showsubmit('modeldetailsubmit');
showtablefooter();
showformfooter();
} else {
$customoptionsnew = $customoptions && is_array($customoptions) ? implode("\t", $customoptions) : '';
$db->query("UPDATE {$tablepre}typemodels SET name='$namenew', customoptions='$customoptionsnew' WHERE id='$modelid'");
cpmsg('threadtype_infotypes_model_succeed', $BASESCRIPT.'?action=threadtypes&operation=modeldetail&modelid='.$modelid, 'succeed');
}
} elseif($operation == 'classlist') {
$classoptions = '';
$classidarray = array();
!$classid && $classid = 0;
$query = $db->query("SELECT optionid, title FROM {$tablepre}typeoptions WHERE classid='$classid' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$classidarray[] = $option['optionid'];
$classoptions .= "<a href=\"#ol\" onclick=\"ajaxget('$BASESCRIPT?action=threadtypes&operation=optionlist&typeid=$typeid&classid=$option[optionid]', 'optionlist', 'optionlist', 'Loading...', '', checkedbox)\">$option[title]</a> ";
}
include template('header');
echo $classoptions;
include template('footer');
exit;
} elseif($operation == 'optionlist') {
if(!$classid) {
$classid = $db->result_first("SELECT optionid FROM {$tablepre}typeoptions WHERE classid='0' ORDER BY displayorder LIMIT 1");
}
$query = $db->query("SELECT optionid FROM {$tablepre}typevars WHERE sortid='$typeid'");
$option = $options = array();
while($option = $db->fetch_array($query)) {
$options[] = $option['optionid'];
}
$optionlist = '';
$query = $db->query("SELECT * FROM {$tablepre}typeoptions WHERE classid='$classid' ORDER BY displayorder");
while($option = $db->fetch_array($query)) {
$optionlist .= "<input ".(in_array($option['optionid'], $options) ? ' checked="checked" ' : '')."class=\"checkbox\" type=\"checkbox\" name=\"typeselect[]\" id=\"typeselect_$option[optionid]\" value=\"$option[optionid]\" onclick=\"insertoption(this.value);\" /><label for=\"typeselect_$option[optionid]\">".dhtmlspecialchars($option['title'])."</label> ";
}
include template('header');
echo $optionlist;
include template('footer');
exit;
} elseif($operation == 'sortlist') {
$option = $db->fetch_first("SELECT * FROM {$tablepre}typeoptions WHERE optionid='$optionid' LIMIT 1");
include template('header');
$option['type'] = $lang['threadtype_edit_vars_type_'. $option['type']];
$option['available'] = 1;
showtablerow('', array('class="td25"', 'class="td28 td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$option[optionid]\" ".($option['model'] ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$option[optionid]]\" value=\"$option[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$option[optionid]]\" value=\"1\" ".($option['available'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
dhtmlspecialchars($option['title']),
$option[type],
"<input class=\"checkbox\" type=\"checkbox\" name=\"required[$option[optionid]]\" value=\"1\" ".($option['required'] ? 'checked' : '')." ".($option['model'] ? 'disabled' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"unchangeable[$option[optionid]]\" value=\"1\" ".($option['unchangeable'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"search[$option[optionid]]\" value=\"1\" ".($option['search'] ? 'checked' : '').">",
"<a href=\"###\" onclick=\"insertvar('$option[identifier]');doane(event);return false;\" class=\"act\">".$lang['threadtype_infotypes_add_template']."</a>",
"<a href=\"$BASESCRIPT?action=threadtypes&operation=optiondetail&optionid=$option[optionid]\" class=\"act\">".$lang['edit']."</a>"
));
include template('footer');
exit;
}
function showoption($var, $type) {
global $optiontitle, $lang;
if($optiontitle[$var]) {
$optiontitle[$var] = $type == 'title' ? $optiontitle[$var] : $optiontitle[$var].$lang['value'];
return $optiontitle[$var];
} else {
return "!$var!";
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/threadtypes.inc.php
|
PHP
|
asf20
| 38,433
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: search.inc.php 17415 2008-12-19 04:34:58Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$actionarray = array(
'settings' => array(
'basic',
'access' => array('register', 'access'),
'styles' => array('global', 'index', 'forumdisplay', 'viewthread', 'member', 'refresh'),
'seo',
'cachethread',
'serveropti',
'editor',
'functions' => array('editor', 'stat', 'mod', 'tags', 'other'),
'permissions',
'credits',
'mail' => array('settings', 'check'),
'sec' => array('seclevel', 'seccode', 'secqaa'),
'datetime',
'attach' => array('basic', 'image', 'remote', 'antileech'),
'wap',
'ec',
'uc',
'uchome',
'msn'
),
'forums' => array(
'admin',
'edit' => array('basic', 'extend', 'posts', 'credits', 'threadtypes', 'threadsorts', 'perm'),
'moderators',
'delete',
'merge',
'copy'
),
'threadtypes' => array(),
'members' => array(
'clean',
'newsletter',
'reward',
'confermedal',
'add',
'group',
'access',
'credit',
'medal',
'edit',
'ipban',
'ban'
),
'profilefields' => array(
'admin',
'edit'
),
'admingroups' => array(
'admin',
'edit'
),
'usergroups' => array(
'admin',
'edit' => array('basic', 'system', 'special', 'post', 'attach', 'magic', 'invite', 'credit'),
'viewsgroup'
),
'ranks' => array(),
'styles' => array(
'admin',
'edit',
'config',
'import'
),
'templates' => array(
'admin',
'add',
'edit'
),
'moderate' => array(
'members',
'threads',
'replies'
),
'threads' => array(),
'prune' => array(),
'recyclebin' => array('clean'),
'announce' => array(
'admin',
'add',
'edit'
),
'smilies' => array(),
'misc' => array(
'link',
'onlinelist',
'censor',
'bbcode',
'tag',
'icon',
'attachtype',
'cron',
'custommenu',
'customnav'
),
'faq' => array(),
'adv' => array(
'admin',
'add',
'edit'
),
'db' => array(
'runquery',
'optimize',
'export',
'import'
),
'extended' => array(
'tag'
),
'tasks' => array(
'add',
'edit',
'type'
),
'tools' => array(
'updatecache',
'fileperms'
),
'attach' => array(),
'counter' => array(),
'jswizard' => array('admin', 'config', 'import'),
'creditwizard' => array(),
'google' => array(),
'qihoo' => array(
'config',
'topics'
),
'video' => array(),
'ec' => array(
'alipay',
'credit',
'orders'
),
'tradelog' => array(),
'medals' => array(),
'magics' => array('config', 'admin', 'market'),
'plugins' => array(
'config',
'edit',
'hooks',
'vars'
),
'logs' => array(
'illegal',
'rate',
'credit',
'mod',
'ban',
'cp',
'error',
'invite',
'magic',
'medal'
)
);
$keywords = trim($keywords);
$results = array();
$kws = explode(' ', $keywords);
$kws = array_map('trim', $kws);
$keywords = implode(' ', $kws);
if($searchsubmit && $keywords) {
foreach($lang as $key => $value) {
$matched = TRUE;
foreach($kws as $kw) {
if(strpos(strtolower($value), strtolower($kw)) === FALSE) {
$matched = FALSE;
break;
}
}
if($matched) {
$tmp = explode('_', $key);
if(isset($actionarray[$tmp[0]])) {
$url = $BASESCRIPT.'?action='.$tmp[0];
$vname = $tmp[0];
$subject = '<a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
if(is_array($actionarray[$tmp[0]][$tmp[1]])) {
$url .= '&operation='.$tmp[1];
$vname .= '_'.$tmp[1];
$subject .= ' » <a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
if(in_array($tmp[2], $actionarray[$tmp[0]][$tmp[1]])) {
$url .= '&anchor='.$tmp[2];
$vname .= '_'.$tmp[2];
$subject .= ' » <a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
}
} else {
if(in_array($tmp[1], $actionarray[$tmp[0]])) {
$url .= '&operation='.$tmp[1];
$vname .= '_'.$tmp[1];
$subject .= ' » <a href="'.$url.'&highlight='.urlencode($keywords).'" target="_blank"><u>'.lang($vname).'</u></a>';
}
}
if(isset($results[$url])) {
$results[$url]['message'] .= '<br />'.$value;
} else {
$results[$url] = array('subject' => $subject, 'message' => $value);
}
}
}
}
if($results) {
showsubmenu('search_result');
foreach($results as $result) {
echo '<div class="news"><h3>'.$result[subject].'</h3><p class="lineheight">'.strip_tags($result[message], '<br>').'</p></div>';
}
echo <<<EOT
<script type="text/JavaScript">
function parsetag(tag) {
var str = $('cpcontainer').innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {
if(tag && $3.indexOf(tag) != -1) {
$3 = $3.replace(tag, '<h_>');
}
return $2 + $3;
});
$('cpcontainer').innerHTML = str.replace(/<h_>/ig, function($1, $2) {
return '<font color="#c60a00">' + tag + '</font>';
});
}
EOT;
foreach($kws as $kw) {
echo 'parsetag(\''.$kw.'\');';
}
echo '</script>';
} else {
cpmsg('search_result_noexists');
}
} else {
cpmsg('search_keyword_noexists', '', 'error');
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/search.inc.php
|
PHP
|
asf20
| 5,480
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: medals.inc.php 16761 2008-11-18 06:17:17Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(!submitcheck('medalsubmit')) {
shownav('extended', 'nav_medals', 'admin');
showsubmenu('nav_medals', array(
array('admin', 'medals', 1),
array('nav_medals_confer', 'members&operation=confermedal', 0),
array('nav_medals_mod', 'medals&operation=mod', 0)
));
showtips('medals_tips');
showformheader('medals');
showtableheader();
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
'',
lang('display_order'),
'',
lang('available'),
lang('name'),
lang('description'),
lang('medals_image'),
lang('medals_type'),
'',
));
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'', 'td25'],
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newname[]" size="10">'],
[1,'<input type="text" class="txt" name="newdescription[]" size="30">'],
[1,'<input type="text" class="txt" name="newimage[]" size="20">'],
[1,'', 'td23'],
[1,'', 'td25']
]
];
</script>
<?
$query = $db->query("SELECT * FROM {$tablepre}medals ORDER BY displayorder");
while($medal = $db->fetch_array($query)) {
$checkavailable = $medal['available'] ? 'checked' : '';
$medal['type'] = $medal['type'] == 1 ? lang('medals_register') : lang('medals_adminadd');
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"', 'class="td25"', '', '', '', 'class="td23"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$medal[medalid]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$medal[medalid]]\" value=\"$medal[displayorder]\">",
"<img src=\"images/common/$medal[image]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"available[$medal[medalid]]\" value=\"1\" $checkavailable>",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"name[$medal[medalid]]\" value=\"$medal[name]\">",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"description[$medal[medalid]]\" value=\"$medal[description]\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"image[$medal[medalid]]\" value=\"$medal[image]\">",
$medal[type],
"<a href=\"$BASESCRIPT?action=medals&operation=edit&medalid=$medal[medalid]\" class=\"act\">$lang[detail]</a>"
));
}
echo '<tr><td></td><td colspan="8"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['medals_addnew'].'</a></div></td></tr>';
showsubmit('medalsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}medals WHERE medalid IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}medals SET name=".($name[$id] ? '\''.dhtmlspecialchars($name[$id]).'\'' : 'name').", available='$available[$id]', description=".($description[$id] ? '\''.dhtmlspecialchars($description[$id]).'\'' : 'name').", displayorder='".intval($displayorder[$id])."', image=".($image[$id] ? '\''.$image[$id].'\'' : 'image')." WHERE medalid='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
if($value != '' && $newimage[$key] != '') {
$db->query("INSERT INTO {$tablepre}medals (name, available, image, displayorder, description) VALUES ('".dhtmlspecialchars($value)."', '$newavailable[$key]', '$newimage[$key]', '".intval($newdisplayorder[$key])."', '".dhtmlspecialchars($newdescription[$key])."')");
}
}
}
updatecache('settings');
updatecache('medals');
cpmsg('medals_succeed', $BASESCRIPT.'?action=medals', 'succeed');
}
} elseif($operation == 'mod') {
if(submitcheck('delmedalsubmit')) {
if (is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$query = $db->query("UPDATE {$tablepre}medallog SET type='3' WHERE id IN ($ids)");
cpmsg('medals_invalidate_succeed', $BASESCRIPT.'?action=medals&operation=mod', 'succeed');
} else {
cpmsg('medals_please_input', $BASESCRIPT.'?action=medals&operation=mod', 'error');
}
} elseif(submitcheck('modmedalsubmit')) {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$query = $db->query("SELECT me.id, me.uid, me.medalid, me.dateline, me.expiration, mf.medals
FROM {$tablepre}medallog me
LEFT JOIN {$tablepre}memberfields mf USING (uid)
WHERE id IN ($ids)");
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
while($modmedal = $db->fetch_array($query)) {
$modmedal['medals'] = empty($medalsnew[$modmedal['uid']]) ? $modmedal['medals'] : $medalsnew[$modmedal['uid']];
foreach($modmedal['medals'] = explode("\t", $modmedal['medals']) as $key => $modmedalid) {
list($medalid, $medalexpiration) = explode("|", $modmedalid);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$medalsnew[$modmedal['uid']][$key] = $modmedalid;
}
}
$medalstatus = empty($modmedal['expiration']) ? 0 : 1;
$modmedal['expiration'] = $modmedal['expiration'] ? ($timestamp + $modmedal['expiration'] - $modmedal['dateline']) : '';
$medalsnew[$modmedal['uid']][] = $modmedal['medalid'].(empty($modmedal['expiration']) ? '' : '|'.$modmedal['expiration']);
$db->query("UPDATE {$tablepre}medallog SET type=1, status='$medalstatus', expiration='$modmedal[expiration]' WHERE id='$modmedal[id]'");
}
foreach ($medalsnew as $key => $medalnew) {
$medalnew = implode("\t", $medalnew);
$db->query("UPDATE {$tablepre}memberfields SET medals='$medalnew' WHERE uid='$key'");
}
cpmsg('medals_validate_succeed', $BASESCRIPT.'?action=medals&operation=mod', 'succeed');
} else {
cpmsg('medals_please_input', $BASESCRIPT.'?action=medals&operation=mod', 'error');
}
} else {
$medals = '';
$query = $db->query("SELECT mel.*, m.username, me.name FROM {$tablepre}medallog mel
LEFT JOIN {$tablepre}medals me ON me.medalid = mel.medalid
LEFT JOIN {$tablepre}members m ON m.uid = mel.uid
WHERE mel.type=2 ORDER BY dateline");
while($medal = $db->fetch_array($query)) {
$medal['dateline'] = gmdate('Y-m-d H:i', $medal['dateline'] + $timeoffset * 3600);
$medal['expiration'] = empty($medal['expiration']) ? $lang['medals_forever'] : gmdate('Y-m-d H:i', $medal['expiration'] + $timeoffset * 3600);
$medals .= showtablerow('', '', array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$medal[id]\">",
"<a href=\"space.php?username=".rawurlencode($medal['username'])."\" target=\"_blank\">$medal[username]</a>",
$medal['name'],
$medal['dateline'],
$medal['expiration']
), TRUE);
}
shownav('extended', 'nav_medals', 'nav_medals_mod');
showsubmenu('nav_medals', array(
array('admin', 'medals', 0),
array('nav_medals_confer', 'members&operation=confermedal', 0),
array('nav_medals_mod', 'medals&operation=mod', 1)
));
showformheader('medals&operation=mod');
showtableheader('medals_mod');
showtablerow('', '', array(
'',
lang('medals_user'),
lang('medals_name'),
lang('medals_date'),
lang('medals_expr'),
));
echo $medals;
showsubmit('modmedalsubmit', 'medals_modpass', 'select_all', '<input type="submit" class="btn" value="'.lang('medals_modnopass').'" name="delmedalsubmit"> ');
showtablefooter();
showformfooter();
}
} elseif($operation == 'edit') {
$medalid = intval($medalid);
if(!submitcheck('medaleditsubmit')) {
$medal = $db->fetch_first("SELECT * FROM {$tablepre}medals WHERE medalid='$medalid'");
$medal['permission'] = unserialize($medal['permission']);$medal['permission'] = $medal['permission'][0];
$checkmedaltype = array($medal['type'] => 'checked');
shownav('extended', 'nav_medals', 'admin');
showsubmenu('nav_medals', array(
array('admin', 'medals', 1),
array('nav_medals_confer', 'members&operation=confermedal', 0),
array('nav_medals_mod', 'medals&operation=mod', 0)
));
showformheader("medals&operation=edit&medalid=$medalid");
showtableheader(lang('medals_edit').' - '.$medal['name'], 'nobottom');
showsetting('medals_name1', 'namenew', $medal['name'], 'text');
showsetting('medals_img', '', '', '<input type="text" class="txt" size="30" name="imagenew" value="'.$medal['image'].'" ><img src="images/common/'.$medal['image'].'">');
showsetting('medals_type1', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($checkmedaltype[0] ? ' class="checked"' : '').'><input name="typenew" type="radio" class="radio" value="0" '.$checkmedaltype[0].'> '.$lang['medals_adminadd'].'</li>
<li'.($checkmedaltype[1] ? ' class="checked"' : '').'><input name="typenew" type="radio" class="radio" value="1" '.$checkmedaltype[1].'> '.$lang['medals_register'].'</li></ul>'
);
showsetting('medals_expr1', 'expirationnew', $medal['expiration'], 'text');
showsetting('medals_memo', 'descriptionnew', $medal['description'], 'text');
showtablefooter();
showtableheader('medals_perm', 'notop');
$formulareplace .= '\'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\',\'<u>'.$lang['settings_credits_formula_posts'].'</u>\',\'<u>'.$lang['settings_credits_formula_oltime'].'</u>\',\'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\'';
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, textend) {
$('formulapermnew').focus();
textend = isUndefined(textend) ? '' : textend;
if(!isUndefined($('formulapermnew').selectionStart)) {
var opn = $('formulapermnew').selectionStart + 0;
if(textend != '') {
text = text + $('formulapermnew').value.substring($('formulapermnew').selectionStart, $('formulapermnew').selectionEnd) + textend;
}
$('formulapermnew').value = $('formulapermnew').value.substr(0, $('formulapermnew').selectionStart) + text + $('formulapermnew').value.substr($('formulapermnew').selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$('formulapermnew').value += text;
}
formulaexp();
}
var formulafind = new Array('digestposts', 'posts', 'oltime', 'pageviews');
var formulareplace = new Array(<?=$formulareplace?>);
function formulaexp() {
var result = $('formulapermnew').value;
<?
$extcreditsbtn = '';
for($i = 1; $i <= 8; $i++) {
$extcredittitle = $extcredits[$i]['title'] ? $extcredits[$i]['title'] : $lang['settings_credits_formula_extcredits'].$i;
echo 'result = result.replace(/extcredits'.$i.'/g, \'<u>'.$extcredittitle.'</u>\');';
$extcreditsbtn .= '<a href="###" onclick="insertunit(\'extcredits'.$i.'\')">'.$extcredittitle.'</a> ';
}
echo 'result = result.replace(/digestposts/g, \'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\');';
echo 'result = result.replace(/posts/g, \'<u>'.$lang['settings_credits_formula_posts'].'</u>\');';
echo 'result = result.replace(/oltime/g, \'<u>'.$lang['settings_credits_formula_oltime'].'</u>\');';
echo 'result = result.replace(/pageviews/g, \'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\');';
echo 'result = result.replace(/and/g, \' '.$lang['settings_formulaperm_and'].' \');';
echo 'result = result.replace(/or/g, \' '.$lang['settings_formulaperm_or'].' \');';
echo 'result = result.replace(/>=/g, \'≥\');';
echo 'result = result.replace(/<=/g, \'≤\');';
?>
$('formulapermexp').innerHTML = result;
}
</script>
<tr><td colspan="2"><div class="extcredits">
<?=$extcreditsbtn?><br />
<a href="###" onclick="insertunit(' digestposts ')"><?=$lang['settings_credits_formula_digestposts']?></a>
<a href="###" onclick="insertunit(' posts ')"><?=$lang['settings_credits_formula_posts']?></a>
<a href="###" onclick="insertunit(' oltime ')"><?=$lang['settings_credits_formula_oltime']?></a>
<a href="###" onclick="insertunit(' pageviews ')"><?=$lang['settings_credits_formula_pageviews']?></a>
<a href="###" onclick="insertunit(' + ')"> + </a>
<a href="###" onclick="insertunit(' - ')"> - </a>
<a href="###" onclick="insertunit(' * ')"> * </a>
<a href="###" onclick="insertunit(' / ')"> / </a>
<a href="###" onclick="insertunit(' > ')"> > </a>
<a href="###" onclick="insertunit(' >= ')"> >= </a>
<a href="###" onclick="insertunit(' < ')"> < </a>
<a href="###" onclick="insertunit(' <= ')"> <= </a>
<a href="###" onclick="insertunit(' = ')"> = </a>
<a href="###" onclick="insertunit(' (', ') ')"> ( ) </a>
<a href="###" onclick="insertunit(' and ')"> <?=$lang['settings_credits_formulaperm_and']?> </a>
<a href="###" onclick="insertunit(' or ')"> <?=$lang['settings_credits_formulaperm_or']?> </a> <br />
</div><div id="formulapermexp" class="marginbot diffcolor2"><?=$formulapermexp?></div>
<textarea name="formulapermnew" id="formulapermnew" style="width: 80%" rows="3" onkeyup="formulaexp()"><?=dhtmlspecialchars($medal['permission'])?></textarea>
<br /><span class="smalltxt"><?=$lang['medals_permformula']?></span>
<br /><?=$lang['creditwizard_current_formula_notice']?>
<script type="text/JavaScript">formulaexp()</script>
</td></tr>
<?
showsubmit('medaleditsubmit');
showtablefooter();
showformfooter();
} else {
if($formulapermnew && !preg_match("/^(\+|\-|\*|\/|\.|>|<|=|\d|\s|extcredits[1-8]|digestposts|posts|pageviews|oltime|and|or)+$/", $formulapermnew) || !is_null(@eval(preg_replace("/(digestposts|posts|pageviews|oltime|extcredits[1-8])/", "\$\\1", $formulapermnew).';'))) {
cpmsg('forums_formulaperm_error', '', 'error');
}
$formulapermary[0] = $formulapermnew;
$formulapermary[1] = preg_replace("/(digestposts|posts|pageviews|oltime|extcredits[1-8])/", "\$_DSESSION['\\1']", $formulapermnew);
$formulapermnew = addslashes(serialize($formulapermary));
$db->query("UPDATE {$tablepre}medals SET name=".($namenew ? '\''.dhtmlspecialchars($namenew).'\'' : 'name').", type='$typenew', description='".dhtmlspecialchars($descriptionnew)."', expiration='".intval($expirationnew)."', permission='$formulapermnew', image='$imagenew' WHERE medalid='$medalid'");
updatecache('medals');
cpmsg('medals_succeed', $BASESCRIPT.'?action=medals&do=editmedals', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/medals.inc.php
|
PHP
|
asf20
| 15,560
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: project.inc.php 17038 2008-12-04 04:41:29Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(!isfounder()) {
cpheader();
cpmsg('noaccess', '', 'error');
}
$query = $db->query("SELECT disabledactions FROM {$tablepre}adminactions WHERE admingid='$groupid'");
$dactionarray = ($dactionarray = unserialize($db->result($query, 0))) ? $dactionarray : array();
$allowforumsedit = !in_array('forums', $dactionarray) ? 1 : 0;
$allowusergroups = !in_array('groups_user', $dactionarray) ? 1 : 0;
$allowcreditwizard = !in_array('creditwizard', $dactionarray) ? 1 : 0;
if(empty($allowforumsedit) && empty($allowusergroups) && empty($allowcreditwizard)) {
cpheader();
cpmsg('action_noaccess', '', 'error');
}
if($operation == 'export' && $id) {
$projectarray = $db->fetch_first("SELECT * FROM {$tablepre}projects WHERE id='$id'");
if(!$projectarray) {
cpheader();
cpmsg('undefined_action', '', 'error');
}
if(($projectarray['type'] == 'forum' && empty($allowforumsedit)) || ($projectarray['type'] == 'group' && empty($allowusergroups)) || ($projectarray['type'] == 'extcredit' && empty($allowcreditwizard))) {
cpheader();
cpmsg('action_noaccess', '', 'error');
}
$projectarray['version'] = strip_tags($version);
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
$project_export = "# Discuz! Project Dump ($projectarray[type])\n".
"# Version: Discuz! $version\n".
"# Time: $time \n".
"# From: $bbname ($boardurl) \n".
"#\n".
"# Discuz! Community: http://www.Discuz.net\n".
"# Please visit our website for latest news about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
wordwrap(base64_encode(serialize($projectarray)), 60, "\n", 1);
ob_end_clean();
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
dheader('Cache-Control: no-cache, must-revalidate');
dheader('Pragma: no-cache');
dheader('Content-Encoding: none');
dheader('Content-Length: '.strlen($project_export));
dheader('Content-Disposition: attachment; filename=discuz_project_'.$projectarray['type'].'_'.$projectarray['name'].'.txt');
dheader('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
echo $project_export;
dexit();
}
cpheader();
if(!$operation) {
if(!submitcheck('projectsubmit')) {
$listarray = array();
$projectlist = $typeadd = $selecttype = '';
$page = max(1, intval($page));
$start_limit = ($page - 1) * 10;
$allowaction = array(
'forum' => $allowforumsedit,
'group' => $allowusergroups,
'extcredit' => $allowcreditwizard,
);
if(!empty($type) && in_array($type, array('forum', 'group', 'extcredit'))) {
foreach($allowaction as $key => $val) {
if($type == $key && empty($val)) {
cpmsg('action_noaccess', '', 'error');
}
}
$typeadd = "WHERE type='$type'";
$selecttype = '&type='.$type;
} else {
$typeadd = $comma = '';
foreach($allowaction as $key => $val) {
if(!empty($val)) {
$typeadd .= $comma."'$key'";
$comma = ', ';
}
}
$typeadd = 'WHERE type IN ('.$typeadd.')';
}
$projectnum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}projects $typeadd");
$query = $db->query("SELECT id, name, type, description FROM {$tablepre}projects $typeadd LIMIT $start_limit, 10");
while($list = $db->fetch_array($query)) {
$list['name'] = dhtmlspecialchars($list['name']);
$list['description'] = dhtmlspecialchars($list['description']);
$projecttype = 'project_'.$list['type'].'_scheme';
$projectlist .= showtablerow('', array('class="td25"', 'class="td24"', 'class="td26"', 'class="td24"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$list[id]\">",
"<input type=\"text\" class=\"txtnobd\" onblur=\"this.className='txtnobd'\" onfocus=\"this.className='txt'\" size=\"15\" name=\"name[$list[id]]\" value=\"$list[name]\">",
"<input type=\"text\" class=\"txtnobd\" onblur=\"this.className='txtnobd'\" onfocus=\"this.className='txt'\" size=\"40\" name=\"description[$list[id]]\" value=\"$list[description]\">",
$lang[$projecttype],
"<a href=\"$BASESCRIPT?action=project&operation=export&id=$list[id]\" class=\"act\">".$lang['export']."</a> <a href=\"$BASESCRIPT?action=project&operation=apply&projectid=$list[id]&type=$list[type]\" class=\"act\">".$lang['apply']."</a>"
), TRUE);
}
$multipage = multi($projectnum, 10, $page, "$BASESCRIPT?action=project$selecttype");
shownav('tools', 'project_scheme');
showsubmenu('project_scheme', array(
$allowforumsedit ? array('project_forum_scheme', 'project&type=forum', $type == 'forum') : array(),
$allowusergroups ? array('project_group_scheme', 'project&type=group', $type == 'group') : array(),
$allowcreditwizard ? array('project_extcredit_scheme', 'project&type=extcredit', $type == 'extcredit') : array(),
array('project_import_stick', 'project&operation=import', $operation == 'import')
));
showformheader('project');
showtableheader();
showsubtitle(array('', 'name', 'description', 'type', ''));
echo $projectlist;
showsubmit('projectsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}projects WHERE id IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}projects SET name='$name[$id]', description='$description[$id]' WHERE id='$id'");
}
}
cpmsg('project_update_forum', $BASESCRIPT.'?action=project', 'succeed');
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit')) {
shownav('tools', 'project_scheme');
showsubmenu('project_scheme', array(
$allowforumsedit ? array('project_forum_scheme', 'project&type=forum', $type == 'forum') : array(),
$allowusergroups ? array('project_group_scheme', 'project&type=group', $type == 'group') : array(),
$allowcreditwizard ? array('project_extcredit_scheme', 'project&type=extcredit', $type == 'extcredit') : array(),
array('project_import_stick', 'project&operation=import', $operation == 'import')
));
showformheader('project&operation=import', 'enctype');
showtableheader('project_import_stick');
showimportdata();
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
$projectarray = getimportdata();
if(strip_tags($projectarray['version']) != strip_tags($version)) {
cpmsg('project_export_version_invalid', '', 'error');
} else {
$db->query("INSERT INTO {$tablepre}projects (name, type, description, value) VALUES ('$projectarray[name]', '$projectarray[type]', '$projectarray[description]', '$projectarray[value]')");
cpmsg('project_import_succeed', $BASESCRIPT.'?action=project', 'succeed');
}
}
} elseif($operation == 'add') {
$delfields = array(
'forum' => array('fid', 'fup', 'type', 'name', 'status', 'displayorder', 'threads', 'posts', 'todayposts', 'lastpost', 'description', 'password', 'icon', 'redirect', 'moderators', 'rules', 'threadtypes'),
'group' => array('groupid', 'radminid', 'type', 'system', 'grouptitle', 'creditshigher', 'creditslower', 'stars', 'color', 'groupavatar')
);
if(!submitcheck('addsubmit')) {
shownav('tools', 'project_scheme_add');
showsubmenu('project_scheme_add');
if(!empty($projectid)) {
$query = $db->query("SELECT name, description, value FROM {$tablepre}projects WHERE id='$projectid'");
$project = $db->fetch_array($query);
}
if(($type == 'forum' && empty($allowforumsedit)) || ($type == 'group' && empty($allowusergroups)) || ($type == 'extcredit' && empty($allowcreditwizard))) {
cpmsg('action_noaccess', '', 'error');
}
$allselected = 'selected';
if($type == 'forum' || $type == 'group') {
$listoption = '';
$fieldarray = $type == 'forum' ? array_merge(fetch_table_struct('forums'), fetch_table_struct('forumfields')) : fetch_table_struct('usergroups');
$listfields = array_diff($fieldarray, $delfields[$type]);
foreach($listfields as $field) {
$listoption .= '<option value="'.$field.'">'.$lang['project_option_'.$type.'_'.$field].'</option>';
}
} elseif($type == 'extcredit') {
$value = unserialize($project['value']);
$savemethod = $value['savemethod'];
$allselected = '';
$listoption = '<option value="1"'.(@in_array(1, $savemethod) ? ' selected': '').'>'.$lang['project_credits_item_config'].'</option>';
$listoption .= '<option value="2"'.(@in_array(2, $savemethod) ? ' selected': '').'>'.$lang['project_credits_rule_config'].'</option>';
$listoption .= '<option value="3"'.(@in_array(3, $savemethod) ? ' selected': '').'>'.$lang['project_credits_use_config'].'</option>';
}
showformheader("project&operation=add&id=$id");
showhiddenfields(array('projectid' => $projectid, 'type' => $type, 'detailsubmit' => 'submit'));
showtableheader();
showtitle('project_scheme_save');
if(!empty($projectid)) {
showsetting('project_scheme_cover', 'coverwith', '', 'radio');
}
showsetting('project_scheme_option', '', '', '<select name="fieldoption[]" size="10" multiple="multiple"><option value="all" '.$allselected.'>'.$lang['all'].'</option>'.$listoption.'</select>');
showsetting('project_scheme_title', 'name', $project['name'], 'text');
showsetting('project_scheme_description', 'description', $project['description'], 'textarea');
showsubmit('addsubmit');
showtablefooter();
} else {
$type = !empty($type) && in_array($type, array('forum', 'group', 'extcredit')) ? $type : '';
if(empty($name)) {
cpmsg('project_no_title', '', 'error');
}
if($type == 'forum') {
$value = $db->fetch_first("SELECT f.*, ff.* FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING (fid)
WHERE f.fid='$id'");
if(!$value) {
cpmsg('forums_nonexistence', '', 'error');
}
} elseif($type == 'group') {
$value = $db->fetch_first("SELECT * FROM {$tablepre}usergroups WHERE groupid='$id'");
if(!$value) {
cpmsg('project_no_usergroup', '', 'error');
}
} elseif($type == 'extcredit') {
if(empty($fieldoption)) {
cpmsg('project_no_item', '', 'error');
}
$delfields = array();
$fieldoption = in_array('all', $fieldoption) ? array(1, 2, 3) : $fieldoption;
$variables = in_array(1, $fieldoption) ? ", 'extcredits', 'creditspolicy'" : '';
$variables .= in_array(2, $fieldoption) ? ", 'creditsformula'" : '';
$variables .= in_array(3, $fieldoption) ? ", 'creditstrans', 'creditstax', 'transfermincredits', 'exchangemincredits', 'maxincperthread', 'maxchargespan'" : '';
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN (''$variables)");
$value['savemethod'] = $fieldoption;
while($data = $db->fetch_array($query)) {
$value[$data['variable']] = $data['value'];
}
}
if($type == 'forum' || $type == 'group') {
if(in_array('all', $fieldoption)) {
foreach($delfields[$type] as $field) {
unset($value[$field]);
}
} else {
$selectlist = '';
foreach($value as $key => $val) {
if(in_array($key, $fieldoption)) {
$selectlist[$key] .= $val;
}
}
$value = $selectlist;
}
}
$value = !empty($value) ? addslashes(serialize($value)) : '';
if(!empty($projectid) && !empty($coverwith)) {
$db->query("UPDATE {$tablepre}projects SET name='$name', description='$description', value='$value' WHERE id='$projectid'");
} else {
$db->query("INSERT INTO {$tablepre}projects (name, type, description, value) VALUES ('$name', '$type', '$description', '$value')");
}
if($type == 'forum') {
cpmsg('project_sava_succeed', $BASESCRIPT.'?action=forums&operation=edit&fid='.$id, 'succeed');
} elseif($type == 'group') {
cpmsg('project_sava_succeed', $BASESCRIPT.'?action=usergroups&operation=edit&id='.$id, 'succeed');
} elseif($type == 'extcredit') {
cpmsg('project_sava_succeed', $BASESCRIPT.'?action=settings&operation=credits', 'succeed');
}
}
} elseif($operation == 'apply') {
$type = !empty($type) && in_array($type, array('forum', 'group', 'extcredit')) ? $type : 'forum';
if(($type == 'forum' && empty($allowforumsedit)) || ($type == 'group' && empty($allowusergroups)) || ($type == 'extcredit' && empty($allowcreditwizard))) {
cpmsg('action_noaccess', '', 'error');
}
$projectselect = "<select name=\"projectid\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name, type FROM {$tablepre}projects WHERE type='$type'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>\n";
}
$projectselect .= '</select>';
if(!submitcheck('applysubmit')) {
if($type == 'forum') {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="target[]" size="10" multiple="multiple">'.forumselect().'</select>';
} elseif($type == 'group') {
$groupselect = '<select name="target[]" size="10" multiple="multiple">';
$query = $db->query("SELECT groupid, type, grouptitle, creditshigher, creditslower, stars, color, groupavatar FROM {$tablepre}usergroups ORDER BY creditshigher");
while($group = $db->fetch_array($query)) {
$groupselect .= '<option value="'.$group['groupid'].'">'.$group['grouptitle'].'</option>';
}
$groupselect .= '</select>';
} elseif($type == 'extcredit') {
dheader("location: $BASESCRIPT?action=settings&operation=credits&projectid=$projectid");
}
shownav('tools', 'project_scheme');
showsubmenu('project_global_forum');
showformheader("project&operation=apply&projectid=$projectid");
showtableheader();
showtitle($type == 'forum' ? 'project_scheme_forum' : 'project_group_scheme');
showsetting('project_scheme_name', '', '', $projectselect);
if($type == 'forum') {
showsetting('forums_copy_target', '', '', $forumselect);
} elseif($type == 'group') {
showsetting('project_target_usergroup', '', '', $groupselect);
}
showsubmit('applysubmit');
showtablefooter();
showformfooter();
} else {
if(empty($target)) {
cpmsg('project_target_item_invalid', '', 'error');
}
$applyids = implodeids($target);
$project = $db->fetch_first("SELECT type, value FROM {$tablepre}projects WHERE id='$projectid'");
if(!$project) {
cpmsg('project_no_scheme', '', 'error');
}
if(!$value = unserialize($project['value'])) {
cpmsg('project_invalid', '', 'error');
}
if($project['type'] == 'forum') {
$table_forum_columns = array('styleid', 'allowsmilies', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowanonymous', 'allowshare', 'allowpostspecial', 'alloweditrules', 'alloweditpost', 'allowspecialonly', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'autoclose', 'simple');
$table_forumfield_columns = array('attachextensions', 'postcredits', 'replycredits', 'digestcredits', 'postattachcredits', 'getattachcredits', 'viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm', 'modrecommend', 'formulaperm');
$updatesql = $comma = '';
foreach($table_forum_columns as $field) {
if(isset($value[$field])) {
$updatesql .= "$comma$field='".addslashes($value[$field])."'";
$comma = ', ';
}
}
if($updatesql && $applyids) {
$db->query("UPDATE {$tablepre}forums SET $updatesql WHERE fid IN ($applyids)");
}
$updatesql = $comma = '';
foreach($table_forumfield_columns as $field) {
if(isset($value[$field])) {
$updatesql .= "$comma$field='".addslashes($value[$field])."'";
$comma = ', ';
}
}
if($updatesql && $applyids) {
$db->query("UPDATE {$tablepre}forumfields SET $updatesql WHERE fid IN ($applyids)");
}
} elseif($project['type'] == 'group') {
$usergroup_columns = array('readaccess', 'allowvisit', 'allowpost', 'allowreply', 'allowpostpoll', 'allowpostreward', 'allowposttrade', 'allowpostactivity', 'allowpostvideo', 'allowdirectpost', 'allowgetattach', 'allowpostattach', 'allowvote', 'allowmultigroups', 'allowsearch', 'allowcstatus', 'allowinvisible', 'allowtransfer', 'allowsetreadperm', 'allowsetattachperm', 'allowhidecode', 'allowhtml', 'allowcusbbcode', 'allowanonymous', 'allownickname', 'allowsigbbcode', 'allowsigimgcode', 'allowviewpro', 'allowviewstats', 'disableperiodctrl', 'reasonpm', 'maxprice', 'maxsigsize', 'maxattachsize', 'maxsizeperday', 'maxpostsperhour', 'attachextensions', 'raterange', 'mintradeprice', 'maxtradeprice', 'minrewardprice', 'maxrewardprice', 'magicsdiscount', 'allowmagics', 'maxmagicsweight', 'allowbiobbcode', 'allowbioimgcode', 'maxbiosize', 'allowinvite', 'allowmailinvite', 'inviteprice', 'maxinvitenum', 'maxinviteday', 'allowpostdebate', 'tradestick', 'exempt');
$updatesql = $comma = '';
foreach($usergroup_columns as $field) {
if(isset($value[$field])) {
$updatesql .= "$comma$field='".addslashes($value[$field])."'";
$comma = ', ';
}
}
if($updatesql && $applyids) {
$db->query("UPDATE {$tablepre}usergroups SET $updatesql WHERE groupid IN ($applyids)");
}
}
cpmsg('project_scheme_succeed', '', 'succeed');
}
}
function fetch_table_struct($tablename, $result = 'FIELD') {
global $db, $tablepre;
$datas = array();
$query = $db->query("DESCRIBE $tablepre$tablename");
while($data = $db->fetch_array($query)) {
$datas[$data['Field']] = $result == 'FIELD' ? $data['Field'] : $data;
}
return $datas;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/project.inc.php
|
PHP
|
asf20
| 18,294
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tasks.inc.php 17396 2008-12-17 07:41:20Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$membervars = array('act', 'num', 'time');
$postvars = array('act', 'forumid', 'num', 'time', 'threadid', 'authorid');
$modvars = array();
$sys_scripts = array('member', 'post', 'mod');
$sys_types = array('member' => array('name' => lang('nav_task_member'), 'version' => '1.0'), 'post' => array('name' => lang('nav_task_post'), 'version' => '1.0'));
$custom_types = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='tasktypes'");
$custom_types = $custom_types ? unserialize($custom_types) : array();
$custom_scripts = array_keys($custom_types);
$submenus = array();
foreach(array_merge($sys_types, $custom_types) as $k => $v) {
$submenus[] = array($v['name'], "tasks&operation=add&script=$k");
}
if(!($operation)) {
if(!submitcheck('tasksubmit')) {
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 1),
array(array('menu' => 'add', 'submenu' => $submenus), '', 0),
array('nav_task_type', 'tasks&operation=type', 0)
));
showtips('tasks_tips');
showformheader('tasks');
showtableheader('config', 'fixpadding');
showsetting('tasks_on', 'taskonnew', $taskon, 'radio');
showtablefooter();
showtableheader('admin', 'fixpadding');
showsubtitle(array('name', 'available', 'settings_access_access_newbietask', 'display_order', 'type', 'tasks_reward', 'time', ''));
$starttasks = array();
$query = $db->query("SELECT * FROM {$tablepre}tasks ORDER BY displayorder, taskid DESC");
while($task = $db->fetch_array($query)) {
if($task['reward'] == 'credit') {
$reward = lang('credits').' '.$extcredits[$task['prize']]['title'].' '.$task['bonus'].' '.$extcredits[$task['prize']]['unit'];
} elseif($task['reward'] == 'magic') {
$magicname = $db->result_first("SELECT name FROM {$tablepre}magics WHERE magicid='$task[prize]'");
$reward = lang('tasks_reward_magic').' '.$magicname.' '.$task['bonus'];
} elseif($task['reward'] == 'medal') {
$medalname = $db->result_first("SELECT name FROM {$tablepre}medals WHERE medalid='$task[prize]'");
$reward = lang('medals').' '.$medalname.($task['bonus'] ? ' '.lang('validity').$task['bonus'].' '.lang('days') : '');
} elseif($task['reward'] == 'invite') {
$reward = lang('tasks_reward_invite').' '.$task['prize'].($task['bonus'] ? ' '.lang('validity').$task['bonus'].' '.lang('days') : '');
} elseif($task['reward'] == 'group') {
$grouptitle = $db->result_first("SELECT grouptitle FROM {$tablepre}usergroups WHERE groupid='$task[prize]'");
$reward = lang('usergroup').' '.$grouptitle.($task['bonus'] ? ' '.lang('validity').' '.$task['bonus'].' '.lang('days') : '');
} else {
$reward = lang('none');
}
if($task['available'] == '1' && (!$task['starttime'] || $task['starttime'] <= $timestamp) && (!$task['endtime'] || $task['endtime'] > $timestamp)) {
$starttasks[] = $task['taskid'];
}
$checked = $task['available'] ? ' checked="checked"' : '';
$checked2 = $task['taskid'] == $newbietask ? ' checked="checked"' : '';
if($task['starttime'] && $task['endtime']) {
$task['time'] = gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600).' ~ '.gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600);
} elseif($task['starttime'] && !$task['endtime']) {
$task['time'] = gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600).' '.lang('tasks_online');
} elseif(!$task['starttime'] && $task['endtime']) {
$task['time'] = gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600).' '.lang('tasks_offline');
} else {
$task['time'] = lang('nolimit');
}
showtablerow('', array('', '', '', 'class="td25"'), array(
"<input type=\"text\" class=\"txt\" name=\"namenew[$task[taskid]]\" size=\"20\" value=\"$task[name]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$task[taskid]]\" value=\"1\"$checked>",
"<input class=\"checkbox\" type=\"checkbox\" name=\"newbie[$task[taskid]]\" id=\"newbie[$task[taskid]]\" value=\"1\"$checked2 onclick=\"if(this.checked) {var objs = this.form.getElementsByTagName('input'); for(var i = 0; i< objs.length; i++) {if(objs[i].id.substr(0, 6) == 'newbie') objs[i].checked = false; this.checked = true;}}\">",
'<input type="text" class="txt" name="displayordernew['.$task['taskid'].']" value="'.$task['displayorder'].'" size="3" />',
in_array($task['scriptname'], $custom_scripts) ? $custom_types[$task['scriptname']]['name'] : lang('nav_task_'.$task['scriptname']),
$reward,
$task['time'],
"<a href=\"$BASESCRIPT?action=tasks&operation=edit&id=$task[taskid]\" class=\"act\">$lang[edit]</a>",
"<a href=\"$BASESCRIPT?action=tasks&operation=delete&id=$task[taskid]\" class=\"act\">$lang[delete]</a>"
));
}
if($starttasks) {
$db->query("UPDATE {$tablepre}tasks SET available='2' WHERE taskid IN (".implodeids($starttasks).")", 'UNBUFFERED');
}
showsubmit('tasksubmit', 'submit');
showtablefooter();
showformfooter();
} else {
if(is_array($namenew)) {
foreach($namenew as $id => $name) {
$availablenew[$id] = $availablenew[$id] && (!$starttimenew[$id] || $starttimenew[$id] <= $timestamp) && (!$endtimenew[$id] || $endtimenew[$id] > $timestamp) ? 2 : $availablenew[$id];
$db->query("UPDATE {$tablepre}tasks SET name='".dhtmlspecialchars($namenew[$id])."', available='$availablenew[$id]', displayorder='$displayordernew[$id]' WHERE taskid='$id'");
}
}
$newbietaskid = 0;
$updatesettings = FALSE;
if($taskonnew != $taskon) {
$updatesettings = TRUE;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('taskon', '$taskonnew')");
}
if(is_array($newbie) && count($newbie) == '1') {
$newbietaskid = key($newbie);
$db->query("UPDATE {$tablepre}tasks SET available='2' WHERE taskid='$newbietaskid'");
}
if($newbietaskid != intval($newbietask)) {
$updatesettings = TRUE;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('newbietask', '$newbietaskid')");
}
$updatesettings && updatecache('settings');
cpmsg('tasks_succeed', $BASESCRIPT.'?action=tasks', 'succeed');
}
} elseif($operation == 'add' && $script) {
if(!in_array($script, $sys_scripts)) {
if(in_array($script, $custom_scripts)) {
include language('tasks');
if((!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.cfg.php') || (!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php')) {
cpmsg('tasks_noscript_or_nocfg', '', 'error');
}
} else {
cpmsg('undefined_action', '', 'error');
}
}
if(!submitcheck('addsubmit')) {
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 0),
array(array('menu' => 'add', 'submenu' => $submenus), '', 1),
array('nav_task_type', 'tasks&operation=type', 0)
));
if(in_array($script, $sys_scripts)) {
showtips('tasks_tips_add_'.$script);
$task_name = $task_description = $task_icon = $task_period = '';
}
showformheader('tasks&operation=add&script='.$script);
showtableheader('tasks_add_basic', 'fixpadding');
showsetting('tasks_add_name', 'name', $task_name, 'text');
showsetting('tasks_add_desc', 'description', $task_description, 'textarea');
showsetting('tasks_add_icon', 'icon', $task_icon, 'text');
showsetting('tasks_add_starttime', 'starttime', '', 'calendar');
showsetting('tasks_add_endtime', 'endtime', '', 'calendar');
showsetting('tasks_add_period', 'period', $task_period, 'text');
showsetting('tasks_add_reward', array('reward', array(
array('', lang('none'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')),
array('credit', lang('credits'), array('reward_credit' => '', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')),
$magicstatus ? array('magic', lang('tasks_reward_magic'), array('reward_credit' => 'none', 'reward_magic' => '', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$medalstatus ? array('medal', lang('medals'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => '', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$regstatus > 1 ? array('invite', lang('tasks_reward_invite'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => '', 'reward_group' => 'none')) : '',
array('group', lang('tasks_add_group'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => ''))
)), '', 'mradio');
$extcreditarray = array(array(0, lang('select')));
foreach($extcredits as $creditid => $extcredit) {
$extcreditarray[] = array($creditid, $extcredit['title']);
}
showtagheader('tbody', 'reward_credit');
showsetting('tasks_add_extcredit', array('prize_credit', $extcreditarray), 0, 'select');
showsetting('tasks_add_credits', 'bonus_credit', '0', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_magic');
showsetting('tasks_add_magicname', array('prize_magic', fetcharray('magicid', 'name', 'magics', "available='1' ORDER BY displayorder")), 0, 'select');
showsetting('tasks_add_magicnum', 'bonus_magic', '0', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_medal');
showsetting('tasks_add_medalname', array('prize_medal', fetcharray('medalid', 'name', 'medals', "available='1' ORDER BY displayorder")), 0, 'select');
showsetting('tasks_add_medalexp', 'bonus_medal', '', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_invite');
showsetting('tasks_add_invitenum', 'prize_invite', '1', 'text');
showsetting('tasks_add_inviteexp', 'bonus_invite', '10', 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_group');
showsetting('tasks_add_group', array('prize_group', fetcharray('groupid', 'grouptitle', 'usergroups', "type='special' AND radminid='0'")), 0, 'select');
showsetting('tasks_add_groupexp', 'bonus_group', '', 'text');
showtagfooter('tbody');
showtitle('tasks_add_appyperm');
showsetting('tasks_add_groupperm', array('grouplimit', array(
array('all', lang('tasks_add_group_all'), array('specialgroup' => 'none')),
array('member', lang('tasks_add_group_member'), array('specialgroup' => 'none')),
array('admin', lang('tasks_add_group_admin'), array('specialgroup' => 'none')),
array('special', lang('tasks_add_group_special'), array('specialgroup' => ''))
)), 'all', 'mradio');
showtagheader('tbody', 'specialgroup');
showsetting('tasks_add_usergroup', array('applyperm[]', fetcharray('groupid', 'grouptitle', 'usergroups', '')), 0, 'mselect');
showtagfooter('tbody');
showsetting('tasks_add_relatedtask', array('relatedtaskid', fetcharray('taskid', 'name', 'tasks', "available='2' ORDER BY displayorder, taskid DESC")), 0, 'select');
showsetting('tasks_add_maxnum', 'tasklimits', '', 'text');
if(in_array($script, $custom_scripts)) {
if(is_array($task_conditions)) {
foreach($task_conditions as $taskvar) {
if($taskvar['sort'] == 'apply' && $taskvar['name']) {
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], 'text', '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
}
showtitle('tasks_add_conditions');
if($script == 'member') {
showsetting('tasks_add_limit_act', array('act', array(
array('buddy', lang('tasks_add_act_buddy'), array('timelimit' => 'none')),
array('favorite', lang('tasks_add_act_favorite'), array('timelimit' => 'none')),
array('magic', lang('tasks_add_act_magic'), array('timelimit' => ''))
)), 'buddy', 'mradio');
showsetting('tasks_add_limit_num', 'num', '', 'text');
showtagheader('tbody', 'timelimit');
showsetting('tasks_add_limit_time', 'time', '', 'text');
showtagfooter('tbody');
} elseif($script == 'post') {
showsetting('tasks_add_limit_act', array('act', array(
array('newthread', lang('tasks_add_act_newthread'), array('forumlimit' => '', 'speciallimit' => 'none')),
array('newreply', lang('tasks_add_act_newreply'), array('forumlimit' => 'none', 'speciallimit' => '')),
array('newpost', lang('tasks_add_act_newpost'), array('forumlimit' => '', 'speciallimit' => 'none'))
)), 'newpost', 'mradio');
require_once DISCUZ_ROOT.'./include/forum.func.php';
showtagheader('tbody', 'forumlimit', TRUE);
showsetting('tasks_add_limit_forumid', '', '', '<SELECT name="forumid"><option value="">'.lang('none').'</option>'.forumselect().'</select>');
showtagfooter('tbody');
showtagheader('tbody', 'speciallimit');
showsetting('tasks_add_limit_threadid', 'threadid', '', 'text');
showsetting('tasks_add_limit_authorid', 'author', '', 'text');
showtagfooter('tbody');
showsetting('tasks_add_limit_num', 'num', '', 'text');
showsetting('tasks_add_limit_time', 'time', '', 'text');
} elseif($script == 'mod') {
} elseif(in_array($script, $custom_scripts)) {
$haveconditions = FALSE;
if(is_array($task_conditions) && $task_conditions) {
foreach($task_conditions as $taskvar) {
if($taskvar['sort'] == 'complete' && $taskvar['name']) {
$haveconditions = TRUE;
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], 'text', '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
if(!$haveconditions) {
showtablerow('', 'class="td27" colspan="2"', lang('nolimit'));
}
if(is_array($task_settings) && $task_settings) {
$havesettings = FALSE;
foreach($task_settings as $taskvar) {
if($taskvar['name']) {
if(!$havesettings) {
showtitle('tasks_add_settings');
$havesettings = TRUE;
}
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], 'text', '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
}
showsubmit('addsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$applyperm = $grouplimit == 'special' && is_array($applyperm) ? implode("\t", $applyperm) : $grouplimit;
$starttime = dmktime($starttime);
$endtime = dmktime($endtime);
$prize = ${'prize_'.$reward};
$bonus = ${'bonus_'.$reward};
if(!$name || !$description) {
cpmsg('tasks_basic_invalid', '', 'error');
} elseif(($endtime && $endtime <= $timestamp) || ($starttime && $endtime && $endtime <= $starttime)) {
cpmsg('tasks_time_invalid', '', 'error');
} elseif($reward && (!$prize || ($reward == 'credit' && !$bonus))) {
cpmsg('tasks_reward_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}tasks (relatedtaskid, available, name, description, icon, tasklimits, applyperm, scriptname, starttime, endtime, period, reward, prize, bonus)
VALUES ('$relatedtaskid', '0', '$name', '$description', '$icon', '$tasklimits', '$applyperm', '$script', '$starttime', '$endtime', '$period', '$reward', '$prize', '$bonus')");
$taskid = $db->insert_id();
if(in_array($script, $sys_scripts)) {
if(!$threadid && $author) {
$authorid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$author'");
}
foreach(${$script.'vars'} as $item) {
if(in_array($item, array('num', 'time', 'threadid'))) {
$$item = intval($$item);
}
$db->query("INSERT INTO {$tablepre}taskvars (taskid, name, description, variable, value)
VALUES ('$taskid', '".lang('tasks_add_limit_'.$item)."', '".lang('tasks_add_limit_'.$item.'_comment')."', '$item', '".$$item."')");
}
} else {
if(is_array($task_conditions) && $task_conditions) {
foreach($task_conditions as $taskvars) {
if($taskvars['name']) {
$db->query("INSERT INTO {$tablepre}taskvars (taskid, sort, name, description, variable, value, type, extra)
VALUES ('$taskid', '$taskvars[sort]', '$taskvars[name]', '$taskvars[description]', '$taskvars[variable]', '${$taskvars[variable]}', '$taskvars[type]', '$taskvars[extra]')");
}
}
}
if(is_array($task_settings) && $task_settings) {
foreach($task_settings as $taskvars) {
if($taskvars['name']) {
$db->query("INSERT INTO {$tablepre}taskvars (taskid, sort, name, description, variable, value, type, extra)
VALUES ('$taskid', 'setting', '$taskvars[name]', '$taskvars[description]', '$taskvars[variable]', '${$taskvars[variable]}', '$taskvars[type]', '$taskvars[extra]')");
}
}
}
}
cpmsg('tasks_succeed', "$BASESCRIPT?action=tasks", 'succeed');
}
} elseif($operation == 'edit' && $id) {
$task = $db->fetch_first("SELECT * FROM {$tablepre}tasks WHERE taskid='$id'");
if(!submitcheck('editsubmit')) {
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 0),
array(array('menu' => 'add', 'submenu' => $submenus), '', 0),
array('nav_task_type', 'tasks&operation=type', 0)
));
showformheader('tasks&operation=edit&id='.$id);
showtableheader('tasks_edit_basic', 'fixpadding');
showsetting('tasks_add_name', 'name', $task['name'], 'text');
showsetting('tasks_add_desc', 'description', $task['description'], 'textarea');
showsetting('tasks_add_icon', 'icon', $task['icon'], 'text');
showsetting('tasks_add_starttime', 'starttime', $task['starttime'] ? gmdate('y-m-d', $task['starttime'] + $timeoffset * 3600) : '', 'calendar');
showsetting('tasks_add_endtime', 'endtime', $task['endtime'] ? gmdate('y-m-d', $task['endtime'] + $timeoffset * 3600) : '', 'calendar');
showsetting('tasks_add_period', 'period', $task['period'], 'text');
showsetting('tasks_add_reward', array('reward', array(
array('', lang('none'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')),
array('credit', lang('credits'), array('reward_credit' => '', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite'=> 'none', 'reward_group' => 'none')),
$magicstatus ? array('magic', lang('tasks_reward_magic'), array('reward_credit' => 'none', 'reward_magic' => '', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$medalstatus ? array('medal', lang('medals'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => '', 'reward_invite' => 'none', 'reward_group' => 'none')) : '',
$regstatus > 1 ? array('invite', lang('tasks_reward_invite'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => '', 'reward_group' => 'none')) : '',
array('group', lang('tasks_add_group'), array('reward_credit' => 'none', 'reward_magic' => 'none', 'reward_medal' => 'none', 'reward_invite' => 'none', 'reward_group' => ''))
)), $task['reward'], 'mradio');
$extcreditarray = array(array(0, lang('select')));
foreach($extcredits as $creditid => $extcredit) {
$extcreditarray[] = array($creditid, $extcredit['title']);
}
showtagheader('tbody', 'reward_credit', $task['reward'] == 'credit');
showsetting('tasks_add_extcredit', array('prize_credit', $extcreditarray), $task['prize'], 'select');
showsetting('tasks_add_credits', 'bonus_credit', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_magic', $task['reward'] == 'magic');
showsetting('tasks_add_magicname', array('prize_magic', fetcharray('magicid', 'name', 'magics', "available='1' ORDER BY displayorder")), $task['prize'], 'select');
showsetting('tasks_add_magicnum', 'bonus_magic', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_medal', $task['reward'] == 'medal');
showsetting('tasks_add_medalname', array('prize_medal', fetcharray('medalid', 'name', 'medals', "available='1' ORDER BY displayorder")), $task['prize'], 'select');
showsetting('tasks_add_medalexp', 'bonus_medal', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_invite', $task['reward'] == 'invite');
showsetting('tasks_add_invitenum', 'prize_invite', $task['prize'], 'text');
showsetting('tasks_add_inviteexp', 'bonus_invite', $task['bonus'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'reward_group', $task['reward'] == 'group');
showsetting('tasks_add_group', array('prize_group', fetcharray('groupid', 'grouptitle', 'usergroups', "type='special' AND radminid='0'")), $task['prize'], 'select');
showsetting('tasks_add_groupexp', 'bonus_group', $task['bonus'], 'text');
showtagfooter('tbody');
showtitle('tasks_add_appyperm');
if(!$task['applyperm']) {
$task['applyperm'] = 'all';
}
$task['grouplimit'] = in_array($task['applyperm'], array('all', 'member', 'admin')) ? $task['applyperm'] : 'special';
showsetting('tasks_add_groupperm', array('grouplimit', array(
array('all', lang('tasks_add_group_all'), array('specialgroup' => 'none')),
array('member', lang('tasks_add_group_member'), array('specialgroup' => 'none')),
array('admin', lang('tasks_add_group_admin'), array('specialgroup' => 'none')),
array('special', lang('tasks_add_group_special'), array('specialgroup' => ''))
)), $task['grouplimit'], 'mradio');
showtagheader('tbody', 'specialgroup', $task['grouplimit'] == 'special');
showsetting('tasks_add_usergroup', array('applyperm[]', fetcharray('groupid', 'grouptitle', 'usergroups', '')), explode("\t", $task['applyperm']), 'mselect');
showtagfooter('tbody');
showsetting('tasks_add_relatedtask', array('relatedtaskid', fetcharray('taskid', 'name', 'tasks', "available='2' AND taskid!='$task[taskid]'")), $task['relatedtaskid'], 'select');
showsetting('tasks_add_maxnum', 'tasklimits', $task['tasklimits'], 'text');
$taskvars = array();
$query = $db->query("SELECT * FROM {$tablepre}taskvars WHERE taskid='$id'");
while($taskvar = $db->fetch_array($query)) {
if($taskvar['sort'] == 'apply') {
$taskvars['apply'][] = $taskvar;
} elseif($taskvar['sort'] == 'complete') {
$taskvars['complete'][$taskvar['variable']] = $taskvar;
} elseif($taskvar['sort'] == 'setting') {
$taskvars['setting'][$taskvar['variable']] = $taskvar;
}
}
if($taskvars['apply']) {
foreach($taskvars['apply'] as $taskvar) {
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], 'text', '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
showtitle('tasks_add_conditions');
if($task['scriptname'] == 'member') {
showsetting('tasks_add_limit_act', array('act', array(
array('buddy', lang('tasks_add_act_buddy'), array('timelimit' => 'none')),
array('favorite', lang('tasks_add_act_favorite'), array('timelimit' => 'none')),
array('magic', lang('tasks_add_act_magic'), array('timelimit' => ''))
)), $taskvars['complete']['act']['value'], 'mradio');
showsetting('tasks_add_limit_num', 'num', $taskvars['complete']['num']['value'], 'text');
showtagheader('tbody', 'timelimit', $taskvars['complete']['act']['value'] == 'magic');
showsetting('tasks_add_limit_time', 'time', $taskvars['complete']['time']['value'], 'text');
showtagfooter('tbody');
} elseif($task['scriptname'] == 'post') {
showsetting('tasks_add_limit_act', array('act', array(
array('newthread', lang('tasks_add_act_newthread'), array('forumlimit' => '', 'speciallimit' => 'none')),
array('newreply', lang('tasks_add_act_newreply'), array('forumlimit' => 'none', 'speciallimit' => '')),
array('newpost', lang('tasks_add_act_newpost'), array('forumlimit' => '', 'speciallimit' => 'none'))
)), $taskvars['complete']['act']['value'], 'mradio');
require_once DISCUZ_ROOT.'./include/forum.func.php';
showtagheader('tbody', 'forumlimit', $taskvars['complete']['act']['value'] != 'newreply');
showsetting('tasks_add_limit_forumid', '', '', '<SELECT name="forumid"><option value="">'.lang('nolimit').'</option>'.forumselect(FALSE, 0, $taskvars['complete']['forumid']['value']).'</select>');
showtagfooter('tbody');
showtagheader('tbody', 'speciallimit', $taskvars['complete']['act']['value'] == 'newreply');
showsetting('tasks_add_limit_threadid', 'threadid', $taskvars['complete']['threadid']['value'] ? $taskvars['complete']['threadid']['value'] : '', 'text');
$author = $taskvars['complete']['authorid']['value'] && ($author = $db->result_first("SELECT username FROM {$tablepre}members WHERE uid='{$taskvars[complete][authorid][value]}'")) ? $author : '';
showsetting('tasks_add_limit_authorid', 'author', $author, 'text');
showtagfooter('tbody');
showsetting('tasks_add_limit_num', 'num', $taskvars['complete']['num']['value'], 'text');
showsetting('tasks_add_limit_time', 'time', $taskvars['complete']['time']['value'], 'text');
} else {
if($taskvars['complete']) {
foreach($taskvars['complete'] as $taskvar) {
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], 'text', '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
} else {
showtablerow('', 'class="td27" colspan="2"', lang('nolimit'));
}
if($taskvars['setting']) {
showtitle('tasks_add_settings');
foreach($taskvars['setting'] as $taskvar) {
if($taskvar['variable']) {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], 'text', '', 0, $taskvar['description']);
} else {
showsetting($taskvar['name'], $taskvar['variable'], $taskvar['value'], $taskvar['description']);
}
}
}
}
showsubmit('editsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$applyperm = $grouplimit == 'special' && is_array($applyperm) ? implode("\t", $applyperm) : $grouplimit;
$starttime = dmktime($starttime);
$endtime = dmktime($endtime);
$prize = ${'prize_'.$reward};
$bonus = ${'bonus_'.$reward};
if(!$name || !$description) {
cpmsg('tasks_basic_invalid', '', 'error');
} elseif(($starttime != $task['starttime'] || $endtime != $task['endtime']) && (($endtime && $endtime <= $timestamp) || ($starttime && $endtime && $endtime <= $starttime))) {
cpmsg('tasks_time_invalid', '', 'error');
} elseif($reward && (!$prize || ($reward == 'credit' && !$bonus))) {
cpmsg('tasks_reward_invalid', '', 'error');
}
if($task['available'] == '2' && ($starttime > $timestamp || ($endtime && $endtime <= $timestamp))) {
$db->query("UPDATE {$tablepre}tasks SET available='1' WHERE taskid='$id'", 'UNBUFFERED');
}
if($task['available'] == '1' && (!$starttime || $starttime <= $timestamp) && (!$endtime || $endtime > $timestamp)) {
$db->query("UPDATE {$tablepre}tasks SET available='2' WHERE taskid='$id'", 'UNBUFFERED');
}
if(in_array($task['scriptname'], $sys_scripts)) {
if(!$threadid && $author) {
$authorid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$author'");
}
$itemarray = ${$task['scriptname'].'vars'};
} else {
$itemarray = array();
$query = $db->query("SELECT variable FROM {$tablepre}taskvars WHERE taskid='$id' AND variable IS NOT NULL");
while($taskvar = $db->fetch_array($query)) {
$itemarray[] = $taskvar['variable'];
}
}
$db->query("UPDATE {$tablepre}tasks SET relatedtaskid='$relatedtaskid', name='$name', description='$description', icon='$icon', tasklimits='$tasklimits', applyperm='$applyperm', starttime='$starttime', endtime='$endtime', period='$period', reward='$reward', prize='$prize', bonus='$bonus' WHERE taskid='$id'");
foreach($itemarray as $item) {
if(in_array($item, array('num', 'time', 'threadid'))) {
$$item = intval($$item);
}
$db->query("UPDATE {$tablepre}taskvars SET value='".$$item."' WHERE taskid='$id' AND variable='$item'");
}
cpmsg('tasks_succeed', "$BASESCRIPT?action=tasks", 'succeed');
}
} elseif($operation == 'delete' && $id) {
if(!$confirmed) {
cpmsg('tasks_del_confirm', "$BASESCRIPT?action=tasks&operation=delete&id=$id", 'form');
}
$task = $db->result_first("SELECT count(*) FROM {$tablepre}tasks WHERE taskid='$id'");
if(!$task) {
cpmsg('undefined_action', '', 'error');
}
$db->query("DELETE FROM {$tablepre}tasks WHERE taskid='$id'");
$db->query("DELETE FROM {$tablepre}taskvars WHERE taskid='$id'");
$db->query("DELETE FROM {$tablepre}mytasks WHERE taskid='$id'");
if($id == $newbietask) {
$db->query("UPDATE {$tablepre}settings SET value='' WHERE variable='newbietask'");
updatecache('settings');
}
cpmsg('tasks_del', $BASESCRIPT.'?action=tasks', 'succeed');
} elseif($operation == 'type') {
include language('tasks');
shownav('extended', 'nav_tasks');
showsubmenu('nav_tasks', array(
array('admin', 'tasks', 0),
array(array('menu' => 'add', 'submenu' => $submenus), '', 0),
array('nav_task_type', 'tasks&operation=type', 1)
));
showtips('tasks_tips_add_type');
$taskdir = DISCUZ_ROOT.'./include/tasks';
$tasksdir = dir($taskdir);
$scripts = array();
while($entry = $tasksdir->read()) {
$script = substr($entry, 0, -8);
if(!in_array($entry, array('.', '..')) && !in_array($script, $sys_scripts) && preg_match("/^[\w\.]+$/", $entry) && substr($entry, -8)== '.inc.php' && strlen($entry) < 30 && is_file($taskdir.'/'.$entry) && is_file($taskdir.'/'.$script.'.cfg.php')) {
$scripts[] = array('filename' => $script, 'filemtime' => @filemtime($taskdir.'/'.$entry));
}
}
uasort($scripts, 'filemtimesort');
showtableheader('', 'fixpadding');
showsubtitle(array('name', 'tasks_script', 'tasks_version', 'copyright', ''));
foreach($scripts as $script) {
require_once $taskdir.'/'.$script['filename'].'.cfg.php';
showtablerow('', array('id="custom_task_'.$script['filename'].'" onmouseover="showMenu(this.id)"'), array(
$task_name.($script['filemtime'] > $timestamp - 86400 ? ' <font color="red">New!</font>' : '').'<div class="dropmenu" id="custom_task_'.$script['filename'].'_menu" style="display: none; white-space: normal; width: 30%; padding: 10px;">'.$task_description.'</div>',
$script['filename'].'.inc.php',
$task_version,
$task_copyright,
in_array($script['filename'], $custom_scripts) ? "<a href=\"$BASESCRIPT?action=tasks&operation=upgrade&script=$script[filename]\" class=\"act\">$lang[tasks_upgrade]</a> <a href=\"$BASESCRIPT?action=tasks&operation=uninstall&script=$script[filename]\" class=\"act\">$lang[tasks_uninstall]</a><br />" : "<a href=\"$BASESCRIPT?action=tasks&operation=install&script=$script[filename]\" class=\"act\">$lang[tasks_install]</a>"
));
}
foreach($sys_types as $script => $task) {
showtablerow('', '', array(
$task['name'],
$script.'.inc.php',
$task['version'],
'<a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a>',
''
));
}
showtablefooter();
} elseif($operation == 'install' && $script) {
include language('tasks');
if((!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.cfg.php') || (!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php')) {
cpmsg('tasks_noscript_or_nocfg', '', 'error');
} elseif(!(function_exists('task_install') && function_exists('task_uninstall') && function_exists('task_upgrade') && function_exists('task_condition') && function_exists('task_preprocess') && function_exists('task_csc') && function_exists('task_sufprocess'))) {
cpmsg('tasks_code_invalid', '', 'error');
} elseif($db->result_first("SELECT COUNT(*) FROM {$tablepre}tasks WHERE scriptname='$script'")) {
cpmsg('tasks_install_duplicate', '', 'error');
}
task_install();
$custom_types[$script] = array('name' => $task_name, 'version' => $task_version);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('tasktypes', '".addslashes(serialize($custom_types))."')");
cpmsg('tasks_installed', $BASESCRIPT.'?action=tasks', 'succeed');
} elseif($operation == 'uninstall' && $script) {
if(!$confirmed) {
cpmsg('tasks_uninstall_confirm', "$BASESCRIPT?action=tasks&operation=uninstall&script=$script", 'form');
}
if(in_array($script, $sys_scripts)) {
cpmsg('undefined_action', '', 'error');
} elseif(!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php') {
cpmsg('tasks_noscript', '', 'error');
}
$ids = $comma = '';
$query = $db->query("SELECT taskid FROM {$tablepre}tasks WHERE scriptname='$script'");
while($task = $db->fetch_array($query)) {
$ids = $comma.$task['taskid'];
$comma = ',';
}
if($ids) {
$db->query("DELETE FROM {$tablepre}tasks WHERE taskid IN ($ids)");
$db->query("DELETE FROM {$tablepre}taskvars WHERE taskid IN ($ids)");
$db->query("DELETE FROM {$tablepre}mytasks WHERE taskid IN ($ids)");
}
task_uninstall();
unset($custom_types[$script]);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('tasktypes', '".addslashes(serialize($custom_types))."')");
cpmsg('tasks_uninstalled', $BASESCRIPT.'?action=tasks', 'succeed');
} elseif($operation == 'upgrade' && $script) {
include language('tasks');
if(in_array($script, $sys_scripts)) {
cpmsg('undefined_action', '', 'error');
} elseif((!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.cfg.php') || (!@include DISCUZ_ROOT.'./include/tasks/'.$script.'.inc.php')) {
cpmsg('tasks_noscript_or_nocfg', '', 'error');
} elseif($custom_types[$script]['version'] >= $task_version) {
cpmsg('tasks_newest', '', 'error');
}
task_upgrade();
$db->query("UPDATE {$tablepre}tasks SET name='$task_name', description='$task_description', icon='$task_icon', tasklimits='$task_tasklimits', starttime='$task_starttime', endtime='$task_endtime', period='$task_period', reward='$task_reward', prize='$task_prize', bonus='$task_bonus', version='$task_version' WHERE scriptname='$script'");
$custom_types[$script] = array('name' => $task_name, 'version' => $task_version);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('tasktypes', '".addslashes(serialize($custom_types))."')");
cpmsg('tasks_updated', $BASESCRIPT.'?action=tasks', 'succeed');
}
function fetcharray($id, $name, $table, $conditions = '1') {
global $db, $tablepre;
$array = array(array(0, lang('nolimit')));
$query = $db->query("SELECT $id, $name FROM $tablepre$table".($conditions ? " WHERE $conditions" : ''));
while($result = $db->fetch_array($query)) {
$array[] = array($result[$id], $result[$name]);
}
return $array;
}
function runquery($sql) {
global $dbcharset, $tablepre, $db;
$sql = str_replace("\r", "\n", str_replace(' cdb_', ' '.$tablepre, $sql));
$ret = array();
$num = 0;
foreach(explode(";\n", trim($sql)) as $query) {
$queries = explode("\n", trim($query));
foreach($queries as $query) {
$ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
}
$num++;
}
unset($sql);
foreach($ret as $query) {
$query = trim($query);
if($query) {
if(substr($query, 0, 12) == 'CREATE TABLE') {
$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
$db->query(createtable($query, $dbcharset));
} else {
$db->query($query);
}
}
}
}
function createtable($sql, $dbcharset) {
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
(mysql_get_server_info() > '4.1' ? " ENGINE=$type DEFAULT CHARSET=$dbcharset" : " TYPE=$type");
}
function dmktime($date) {
if(strpos($date, '-')) {
$time = explode('-', $date);
return mktime(0, 0, 0, $time[1], $time[2], $time[0]);
}
return 0;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/tasks.inc.php
|
PHP
|
asf20
| 37,238
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: forums.inc.php 17347 2008-12-16 01:09:47Z tiger $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = empty($operation) ? 'admin' : $operation;
if($operation == 'admin') {
if(!submitcheck('editsubmit')) {
shownav('forum', 'forums_admin');
showsubmenu('forums_admin');
showtips('forums_admin_tips');
$projectselect = '<option value="0" selected="selected">'.$lang['none'].'</option>';
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='forum'");
while($project = $db->fetch_array($query)) {
$projectselect .= '<option value="'.$project['id'].'">'.$project['name'].'</option>';
}
?>
<script type="text/JavaScript">
var rowtypedata = [
[[1,'<input type="text" class="txt" name="newcatorder[]" value="0" />', 'td25'], [3, '<input name="newcat[]" value="<?=$lang['forums_admin_add_category_name']?>" size="20" type="text" class="txt" />']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="board"><input name="newforum[{1}][]" value="<?=$lang['forums_admin_add_forum_name']?>" size="20" type="text" class="txt" /><select name="projectid[{1}][]"><?=$projectselect?></select></div>']],
[[1,'<input type="text" class="txt" name="neworder[{1}][]" value="0" />', 'td25'], [3, '<div class="childboard"><input name="newforum[{1}][]" value="<?=$lang['forums_admin_add_forum_name']?>" size="20" type="text" class="txt" /><select name="projectid[{1}][]" id="projectid[{1}]"><?=$projectselect?></select> <input name="inherited[{1}][]" type="checkbox" class="checkbox" value="1" onclick="if($(\'projectid[{1}]\').disabled) {$(\'projectid[{1}]\').disabled = false;} else {$(\'projectid[{1}]\').disabled = true;}"> <?=$lang['forums_edit_inherited']?></div>']],
];
</script>
<?
showformheader('forums');
showtableheader('');
showsubtitle(array('display_order', 'forums_admin_name', 'forums_moderators', ''));
$forums = $showedforums = array();
$query = $db->query("SELECT f.fid, f.type, f.status, f.name, f.fup, f.displayorder, f.inheritedmod, ff.moderators, ff.password, ff.redirect
FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff USING(fid)
ORDER BY f.type<>'group', f.displayorder");
while($forum = $db->fetch_array($query)) {
$forums[] = $forum;
}
for($i = 0; $i < count($forums); $i++) {
if($forums[$i]['type'] == 'group') {
echo showforum($i, 'group');
for($j = 0; $j < count($forums); $j++) {
if($forums[$j]['fup'] == $forums[$i]['fid'] && $forums[$j]['type'] == 'forum') {
echo showforum($j);
$lastfid = 0;
for($k = 0; $k < count($forums); $k++) {
if($forums[$k]['fup'] == $forums[$j]['fid'] && $forums[$k]['type'] == 'sub') {
echo showforum($k, 'sub');
$lastfid = $forums[$k]['fid'];
}
}
echo showforum($j, $lastfid, 'lastchildboard');
}
}
echo showforum($i, '', 'lastboard');
} elseif(!$forums[$i]['fup'] && $forums[$i]['type'] == 'forum') {
echo showforum($i);
for($j = 0; $j < count($forums); $j++) {
if($forums[$j]['fup'] == $forums[$i]['fid'] && $forums[$j]['type'] == 'sub') {
echo showforum($j, 'sub');
}
}
echo showforum($i, '', 'lastchildboard');
}
}
foreach($forums as $key => $forum) {
if(!in_array($key, $showedforums)) {
$db->query("UPDATE {$tablepre}forums SET fup='0', type='forum' WHERE fid='$forum[fid]'");
echo showforum($key);
}
}
echo showforum($i, '', 'last');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
// read from groups
$usergroups = array();
$query = $db->query("SELECT groupid, type, creditshigher, creditslower FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$usergroups[$group['groupid']] = $group;
}
if(is_array($order)) {
foreach($order as $fid => $value) {
$db->query("UPDATE {$tablepre}forums SET name='$name[$fid]', displayorder='$order[$fid]' WHERE fid='$fid'");
}
}
if(is_array($newcat)) {
foreach($newcat as $key => $forumname) {
if(empty($forumname)) {
continue;
}
$db->query("INSERT INTO {$tablepre}forums (type, name, status, displayorder)
VALUES ('group', '$forumname', '1', '$newcatorder[$key]')");
$fid = $db->insert_id();
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
}
}
$table_forum_columns = array('fup', 'type', 'name', 'status', 'displayorder', 'styleid', 'allowsmilies', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowanonymous', 'allowshare', 'allowpostspecial', 'alloweditrules', 'alloweditpost', 'modnewposts', 'recyclebin', 'jammer', 'forumcolumns', 'threadcaches', 'disablewatermark', 'autoclose', 'simple');
$table_forumfield_columns = array('fid', 'attachextensions', 'threadtypes', 'postcredits', 'replycredits', 'digestcredits', 'postattachcredits', 'getattachcredits', 'viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm');
$projectdata = array();
if(is_array($newforum)) {
foreach($newforum as $fup => $forums) {
$forum = $db->fetch_first("SELECT * FROM {$tablepre}forums WHERE fid='$fup'");
foreach($forums as $key => $forumname) {
if(empty($forumname)) {
continue;
}
$forumfields = array();
$id = $projectid[$fup][$key];
$inheritedid = $inherited[$fup] ? $fup : '';
if(!empty($id)) {
$projectdata[$id] = empty($projectdata[$id]) ? unserialize($db->result_first("SELECT value FROM {$tablepre}projects WHERE id='$id'")) : $projectdata[$id];
foreach($table_forum_columns as $field) {
$forumfields[$field] = $projectdata[$id][$field];
}
foreach($table_forumfield_columns as $field) {
$forumfields[$field] = $projectdata[$id][$field];
}
} elseif(!empty($inheritedid)) {
$query = $db->query("SELECT * FROM {$tablepre}forums WHERE fid='$inheritedid'");
$forum = $db->fetch_array($query);
$query = $db->query("SELECT * FROM {$tablepre}forumfields WHERE fid='$inheritedid'");
$forumfield = $db->fetch_array($query);
foreach($table_forum_columns as $field) {
$forumfields[$field] = $forum[$field];
}
foreach($table_forumfield_columns as $field) {
$forumfields[$field] = $forumfield[$field];
}
} else {
$forumfields['allowsmilies'] = $forumfields['allowbbcode'] = $forumfields['allowimgcode'] = $forumfields['allowshare'] = 1;
$forumfields['allowpostspecial'] = 127;
}
$forumfields['fup'] = $forum ? $fup : 0;
$forumfields['type'] = $forum['type'] == 'forum' ? 'sub' : 'forum';
$forumfields['name'] = $forumname;
$forumfields['status'] = 1;
$forumfields['displayorder'] = $neworder[$fup][$key];
$sql1 = $sql2 = $comma = '';
foreach($table_forum_columns as $field) {
if(isset($forumfields[$field])) {
$sql1 .= "$comma$field";
$sql2 .= "$comma'{$forumfields[$field]}'";
$comma = ', ';
}
}
$db->query("INSERT INTO {$tablepre}forums ($sql1) VALUES ($sql2)");
$forumfields['fid'] = $fid = $db->insert_id();
$sql1 = $sql2 = $comma = '';
foreach($table_forumfield_columns as $field) {
if(isset($forumfields[$field])) {
$sql1 .= "$comma$field";
$sql2 .= "$comma'{$forumfields[$field]}'";
$comma = ', ';
}
}
$db->query("INSERT INTO {$tablepre}forumfields ($sql1) VALUES ($sql2)");
$query = $db->query("SELECT uid, inherited FROM {$tablepre}moderators WHERE fid='$fup'");
while($mod = $db->fetch_array($query)) {
if($mod['inherited'] || $forum['inheritedmod']) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, inherited)
VALUES ('$mod[uid]', '$fid', '1')");
}
}
}
}
}
updatecache('forums');
cpmsg('forums_update_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
} elseif($operation == 'moderators' && $fid) {
if(!submitcheck('modsubmit')) {
shownav('forum', 'forums_moderators_edit');
showsubmenu(lang('forums_moderators_edit').' - '.$forum['name']);
showtips('forums_moderators_tips');
showformheader("forums&operation=moderators&fid=$fid&");
showtableheader('', 'fixpadding');
showsubtitle(array('', 'display_order', 'username', 'forums_moderators_inherited'));
$query = $db->query("SELECT m.username, mo.* FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND m.uid=mo.uid ORDER BY mo.inherited, mo.displayorder");
while($mod = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td28"'), array(
'<input type="checkbox" class="checkbox" name="delete[]" value="'.$mod[uid].'"'.($mod['inherited'] ? ' disabled' : '').' />',
'<input type="text" class="txt" name="displayordernew['.$mod[uid].']" value="'.$mod[displayorder].'" size="2" />',
"<a href=\"space.php?uid=$mod[uid]\" target=\"_blank\">$mod[username]</a>",
lang($mod['inherited'] ? 'yes' : 'no'),
));
}
if($forum['type'] == 'group' || $forum['type'] == 'sub') {
$checked = $forum['type'] == 'group' ? 'checked' : '';
$disabled = 'disabled';
} else {
$checked = $forum['inheritedmod'] ? 'checked' : '';
$disabled = '';
}
showtablerow('', array('class="td25"', 'class="td28"'), array(
lang('add_new'),
'<input type="text" class="txt" name="newdisplayorder" value="0" size="2" />',
'<input type="text" class="txt" name="newmoderator" value="" size="20" />',
''
));
showsubmit('modsubmit', 'submit', 'del', '<input class="checkbox" type="checkbox" name="inheritedmodnew" value="1" '.$checked.' '.$disabled.' id="inheritedmodnew" /><label for="inheritedmodnew">'.lang('forums_moderators_inherit').'</label>');
showtablefooter();
showformfooter();
} else {
if($forum['type'] == 'group') {
$inheritedmodnew = 1;
} elseif($forum['type'] == 'sub') {
$inheritedmodnew = 0;
}
if(!empty($delete) || $newmoderator || (bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
$fidarray = $newmodarray = $origmodarray = array();
if($forum['type'] == 'group') {
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='forum' AND fup='$fid'");
while($sub = $db->fetch_array($query)) {
$fidarray[] = $sub['fid'];
}
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='sub' AND fup IN ('".implode('\',\'', $fidarray)."')");
while($sub = $db->fetch_array($query)) {
$fidarray[] = $sub['fid'];
}
} elseif($forum['type'] == 'forum') {
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE type='sub' AND fup='$fid'");
while($sub = $db->fetch_array($query)) {
$fidarray[] = $sub['fid'];
}
}
if(is_array($delete)) {
foreach($delete as $uid) {
$db->query("DELETE FROM {$tablepre}moderators WHERE uid='$uid' AND ((fid='$fid' AND inherited='0') OR (fid IN ('".implode('\',\'', $fidarray)."') AND inherited='1'))");
}
$excludeuids = 0;
$deleteuids = '\''.implode('\',\'', $delete).'\'';
$query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE uid IN ($deleteuids)");
while($mod = $db->fetch_array($query)) {
$excludeuids .= ','.$mod['uid'];
}
$usergroups = array();
$query = $db->query("SELECT groupid, type, radminid, creditshigher, creditslower FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$usergroups[$group['groupid']] = $group;
}
$query = $db->query("SELECT uid, groupid, credits FROM {$tablepre}members WHERE uid IN ($deleteuids) AND uid NOT IN ($excludeuids) AND adminid NOT IN (1,2)");
while($member = $db->fetch_array($query)) {
if($usergroups[$member['groupid']]['type'] == 'special' && $usergroups[$member['groupid']]['radminid'] != 3) {
$adminidnew = -1;
$groupidnew = $member['groupid'];
} else {
$adminidnew = 0;
foreach($usergroups as $group) {
if($group['type'] == 'member' && $member['credits'] >= $group['creditshigher'] && $member['credits'] < $group['creditslower']) {
$groupidnew = $group['groupid'];
break;
}
}
}
$db->query("UPDATE {$tablepre}members SET adminid='$adminidnew', groupid='$groupidnew' WHERE uid='$member[uid]'");
}
}
if((bool)$forum['inheritedmod'] != (bool)$inheritedmodnew) {
$query = $db->query("SELECT uid FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='0'");
while($mod = $db->fetch_array($query)) {
$origmodarray[] = $mod['uid'];
if(!$forum['inheritedmod'] && $inheritedmodnew) {
$newmodarray[] = $mod['uid'];
}
}
if($forum['inheritedmod'] && !$inheritedmodnew) {
$db->query("DELETE FROM {$tablepre}moderators WHERE uid IN ('".implode('\',\'', $origmodarray)."') AND fid IN ('".implode('\',\'', $fidarray)."') AND inherited='1'");
}
}
if($newmoderator) {
$member = $db->fetch_first("SELECT uid FROM {$tablepre}members WHERE username='$newmoderator'");
if(!$member) {
cpmsg('members_edit_nonexistence', '', 'error');
} else {
$newmodarray[] = $member['uid'];
$db->query("UPDATE {$tablepre}members SET groupid='3' WHERE uid='$member[uid]' AND adminid NOT IN (1,2,3,4,5,6,7,8,-1)");
$db->query("UPDATE {$tablepre}members SET adminid='3' WHERE uid='$member[uid]' AND adminid NOT IN (1,2)");
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
VALUES ('$member[uid]', '$fid', '$newdisplayorder', '0')");
}
}
foreach($newmodarray as $uid) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
VALUES ('$uid', '$fid', '$newdisplayorder', '0')");
if($inheritedmodnew) {
foreach($fidarray as $ifid) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, inherited)
VALUES ('$uid', '$ifid', '1')");
}
}
}
if($forum['type'] == 'group') {
$inheritedmodnew = 1;
} elseif($forum['type'] == 'sub') {
$inheritedmodnew = 0;
}
$db->query("UPDATE {$tablepre}forums SET inheritedmod='$inheritedmodnew' WHERE fid='$fid'");
}
if(is_array($displayordernew)) {
foreach($displayordernew as $uid => $order) {
$db->query("UPDATE {$tablepre}moderators SET displayorder='$order' WHERE fid='$fid' AND uid='$uid'");
}
}
$moderators = $tab = '';
$query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder");
while($mod = $db->fetch_array($query)) {
$moderators .= $tab.addslashes($mod['username']);
$tab = "\t";
}
$db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'");
cpmsg('forums_moderators_update_succeed', "$BASESCRIPT?action=forums&operation=moderators&fid=$fid", 'succeed');
}
} elseif($operation == 'merge') {
if(!submitcheck('mergesubmit') || $source == $target) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$forumselect = "<select name=\"%s\">\n<option value=\"\"> > $lang[select]</option><option value=\"\"> </option>".str_replace('%', '%%', forumselect()).'</select>';
shownav('forum', 'forums_merge');
showsubmenu('forums_merge');
showformheader('forums&operation=merge');
showtableheader();
showsetting('forums_merge_source', '', '', sprintf($forumselect, 'source'));
showsetting('forums_merge_target', '', '', sprintf($forumselect, 'target'));
showsubmit('mergesubmit');
showtablefooter();
showformfooter();
} else {
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}forums WHERE fid IN ('$source', '$target') AND type<>'group'") != 2) {
cpmsg('forums_nonexistence', '', 'error');
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$source'")) {
cpmsg('forums_merge_source_sub_notnull', '', 'error');
}
$db->query("UPDATE {$tablepre}threads SET fid='$target' WHERE fid='$source'");
$db->query("UPDATE {$tablepre}posts SET fid='$target' WHERE fid='$source'");
$sourceforum = $db->fetch_first("SELECT threads, posts FROM {$tablepre}forums WHERE fid='$source'");
$db->query("UPDATE {$tablepre}forums SET threads=threads+$sourceforum[threads], posts=posts+$sourceforum[posts] WHERE fid='$target'");
$db->query("DELETE FROM {$tablepre}forums WHERE fid='$source'");
$db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$source'");
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$source'");
$query = $db->query("SELECT * FROM {$tablepre}access WHERE fid='$source'");
while($access = $db->fetch_array($query)) {
$db->query("INSERT INTO {$tablepre}access (uid, fid, allowview, allowpost, allowreply, allowgetattach)
VALUES ('$access[uid]', '$target', '$access[allowview]', '$access[allowpost]', '$access[allowreply]', '$access[allowgetattach]')", 'SILENT');
}
$db->query("DELETE FROM {$tablepre}access WHERE fid='$source'");
updatecache('forums');
cpmsg('forums_merge_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
} elseif($operation == 'edit') {
if(empty($fid)) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
cpmsg('forums_edit_nonexistence', $BASESCRIPT.'?action=forums&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : '').(!empty($anchor) ? "&anchor=$anchor" : ''), 'form', '<select name="fid">'.forumselect().'</select>');
}
$perms = array('viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm');
$forum = $db->fetch_first("SELECT *, f.fid AS fid FROM {$tablepre}forums f
LEFT JOIN {$tablepre}forumfields ff USING (fid)
WHERE f.fid='$fid'");
if(!$forum) {
cpmsg('forums_nonexistence', '', 'error');
}
$query = $db->query("SELECT disabledactions FROM {$tablepre}adminactions WHERE admingid='$groupid'");
$dactionarray = ($dactionarray = unserialize($db->result($query, 0))) ? $dactionarray : array();
$allowthreadtypes = !in_array('threadtypes', $dactionarray);
if(!empty($projectid)) {
$query = $db->query("SELECT value FROM {$tablepre}projects WHERE id='$projectid'");
$forum = @array_merge($forum, unserialize($db->result($query, 0)));
}
if(!submitcheck('detailsubmit') && !submitcheck('saveconfigsubmit')) {
$anchor = in_array($anchor, array('basic', 'extend', 'posts', 'credits', 'threadtypes', 'threadsorts', 'perm')) ? $anchor : 'basic';
shownav('forum', 'forums_edit');
if($forum['type'] == 'group') {
showsubmenu("$lang[forums_cat_detail] - $forum[name]");
} else {
showsubmenuanchors(lang('forums_edit').' - '.$forum['name'], array(
array('forums_edit_basic', 'basic', $anchor == 'basic'),
array('forums_edit_extend', 'extend', $anchor == 'extend'),
array('forums_edit_posts', 'posts', $anchor == 'posts'),
array('forums_edit_credits', 'credits', $anchor == 'credits'),
array('forums_edit_threadtypes', 'threadtypes', $anchor == 'threadtypes'),
array('forums_edit_threadsorts', 'threadsorts', $anchor == 'threadsorts'),
array('forums_edit_perm', 'perm', $anchor == 'perm')
));
}
showtips('forums_edit_tips');
showformheader("forums&operation=edit&fid=$fid&");
showhiddenfields(array('type' => $forum['type']));
$sideselect = array();
$infosidestatus[0] && $sideselect[0] = '<select name="foruminfosidestatus[0]">
<option value="">'.$lang['forums_edit_extend_sideselect_global'].'</option>
<option value="-1"'.($infosidestatus['f'.$fid][0] == -1 ? ' selected="selected"' : '').'>'.$lang['forums_edit_extend_sideselect_off'].'</option>';
if($sideselect) {
$query = $db->query("SELECT variable FROM {$tablepre}request WHERE type=-2");
while($side = $db->fetch_array($query)) {
$infosidestatus[0] && $sideselect[0] .= "<option value=\"$side[variable]\" ".($infosidestatus['f'.$fid][0] == $side['variable'] ? 'selected="selected"' : NULL).">$side[variable]</option>\n";
}
$infosidestatus[0] && $sideselect[0] .= '</select>';
}
if($forum['type'] == 'group') {
showtableheader();
showsetting('forums_edit_basic_cat_name', 'namenew', $forum['name'], 'text');
showsetting('forums_edit_extend_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text');
showsetting('forums_cat_display', 'statusnew', $forum['status'], 'radio');
if($sideselect) {
showsetting('forums_cat_extend_sideselect', '', '', $sideselect[0]);
}
showsubmit('detailsubmit');
showtablefooter();
} else {
require_once DISCUZ_ROOT.'./include/editor.func.php';
$projectselect = "<select name=\"projectid\" onchange=\"window.location='$BASESCRIPT?action=forums&operation=edit&fid=$fid&projectid='+this.options[this.options.selectedIndex].value\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='forum'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>\n";
}
$projectselect .= '</select>';
$fupselect = "<select name=\"fupnew\">\n";
$query = $db->query("SELECT fid, type, name, fup FROM {$tablepre}forums WHERE fid<>'$fid' AND type<>'sub' ORDER BY displayorder");
while($fup = $db->fetch_array($query)) {
$fups[] = $fup;
}
if(is_array($fups)) {
foreach($fups as $forum1) {
if($forum1['type'] == 'group') {
$selected = $forum1['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
$fupselect .= "<option value=\"$forum1[fid]\" $selected>$forum1[name]</option>\n";
foreach($fups as $forum2) {
if($forum2['type'] == 'forum' && $forum2['fup'] == $forum1['fid']) {
$selected = $forum2['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
$fupselect .= "<option value=\"$forum2[fid]\" $selected> > $forum2[name]</option>\n";
}
}
}
}
foreach($fups as $forum0) {
if($forum0['type'] == 'forum' && $forum0['fup'] == 0) {
$selected = $forum0['fid'] == $forum['fup'] ? "selected=\"selected\"" : NULL;
$fupselect .= "<option value=\"$forum0[fid]\" $selected>$forum0[name]</option>\n";
}
}
}
$fupselect .= '</select>';
$groups = array();
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups");
while($group = $db->fetch_array($query)) {
$groups[] = $group;
}
$styleselect = "<select name=\"styleidnew\"><option value=\"0\">$lang[use_default]</option>";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$styleselect .= "<option value=\"$style[styleid]\" ".
($style['styleid'] == $forum['styleid'] ? 'selected="selected"' : NULL).
">$style[name]</option>\n";
}
$styleselect .= '</select>';
if($forum['autoclose']) {
$forum['autoclosetime'] = abs($forum['autoclose']);
$forum['autoclose'] = $forum['autoclose'] / abs($forum['autoclose']);
}
$viewaccess = $postaccess = $replyaccess = $getattachaccess = $postattachaccess = '';
$query = $db->query("SELECT m.username, a.* FROM {$tablepre}access a LEFT JOIN {$tablepre}members m USING (uid) WHERE a.fid='$fid'");
while($access = $db->fetch_array($query)) {
$member = ", <a href=\"$BASESCRIPT?action=members&operation=access&uid=$access[uid]\" target=\"_blank\">$access[username]</a>";
$viewaccess .= $access['allowview'] > 0 ? $member : NULL;
$postaccess .= $access['allowpost'] > 0 ? $member : NULL;
$replyaccess .= $access['allowreply'] > 0 ? $member : NULL;
$getattachaccess .= $access['allowgetattach'] > 0 ? $member : NULL;
$postattachaccess .= $access['allowpostattach'] > 0 ? $member : NULL;
}
unset($member);
$forum['typemodels'] = unserialize($forum['typemodels']);
if($forum['threadtypes']) {
$forum['threadtypes'] = unserialize($forum['threadtypes']);
$forum['threadtypes']['status'] = 1;
} else {
$forum['threadtypes'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
}
if($forum['threadsorts']) {
$forum['threadsorts'] = unserialize($forum['threadsorts']);
$forum['threadsorts']['status'] = 1;
} else {
$forum['threadsorts'] = array('status' => 0, 'required' => 0, 'listable' => 0, 'prefix' => 0, 'options' => array());
}
$typeselect = $sortselect = '';
$typemodelid = array();
$query = $db->query("SELECT * FROM {$tablepre}threadtypes ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
$typemodelid[] = $type['modelid'];
$typeselected = array();
$enablechecked = '';
$keysort = $type['special'] ? 'threadsorts' : 'threadtypes';
if(isset($forum[$keysort]['flat'][$type['typeid']])) {
$enablechecked = ' checked="checked"';
$typeselected[1] = ' selected="selected"';
} elseif(isset($forum[$keysort]['selectbox'][$type['typeid']])) {
$enablechecked = ' checked="checked"';
$typeselected[2] = ' selected="selected"';
} else {
$typeselected[1] = ' selected="selected"';
}
$showtype = TRUE;
if($type['special'] && !@include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$type['typeid'].'.php') {
$showtype = FALSE;
}
if(!$type['special']) {
$typeselect .= showtablerow('', array('class="td25"'), array(
'<input type="checkbox" name="threadtypesnew[options][enable]['.$type['typeid'].']" value="1" class="checkbox"'.$enablechecked.' />',
$type['name'],
$type['description'],
"<select name=\"threadtypesnew[options][{$type[typeid]}]\"><option value=\"1\" $typeselected[1]>$lang[forums_edit_threadtypes_use_cols]</option><option value=\"2\" $typeselected[2]>$lang[forums_edit_threadtypes_use_choice]</option></select>",
), TRUE);
} else {
$typeselected[3] = $forum['threadsorts']['show'][$type['typeid']] ? ' checked="checked"' : '';
$sortselect .= $showtype ? showtablerow('', array('class="td25"'), array(
'<input type="checkbox" name="threadsortsnew[options][enable]['.$type['typeid'].']" value="1" class="checkbox"'.$enablechecked.' />',
$type['name'],
$type['description'],
"<select name=\"threadsortsnew[options][{$type[typeid]}]\"><option value=\"1\" $typeselected[1]>$lang[forums_edit_threadtypes_use_cols]</option><option value=\"2\" $typeselected[2]>$lang[forums_edit_threadtypes_use_choice]</option></select>",
"<input class=\"checkbox\" type=\"checkbox\" name=\"threadsortsnew[options][show][{$type[typeid]}]\" value=\"3\" $typeselected[3] />"
), TRUE) : '';
}
}
$typeselect = $typeselect ? $typeselect : showtablerow('', array('class="td25"'), $lang['forums_edit_threadtypes_nonexistence'], TRUE);
$sortselect = $sortselect ? $sortselect : showtablerow('', array('class="td25"'), $lang['forums_edit_threadsorts_nonexistence'], TRUE);
$num = 0;
$typemodelshow = FALSE;
$typemodelselect = '<ul class="nofloat" onmouseover="altStyle(this);">';
$query = $db->query("SELECT * FROM {$tablepre}typemodels ORDER BY displayorder");
while($model = $db->fetch_array($query)) {
$num++;
$modelchecked = $forum['typemodels'][$model['id']] ? 'checked' : '';
if(in_array($model['id'], $typemodelid)) {
$typemodelshow = TRUE;
$typemodelselect .= "<li".($modelchecked ? ' class="checked"' : '')."><input class=\"checkbox\" type=\"checkbox\" name=\"typemodel[]\" value=\"$model[id]\" $modelchecked>$model[name]</li>";
}
}
$typemodelselect .= '</ul>';
$forum['postcredits'] = $forum['postcredits'] ? unserialize($forum['postcredits']) : array();
$forum['replycredits'] = $forum['replycredits'] ? unserialize($forum['replycredits']) : array();
$forum['digestcredits'] = $forum['digestcredits'] ? unserialize($forum['digestcredits']) : array();
$forum['postattachcredits'] = $forum['postattachcredits'] ? unserialize($forum['postattachcredits']) : array();
$forum['getattachcredits'] = $forum['getattachcredits'] ? unserialize($forum['getattachcredits']) : array();
$simplebin = sprintf('%08b', $forum['simple']);
$forum['defaultorderfield'] = bindec(substr($simplebin, 0, 2));
$forum['defaultorder'] = ($forum['simple'] & 32) ? 1 : 0;
$forum['subforumsindex'] = bindec(substr($simplebin, 3, 2));
$forum['subforumsindex'] = $forum['subforumsindex'] == 0 ? -1 : ($forum['subforumsindex'] == 2 ? 0 : 1);
$forum['simple'] = $forum['simple'] & 1;
$forum['modrecommend'] = $forum['modrecommend'] ? unserialize($forum['modrecommend']) : '';
$forum['formulaperm'] = unserialize($forum['formulaperm']);$forum['formulaperm'] = $forum['formulaperm'][0];
showtagheader('div', 'basic', $anchor == 'basic');
showtableheader('forums_edit_basic', 'nobottom');
showsetting('forums_edit_basic_name', 'namenew', $forum['name'], 'text');
showsetting('forums_edit_basic_scheme', '', '', $projectselect);
showsetting('forums_edit_basic_display', 'statusnew', $forum['status'], 'radio');
showsetting('forums_edit_basic_up', '', '', $fupselect);
showsetting('forums_edit_basic_redirect', 'redirectnew', $forum['redirect'], 'text');
showsetting('forums_edit_basic_icon', 'iconnew', $forum['icon'], 'text');
showsetting('forums_edit_basic_description', 'descriptionnew', html2bbcode($forum['description']), 'textarea');
showsetting('forums_edit_basic_rules', 'rulesnew', html2bbcode($forum['rules']), 'textarea');
showsetting('forums_edit_basic_keyword', 'keywordsnew', $forum['keywords'], 'text');
showtablefooter();
showtagfooter('div');
showtagheader('div', 'extend', $anchor == 'extend');
showtableheader('forums_edit_extend', 'nobottom');
showsetting('forums_edit_extend_style', '', '', $styleselect);
showsetting('forums_edit_extend_sub_horizontal', 'forumcolumnsnew', $forum['forumcolumns'], 'text');
showsetting('forums_edit_extend_subforumsindex', array('subforumsindexnew', array(
array(-1, $lang['default']),
array(1, $lang['yes']),
array(0, $lang['no'])
), 1), $forum['subforumsindex'], 'mradio');
showsetting('forums_edit_extend_simple', 'simplenew', $forum['simple'], 'radio');
showsetting('forums_edit_extend_recommend_top', 'allowglobalsticknew', $forum['allowglobalstick'], 'radio');
showsetting('forums_edit_extend_defaultorderfield', array('defaultorderfieldnew', array(
array(0, $lang['forums_edit_extend_order_lastpost']),
array(1, $lang['forums_edit_extend_order_starttime']),
array(2, $lang['forums_edit_extend_order_replies']),
array(3, $lang['forums_edit_extend_order_views'])
)), $forum['defaultorderfield'], 'mradio');
showsetting('forums_edit_extend_defaultorder', array('defaultordernew', array(
array(0, $lang['forums_edit_extend_order_desc']),
array(1, $lang['forums_edit_extend_order_asc'])
)), $forum['defaultorder'], 'mradio');
showsetting('forums_edit_extend_threadcache', 'threadcachesnew', $forum['threadcaches'], 'text');
showsetting('forums_edit_extend_edit_rules', 'alloweditrulesnew', $forum['alloweditrules'], 'radio');
if($sideselect) {
showsetting('forums_edit_extend_sideselect', '', '', $sideselect[0]);
}
showsetting('forums_edit_extend_recommend', 'modrecommendnew[open]', $forum['modrecommend']['open'], 'radio', '', 1);
showsetting('forums_edit_extend_recommend_sort', array('modrecommendnew[sort]', array(
array(1, $lang['forums_edit_extend_recommend_sort_auto']),
array(0, $lang['forums_edit_extend_recommend_sort_manual']),
array(2, $lang['forums_edit_extend_recommend_sort_mix']))), $forum['modrecommend']['sort'], 'mradio');
showsetting('forums_edit_extend_recommend_orderby', array('modrecommendnew[orderby]', array(
array(0, $lang['forums_edit_extend_recommend_orderby_dateline']),
array(1, $lang['forums_edit_extend_recommend_orderby_lastpost']),
array(2, $lang['forums_edit_extend_recommend_orderby_views']),
array(3, $lang['forums_edit_extend_recommend_orderby_replies']),
array(4, $lang['forums_edit_extend_recommend_orderby_digest']))), $forum['modrecommend']['orderby'], 'mradio');
showsetting('forums_edit_extend_recommend_num', 'modrecommendnew[num]', $forum['modrecommend']['num'], 'text');
showsetting('forums_edit_extend_recommend_maxlength', 'modrecommendnew[maxlength]', $forum['modrecommend']['maxlength'], 'text');
showsetting('forums_edit_extend_recommend_cachelife', 'modrecommendnew[cachelife]', $forum['modrecommend']['cachelife'], 'text');
showsetting('forums_edit_extend_recommend_dateline', 'modrecommendnew[dateline]', $forum['modrecommend']['dateline'], 'text');
showtablefooter();
showtagfooter('div');
showtagheader('div', 'posts', $anchor == 'posts');
showtableheader('forums_edit_posts', 'nobottom');
showsetting('forums_edit_posts_modposts', array('modnewpostsnew', array(
array(0, $lang['none']),
array(1, $lang['forums_edit_posts_modposts_threads']),
array(2, $lang['forums_edit_posts_modposts_posts'])
)), $forum['modnewposts'], 'mradio');
showsetting('forums_edit_posts_alloweditpost', 'alloweditpostnew', $forum['alloweditpost'], 'radio');
showsetting('forums_edit_posts_recyclebin', 'recyclebinnew', $forum['recyclebin'], 'radio');
showsetting('forums_edit_posts_html', 'allowhtmlnew', $forum['allowhtml'], 'radio');
showsetting('forums_edit_posts_bbcode', 'allowbbcodenew', $forum['allowbbcode'], 'radio');
showsetting('forums_edit_posts_imgcode', 'allowimgcodenew', $forum['allowimgcode'], 'radio');
showsetting('forums_edit_posts_mediacode', 'allowmediacodenew', $forum['allowmediacode'], 'radio');
showsetting('forums_edit_posts_smilies', 'allowsmiliesnew', $forum['allowsmilies'], 'radio');
showsetting('forums_edit_posts_jammer', 'jammernew', $forum['jammer'], 'radio');
showsetting('forums_edit_posts_anonymous', 'allowanonymousnew', $forum['allowanonymous'], 'radio');
showsetting('forums_edit_posts_disablewatermark', 'disablewatermarknew', $forum['disablewatermark'], 'radio');
if($_DCACHE['settings']['uchome']['addfeed']) {
showsetting('forums_edit_posts_allowfeed', 'allowfeednew', $forum['allowfeed'], 'radio');
}
if($tagstatus) {
showsetting('forums_edit_posts_tagstatus', array('allowtagnew', array(
array(0, $lang['forums_edit_posts_tagstatus_none']),
array(1, $lang['forums_edit_posts_tagstatus_use']),
array(2, $lang['forums_edit_posts_tagstatus_quired'])
)), $forum['allowtag'], 'mradio');
}
showsetting('forums_edit_posts_allowpostspecial', array('allowpostspecialnew', array(
$lang['thread_poll'],
$lang['thread_trade'],
$lang['thread_reward'],
$lang['thread_activity'],
$lang['thread_debate'],
$lang['thread_video']
)), $forum['allowpostspecial'], 'binmcheckbox');
showsetting('forums_edit_posts_allowspecialonly', 'allowspecialonlynew', $forum['allowspecialonly'], 'radio');
if(!empty($tradetypes) && is_array($tradetypes)) {
$forum['tradetypes'] = $forum['tradetypes'] == '' ? -1 : unserialize($forum['tradetypes']);
$tradetypeselect = '';
foreach($tradetypes as $typeid => $typename) {
$tradetypeselect .= '<input class="checkbox" type="checkbox" name="tradetypesnew[]" value="'.$typeid.'" '.($forum['tradetypes'] == -1 || @in_array($typeid, $forum['tradetypes']) ? 'checked' : '').'> '.$typename.'<br />';
}
showsetting('forums_edit_posts_trade_type', '', '', $tradetypeselect);
}
showsetting('forums_edit_posts_autoclose', array('autoclosenew', array(
array(0, $lang['forums_edit_posts_autoclose_none'], array('autoclose_time' => 'none')),
array(1, $lang['forums_edit_posts_autoclose_dateline'], array('autoclose_time' => '')),
array(-1, $lang['forums_edit_posts_autoclose_lastpost'], array('autoclose_time' => ''))
)), $forum['autoclose'], 'mradio');
showtagheader('tbody', 'autoclose_time', $forum['autoclose'], 'sub');
showsetting('forums_edit_posts_autoclose_time', 'autoclosetimenew', $forum['autoclosetime'], 'text');
showtagfooter('tbody');
showsetting('forums_edit_posts_attach_ext', 'attachextensionsnew', $forum['attachextensions'], 'text');
showtablefooter();
showtagfooter('div');
showtagheader('div', 'credits', $anchor == 'credits');
showtableheader('forums_edit_credits', 'nobottom');
echo '<tr ><td>'.$lang['credits_id'].'</td><td>'.$lang['credits_title'].'</td><td>'.$lang['forums_edit_credits_postcredits_add'].'</td><td>'.$lang['forums_edit_credits_replycredits_add'].'</td><td>'.$lang['settings_credits_policy_digest'].'</td><td>'.$lang['settings_credits_policy_postattach'].'</td><td>'.$lang['settings_credits_policy_getattach'].'</td></tr>';
$customcreditspolicy = '';
if(is_array($extcredits)) {
foreach($extcredits as $i => $extcredit) {
$customcreditspolicy .= showtablerow('', '', array(
"extcredits$i",
$extcredit['title'],
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"postcreditsnew[$i]\" value=\"".$forum['postcredits'][$i]."\" />",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"replycreditsnew[$i]\" value=\"".$forum['replycredits'][$i]."\" />",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"digestcreditsnew[$i]\" value=\"".$forum['digestcredits'][$i]."\" />",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"postattachcreditsnew[$i]\" value=\"".$forum['postattachcredits'][$i]."\" />",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"getattachcreditsnew[$i]\" value=\"".$forum['getattachcredits'][$i]."\" />"
), TRUE);
}
}
$customcreditspolicy .= '<tr><td colspan="7">'.$lang['forums_edit_credits_comment'].'</td></tr>';
echo $customcreditspolicy;
showtablefooter();
showtagfooter('div');
if($allowthreadtypes) {
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'<input type="checkbox" class="checkbox" name="newenable[]" checked="checked" />', 'td25'],
[1,'<input type="text" class="txt" name="newname[]" size="15" />'],
[1,'<input type="text" class="txt" name="newdescription[]" size="15" />'],
[1,'<select name="newoptions[]"><option value="1" selected="selected">$lang[forums_edit_threadtypes_use_cols]</option><option value="2">$lang[forums_edit_threadtypes_use_choice]</option></select>'],
[1,'']
],
];
</script>
EOT;
showtagheader('div', 'threadtypes', $anchor == 'threadtypes');
showtableheader('forums_edit_threadtypes', 'nobottom');
showsetting('forums_edit_threadtypes_status', array('threadtypesnew[status]', array(
array(1, $lang['yes'], array('threadtypes_config' => '', 'threadtypes_manage' => '')),
array(0, $lang['no'], array('threadtypes_config' => 'none', 'threadtypes_manage' => 'none'))
), TRUE), $forum['threadtypes']['status'], 'mradio');
showtagheader('tbody', 'threadtypes_config', $forum['threadtypes']['status']);
showsetting('forums_edit_threadtypes_required', 'threadtypesnew[required]', $forum['threadtypes']['required'], 'radio');
showsetting('forums_edit_threadtypes_listable', 'threadtypesnew[listable]', $forum['threadtypes']['listable'], 'radio');
showsetting('forums_edit_threadtypes_prefix', 'threadtypesnew[prefix]', $forum['threadtypes']['prefix'], 'radio');
showtagfooter('tbody');
showtablefooter();
showtagheader('div', 'threadtypes_manage', $forum['threadtypes']['status']);
showtableheader('', 'noborder fixpadding');
showsubtitle(array('enable', 'forums_edit_threadtypes_name', 'forums_edit_threadtypes_note', 'forums_edit_threadtypes_showtype', 'forums_edit_threadtypes_show'));
echo $typeselect;
echo '<tr><td colspan="6"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.lang('threadtype_infotypes_add').'</a></div></td></tr>';
echo '<tr><td class="lineheight" colspan="6">'.$lang['forums_edit_threadtypes_comment'].'</td></tr>';
showtablefooter();
showtagfooter('div');
showtagfooter('div');
showtagheader('div', 'threadsorts', $anchor == 'threadsorts');
showtableheader('forums_edit_threadsorts', 'nobottom');
showsetting('forums_edit_threadsorts_status', array('threadsortsnew[status]', array(
array(1, $lang['yes'], array('threadsorts_config' => '', 'threadsorts_manage' => '')),
array(0, $lang['no'], array('threadsorts_config' => 'none', 'threadsorts_manage' => 'none'))
), TRUE), $forum['threadsorts']['status'], 'mradio');
showtagheader('tbody', 'threadsorts_config', $forum['threadsorts']['status']);
showsetting('forums_edit_threadtypes_required', 'threadsortsnew[required]', $forum['threadsorts']['required'], 'radio');
showsetting('forums_edit_threadtypes_listable', 'threadsortsnew[listable]', $forum['threadsorts']['listable'], 'radio');
showsetting('forums_edit_threadtypes_prefix', 'threadsortsnew[prefix]', $forum['threadsorts']['prefix'], 'radio');
if($typemodelshow) {
showsetting('forums_edit_threadsorts_typemodel', '', '', $typemodelselect);
}
showtagfooter('tbody');
showtablefooter();
showtagheader('div', 'threadsorts_manage', $forum['threadsorts']['status']);
showtableheader('', 'noborder fixpadding');
showsubtitle(array('enable', 'forums_edit_threadtypes_name', 'forums_edit_threadtypes_note', 'forums_edit_threadtypes_showtype', 'forums_edit_threadtypes_show'));
echo $sortselect;
showtablefooter();
showtagfooter('div');
showtagfooter('div');
}
showtagheader('div', 'perm', $anchor == 'perm');
showtableheader('forums_edit_perm_forum', 'nobottom');
showsetting('forums_edit_perm_passwd', 'passwordnew', $forum['password'], 'text');
showtablefooter();
showtableheader('forums_edit_perm_forum', 'noborder fixpadding');
showsubtitle(array(
'',
'<input class="checkbox" type="checkbox" name="chkall1" onclick="checkAll(\'prefix\', this.form, \'viewperm\', \'chkall1\')" id="chkall1" /><label for="chkall1"> '.$lang['forums_edit_perm_view'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'postperm\', \'chkall2\')" id="chkall2" /><label for="chkall2"> '.$lang['forums_edit_perm_post'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall3" onclick="checkAll(\'prefix\', this.form, \'replyperm\', \'chkall3\')" id="chkall3" /><label for="chkall3"> '.$lang['forums_edit_perm_reply'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall4" onclick="checkAll(\'prefix\', this.form, \'getattachperm\', \'chkall4\')" id="chkall4" /><label for="chkall4"> '.$lang['forums_edit_perm_getattach'].'</label>',
'<input class="checkbox" type="checkbox" name="chkall5" onclick="checkAll(\'prefix\', this.form, \'postattachperm\', \'chkall5\')" id="chkall5" /><label for="chkall5"> '.$lang['forums_edit_perm_postattach'].'</label>'
));
foreach($groups as $group) {
$colums = array('<input class="checkbox" title="'.$lang['select_all'].'" type="checkbox" name="chkallv'.$group['groupid'].'" onclick="checkAll(\'value\', this.form, '.$group['groupid'].', \'chkallv'.$group['groupid'].'\')" id="chkallv_'.$group['groupid'].'" /><label for="chkallv_'.$group['groupid'].'"> '.$group[grouptitle].'</label>');
foreach($perms as $perm) {
$checked = strstr($forum[$perm], "\t$group[groupid]\t") ? 'checked="checked"' : NULL;
$colums[] = '<input class="checkbox" type="checkbox" name="'.$perm.'[]" value="'.$group['groupid'].'" chkvalue="'.$group['groupid'].'" '.$checked.'>';
}
showtablerow('', '', $colums);
}
showtablerow('', 'class="lineheight" colspan="6"', $lang['forums_edit_perm_forum_comment']);
showtablefooter();
showtableheader('forums_edit_perm_formula', 'noborder fixpadding');
$formulareplace .= '\'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\',\'<u>'.$lang['settings_credits_formula_posts'].'</u>\',\'<u>'.$lang['settings_credits_formula_oltime'].'</u>\',\'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\'';
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, textend) {
$('formulapermnew').focus();
textend = isUndefined(textend) ? '' : textend;
if(!isUndefined($('formulapermnew').selectionStart)) {
var opn = $('formulapermnew').selectionStart + 0;
if(textend != '') {
text = text + $('formulapermnew').value.substring($('formulapermnew').selectionStart, $('formulapermnew').selectionEnd) + textend;
}
$('formulapermnew').value = $('formulapermnew').value.substr(0, $('formulapermnew').selectionStart) + text + $('formulapermnew').value.substr($('formulapermnew').selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
if(textend != '') {
text = text + sel.text + textend;
}
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$('formulapermnew').value += text;
}
formulaexp();
}
var formulafind = new Array('digestposts', 'posts', 'oltime', 'pageviews');
var formulareplace = new Array(<?php echo $formulareplace?>);
function formulaexp() {
var result = $('formulapermnew').value;
<?php
$extcreditsbtn = '';
for($i = 1; $i <= 8; $i++) {
$extcredittitle = $extcredits[$i]['title'] ? $extcredits[$i]['title'] : $lang['settings_credits_formula_extcredits'].$i;
echo 'result = result.replace(/extcredits'.$i.'/g, \'<u>'.str_replace("'", "\'", $extcredittitle).'</u>\');';
$extcreditsbtn .= '<a href="###" onclick="insertunit(\'extcredits'.$i.'\')">'.$extcredittitle.'</a> ';
}
echo 'result = result.replace(/digestposts/g, \'<u>'.$lang['settings_credits_formula_digestposts'].'</u>\');';
echo 'result = result.replace(/posts/g, \'<u>'.$lang['settings_credits_formula_posts'].'</u>\');';
echo 'result = result.replace(/oltime/g, \'<u>'.$lang['settings_credits_formula_oltime'].'</u>\');';
echo 'result = result.replace(/pageviews/g, \'<u>'.$lang['settings_credits_formula_pageviews'].'</u>\');';
echo 'result = result.replace(/and/g, \' '.$lang['forums_edit_perm_formula_and'].' \');';
echo 'result = result.replace(/or/g, \' '.$lang['forums_edit_perm_formula_or'].' \');';
echo 'result = result.replace(/>=/g, \'≥\');';
echo 'result = result.replace(/<=/g, \'≤\');';
?>
$('formulapermexp').innerHTML = result;
}
</script>
<tr><td colspan="2"><div class="extcredits">
<?php echo $extcreditsbtn?><br />
<a href="###" onclick="insertunit(' digestposts ')"><?php echo lang('forums_edit_perm_formula_digestposts')?></a>
<a href="###" onclick="insertunit(' posts ')"><?php echo lang('forums_edit_perm_formula_posts')?></a>
<a href="###" onclick="insertunit(' oltime ')"><?php echo lang('forums_edit_perm_formula_oltime')?></a>
<a href="###" onclick="insertunit(' pageviews ')"><?php echo lang('forums_edit_perm_formula_pageviews')?></a>
<a href="###" onclick="insertunit(' + ')"> + </a>
<a href="###" onclick="insertunit(' - ')"> - </a>
<a href="###" onclick="insertunit(' * ')"> * </a>
<a href="###" onclick="insertunit(' / ')"> / </a>
<a href="###" onclick="insertunit(' > ')"> > </a>
<a href="###" onclick="insertunit(' >= ')"> >= </a>
<a href="###" onclick="insertunit(' < ')"> < </a>
<a href="###" onclick="insertunit(' <= ')"> <= </a>
<a href="###" onclick="insertunit(' = ')"> = </a>
<a href="###" onclick="insertunit(' (', ') ')"> ( ) </a>
<a href="###" onclick="insertunit(' and ')"> <?php echo lang('forums_edit_perm_formula_and')?> </a>
<a href="###" onclick="insertunit(' or ')"> <?php echo lang('forums_edit_perm_formula_or')?> </a> <br />
<div id="formulapermexp" class="margintop marginbot diffcolor2"><?php echo $formulapermexp?></div>
</div>
<textarea name="formulapermnew" id="formulapermnew" class="marginbot" style="width:80%" rows="3" onkeyup="formulaexp()"><?php echo dhtmlspecialchars($forum['formulaperm'])?></textarea>
<script type="text/JavaScript">formulaexp()</script>
<br /><span class="smalltxt"><?=$lang['forums_edit_perm_formula_comment']?></span>
<br /><?php echo lang('creditwizard_current_formula_notice')?>
</td></tr>
<?php
showtablefooter();
showtagfooter('div');
showtableheader('', 'notop');
showsubmit('detailsubmit', 'submit', '', $forum['type'] != 'group' ? '<input type="submit" class="btn" name="saveconfigsubmit" value="'.$lang['saveconf'].'">' : '');
showtablefooter();
}
showformfooter();
} else {
if(strlen($namenew) > 50) {
cpmsg('forums_name_toolong', '', 'error');
}
if($formulapermnew && !preg_match("/^(\+|\-|\*|\/|\.|>|<|=|\d|\s|extcredits[1-8]|digestposts|posts|pageviews|oltime|and|or)+$/", $formulapermnew) || !is_null(@eval(preg_replace("/(digestposts|posts|pageviews|oltime|extcredits[1-8])/", "\$\\1", $formulapermnew).';'))) {
cpmsg('forums_formulaperm_error', '', 'error');
}
$formulapermary[0] = $formulapermnew;
$formulapermary[1] = preg_replace("/(digestposts|posts|pageviews|oltime|extcredits[1-8])/", "\$_DSESSION['\\1']", $formulapermnew);
$formulapermnew = addslashes(serialize($formulapermary));
if($type == 'group') {
if($namenew) {
if($foruminfosidestatus) {
$infosidestatusnew = $infosidestatus;
unset($infosidestatusnew['f'.$fid]);
$foruminfosidestatus[0] != $infosidestatus[2] && $foruminfosidestatus[0] != '' && $infosidestatusnew['f'.$fid][0] = $foruminfosidestatus[0];
$foruminfosidestatus['posts'] != $infosidestatus['posts'] && $foruminfosidestatus['posts'] != '' && $infosidestatusnew['f'.$fid]['posts'] = $foruminfosidestatus['posts'];
if($infosidestatus != $infosidestatusnew) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".(addslashes(serialize($infosidestatusnew)))."')");
updatecache('settings');
}
}
$forumcolumnsnew = $forumcolumnsnew > 1 ? intval($forumcolumnsnew) : 0;
$db->query("UPDATE {$tablepre}forums SET name='$namenew',forumcolumns='".$forumcolumnsnew."',status='".intval($statusnew)."' WHERE fid='$fid'");
updatecache('forums');
cpmsg('forums_edit_succeed', $BASESCRIPT.'?action=forums', 'succeed');
} else {
cpmsg('forums_edit_name_invalid', '', 'error');
}
} else {
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$extensionarray = array();
foreach(explode(',', $attachextensionsnew) as $extension) {
if($extension = trim($extension)) {
$extensionarray[] = $extension;
}
}
$attachextensionsnew = implode(', ', $extensionarray);
foreach($perms as $perm) {
${$perm.'new'} = is_array($$perm) && !empty($$perm) ? "\t".implode("\t", $$perm)."\t" : '';
}
$fupadd = '';
if($fupnew != $forum['fup']) {
$query = $db->query("SELECT fid FROM {$tablepre}forums WHERE fup='$fid'");
if($db->num_rows($query)) {
cpmsg('forums_edit_sub_notnull', '', 'error');
}
$fup = $db->fetch_first("SELECT fid, type, inheritedmod FROM {$tablepre}forums WHERE fid='$fupnew'");
$fupadd = ", type='".($fup['type'] == 'forum' ? 'sub' : 'forum')."', fup='$fup[fid]'";
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid' AND inherited='1'");
$query = $db->query("SELECT * FROM {$tablepre}moderators WHERE fid='$fupnew' ".($fup['inheritedmod'] ? '' : "AND inherited='1'"));
while($mod = $db->fetch_array($query)) {
$db->query("REPLACE INTO {$tablepre}moderators (uid, fid, displayorder, inherited)
VALUES ('$mod[uid]', '$fid', '0', '1')");
}
$moderators = $tab = '';
$query = $db->query("SELECT m.username FROM {$tablepre}members m, {$tablepre}moderators mo WHERE mo.fid='$fid' AND mo.inherited='0' AND m.uid=mo.uid ORDER BY mo.displayorder");
while($mod = $db->fetch_array($query)) {
$moderators .= $tab.addslashes($mod['username']);
$tab = "\t";
}
$db->query("UPDATE {$tablepre}forumfields SET moderators='$moderators' WHERE fid='$fid'");
}
$allowpostspecialtrade = intval($allowpostspecialnew[2]);
$allowpostspecialnew = bindec(intval($allowpostspecialnew[6]).intval($allowpostspecialnew[5]).intval($allowpostspecialnew[4]).intval($allowpostspecialnew[3]).intval($allowpostspecialnew[2]).intval($allowpostspecialnew[1]));
$allowspecialonlynew = $allowpostspecialnew ? $allowspecialonlynew : 0;
$forumcolumnsnew = $forumcolumnsnew > 1 ? intval($forumcolumnsnew) : 0;
$threadcachesnew = max(0, min(100, intval($threadcachesnew)));
$subforumsindexnew = $subforumsindexnew == -1 ? 0 : ($subforumsindexnew == 0 ? 2 : 1);
$simplenew = bindec(sprintf('%02d', decbin($defaultorderfieldnew)).$defaultordernew.sprintf('%02d', decbin($subforumsindexnew)).'00'.$simplenew);
$allowglobalsticknew = $allowglobalsticknew ? 1 : 0;
$db->query("UPDATE {$tablepre}forums SET status='$statusnew', name='$namenew', styleid='$styleidnew', alloweditpost='$alloweditpostnew',
allowpostspecial='$allowpostspecialnew', allowspecialonly='$allowspecialonlynew', allowhtml='$allowhtmlnew', allowbbcode='$allowbbcodenew', allowimgcode='$allowimgcodenew', allowmediacode='$allowmediacodenew',
allowsmilies='$allowsmiliesnew', alloweditrules='$alloweditrulesnew', allowfeed='$allowfeednew', modnewposts='$modnewpostsnew',
recyclebin='$recyclebinnew', jammer='$jammernew', allowanonymous='$allowanonymousnew', forumcolumns='$forumcolumnsnew', threadcaches='$threadcachesnew',
simple='$simplenew', allowglobalstick='$allowglobalsticknew', disablewatermark='$disablewatermarknew', allowtag='$allowtagnew', autoclose='".intval($autoclosenew * $autoclosetimenew)."' $fupadd
WHERE fid='$fid'");
$query = $db->query("SELECT fid FROM {$tablepre}forumfields WHERE fid='$fid'");
if(!($db->num_rows($query))) {
$db->query("INSERT INTO {$tablepre}forumfields (fid)
VALUES ('$fid')");
}
foreach(array('post', 'reply', 'digest', 'postattach', 'getattach') as $item) {
if(${$item.'creditsnew'}) {
foreach(${$item.'creditsnew'} as $i => $v) {
if($v == '') {
unset(${$item.'creditsnew'}[$i]);
} else {
$v = intval($v);
${$item.'creditsnew'}[$i] = $v < -99 ? -99 : $v;
${$item.'creditsnew'}[$i] = $v > 99 ? 99 : $v;
}
}
}
${$item.'creditsnew'} = ${$item.'creditsnew'} ? addslashes(serialize(${$item.'creditsnew'})) : '';
}
$threadtypesnew['types'] = $threadtypesnew['flat'] = $threadtypes['selectbox'] = $threadtypes['special'] = $threadtypes['show'] = array();
$threadsortsnew['types'] = $threadsortsnew['flat'] = $threadsorts['selectbox'] = $threadsorts['special'] = $threadsorts['show'] = array();
if($allowthreadtypes) {
if(is_array($newname) && $newname) {
$newname = array_unique($newname);
if($newname) {
foreach($newname as $key => $val) {
$val = trim($val);
if($newenable[$key] && $val) {
$newtypeid = $db->result_first("SELECT typeid FROM {$tablepre}threadtypes WHERE name='$val'");
if(!$newtypeid) {
$db->query("INSERT INTO {$tablepre}threadtypes (name, description) VALUES
('$val', '".dhtmlspecialchars(trim($newdescription[$key]))."')");
$newtypeid = $db->insert_id();
}
if($newoptions[$key] == 1) {
$threadtypesnew['types'][$newtypeid] = $threadtypesnew['flat'][$newtypeid] = $val;
} elseif($newoptions[$key] == 2) {
$threadtypesnew['types'][$newtypeid] = $threadtypesnew['selectbox'][$newtypeid] = $val;
}
}
}
}
$threadtypesnew['status'] = 1;
} else {
$newname = array();
}
if($threadtypesnew['status']) {
if(is_array($threadtypesnew['options']) && $threadtypesnew['options']) {
$typeids = '0';
foreach($threadtypesnew['options'] as $key => $val) {
$typeids .= $val ? ', '.intval($key) : '';
}
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($typeids) AND special='' ORDER BY displayorder");
while($type = $db->fetch_array($query)) {
if($threadtypesnew['options']['enable'][$type['typeid']]) {
if($threadtypesnew['options'][$type['typeid']] == 1) {
$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['flat'][$type['typeid']] = $type['name'];
} elseif($threadtypesnew['options'][$type['typeid']] == 2) {
$threadtypesnew['types'][$type['typeid']] = $threadtypesnew['selectbox'][$type['typeid']] = $type['name'];
}
}
}
}
$threadtypesnew = $threadtypesnew['types'] ? addslashes(serialize(array
(
'required' => (bool)$threadtypesnew['required'],
'listable' => (bool)$threadtypesnew['listable'],
'prefix' => (bool)$threadtypesnew['prefix'],
'types' => $threadtypesnew['types'],
'selectbox' => $threadtypesnew['selectbox'],
'flat' => $threadtypesnew['flat'],
))) : '';
} else {
$threadtypesnew = '';
}
$threadtypesadd = "threadtypes='$threadtypesnew',";
if($threadsortsnew['status']) {
if(is_array($threadsortsnew['options']) && $threadsortsnew['options']) {
$sortids = '0';
foreach($threadsortsnew['options'] as $key => $val) {
$sortids .= $val ? ', '.intval($key) : '';
}
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE typeid IN ($sortids) AND special='1' ORDER BY displayorder");
while($sort = $db->fetch_array($query)) {
if($threadsortsnew['options']['enable'][$sort['typeid']]) {
if($threadsortsnew['options'][$sort['typeid']] == 1) {
$threadsortsnew['types'][$sort['typeid']] = $threadsortsnew['flat'][$sort['typeid']] = $sort['name'];
} elseif($threadsortsnew['options'][$sort['typeid']] == 2) {
$threadsortsnew['types'][$sort['typeid']] = $threadsortsnew['selectbox'][$sort['typeid']] = $sort['name'];
}
}
$threadsortsnew['expiration'][$sort['typeid']] = $sort['expiration'];
$threadsortsnew['show'][$sort['typeid']] = $threadsortsnew['options']['show'][$sort['typeid']] ? 1 : 0;
$threadsortsnew['typemodelid'][$sort['typeid']] = $sort['modelid'];
}
}
$threadsortsnew = $threadsortsnew['types'] ? addslashes(serialize(array
(
'required' => (bool)$threadsortsnew['required'],
'listable' => (bool)$threadsortsnew['listable'],
'prefix' => (bool)$threadsortsnew['prefix'],
'types' => $threadsortsnew['types'],
'selectbox' => $threadsortsnew['selectbox'],
'flat' => $threadsortsnew['flat'],
'show' => $threadsortsnew['show'],
'expiration' => $threadsortsnew['expiration'],
'modelid' => $threadsortsnew['typemodelid'],
))) : '';
} else {
$threadsortsnew = '';
}
$threadsortsadd = "threadsorts='$threadsortsnew',";
if($typemodel) {
$query = $db->query("SELECT id, name FROM {$tablepre}typemodels WHERE id IN (".implodeids($typemodel).") ORDER BY displayorder");
while($model = $db->fetch_array($query)) {
$threadtypemodel[$model['id']]['name'] = $model['name'];
}
$threadtypemodeladd = addslashes(serialize($threadtypemodel));
}
} else {
$threadtypesadd = $threadsortsadd = $threadtypemodeladd = '';
}
if(!empty($tradetypes) && is_array($tradetypes) && $allowpostspecialtrade) {
if(count($tradetypes) == count($tradetypesnew)) {
$tradetypesnew = '';
} else {
$tradetypesnew = addslashes(serialize($tradetypesnew));
}
} else {
$tradetypesnew = '';
}
$modrecommendnew['num'] = $modrecommendnew['num'] ? intval($modrecommendnew['num']) : 10;
$modrecommendnew['cachelife'] = $modrecommendnew['cachelife'] ? intval($modrecommendnew['cachelife']) : 900;
$modrecommendnew['maxlength'] = $modrecommendnew['maxlength'] ? intval($modrecommendnew['maxlength']) : 0;
$modrecommendnew['dateline'] = $modrecommendnew['dateline'] ? intval($modrecommendnew['dateline']) : 0;
$modrecommendnew = $modrecommendnew && is_array($modrecommendnew) ? addslashes(serialize($modrecommendnew)) : '';
$descriptionnew = addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($descriptionnew), 1, 0, 0, 0, 1, 1, 0, 0, 1)));
$rulesnew = addslashes(preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode(stripslashes($rulesnew), 1, 0, 0, 0, 1, 1, 0, 0, 1)));
$db->query("UPDATE {$tablepre}forumfields SET description='$descriptionnew', icon='$iconnew', password='$passwordnew', redirect='$redirectnew', rules='$rulesnew',
attachextensions='$attachextensionsnew', $threadtypesadd $threadsortsadd postcredits='$postcreditsnew', replycredits='$replycreditsnew', digestcredits='$digestcreditsnew',
postattachcredits='$postattachcreditsnew', getattachcredits='$getattachcreditsnew', viewperm='$viewpermnew', postperm='$postpermnew', replyperm='$replypermnew', tradetypes='$tradetypesnew', typemodels='$threadtypemodeladd',
getattachperm='$getattachpermnew', postattachperm='$postattachpermnew', formulaperm='$formulapermnew', modrecommend='$modrecommendnew', keywords='$keywordsnew' WHERE fid='$fid'");
if($modrecommendnew && !$modrecommendnew['sort']) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
recommendupdate($fid, $modrecommendnew, '1');
}
if($statusnew == 0) {
$db->query("UPDATE {$tablepre}forums SET status='$statusnew' WHERE fup='$fid'", 'UNBUFFERED');
}
updatecache('forums');
if($foruminfosidestatus) {
$infosidestatusnew = $infosidestatus;
unset($infosidestatusnew['f'.$fid]);
$foruminfosidestatus[0] != $infosidestatus[0] && $foruminfosidestatus[0] != '' && $infosidestatusnew['f'.$fid][0] = $foruminfosidestatus[0];
$foruminfosidestatus['posts'] != $infosidestatus['posts'] && $foruminfosidestatus['posts'] != '' && $infosidestatusnew['f'.$fid]['posts'] = $foruminfosidestatus['posts'];
if($infosidestatus != $infosidestatusnew) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".(addslashes(serialize($infosidestatusnew)))."')");
updatecache('settings');
}
}
if(submitcheck('saveconfigsubmit') && $type != 'group') {
$projectid = intval($projectid);
dheader("Location: $boardurl$BASESCRIPT?action=project&operation=add&id=$fid&type=forum&projectid=$projectid");
} else {
cpmsg('forums_edit_succeed', "$BASESCRIPT?action=forums&operation=edit&fid=$fid".($anchor ? "&anchor=$anchor" : ''), 'succeed');
}
}
}
} elseif($operation == 'delete') {
if($ajax) {
ob_end_clean();
require_once DISCUZ_ROOT.'./include/post.func.php';
$tids = 0;
$total = intval($total);
$pp = intval($pp);
$currow = intval($currow);
$query = $db->query("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' LIMIT $pp");
while($thread = $db->fetch_array($query)) {
$tids .= ','.$thread['tid'];
}
if($tids) {
$query = $db->query("SELECT attachment, thumb, remote FROM {$tablepre}attachments WHERE tid IN ($tids)");
while($attach = $db->fetch_array($query)) {
dunlink($attach['attachment'], $attach['thumb'], $attach['remote']);
}
foreach(array('threads', 'threadsmod', 'relatedthreads', 'posts', 'polls', 'polloptions', 'trades', 'activities', 'activityapplies', 'debates', 'debateposts', 'videos', 'attachments', 'favorites', 'mythreads', 'myposts', 'subscriptions', 'typeoptionvars', 'forumrecommend') as $value) {
$db->query("DELETE FROM {$tablepre}$value WHERE tid IN ($tids)", 'UNBUFFERED');
}
}
if($currow + $pp > $total) {
$db->query("DELETE FROM {$tablepre}forums WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}forumfields WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}moderators WHERE fid='$fid'");
$db->query("DELETE FROM {$tablepre}access WHERE fid='$fid'");
echo 'TRUE';
exit;
}
echo 'GO';
exit;
} else {
if($finished) {
updatecache('forums');
cpmsg('forums_delete_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}forums WHERE fup='$fid'")) {
cpmsg('forums_delete_sub_notnull', '', 'error');
}
if(!$confirmed) {
cpmsg('forums_delete_confirm', "$BASESCRIPT?action=forums&operation=delete&fid=$fid", 'form');
} else {
$threads = $db->result_first("SELECT COUNT(*) FROM {$tablepre}threads WHERE fid='$fid'");
cpmsg('forums_delete_alarm', "$BASESCRIPT?action=forums&operation=delete&fid=$fid&confirmed=1", 'loadingform', '<div id="percent">0%</div>', FALSE);
echo "
<div id=\"statusid\" style=\"display:none\"></div>
<script type=\"text/JavaScript\">
var xml_http_building_link = '".$lang['xml_http_building_link']."';
var xml_http_sending = '".$lang['xml_http_sending']."';
var xml_http_loading = '".$lang['xml_http_loading']."';
var xml_http_load_failed = '".$lang['xml_http_load_failed']."';
var xml_http_data_in_processed = '".$lang['xml_http_data_in_processed']."';
var adminfilename = '$BASESCRIPT';
function forumsdelete(url, total, pp, currow) {
var x = new Ajax('HTML', 'statusid');
x.get(url+'&ajax=1&pp='+pp+'&total='+total+'&currow='+currow, function(s) {
if(s != 'GO') {
location.href = adminfilename + '?action=forums&operation=delete&finished=1';
}
currow += pp;
var percent = ((currow / total) * 100).toFixed(0);
percent = percent > 100 ? 100 : percent;
document.getElementById('percent').innerHTML = percent+'%';
document.getElementById('percent').style.backgroundPosition = '-'+percent+'%';
if(currow < total) {
forumsdelete(url, total, pp, currow);
}
});
}
forumsdelete(adminfilename + '?action=forums&operation=delete&fid=$fid&confirmed=1', $threads, 2000, 0);
</script>
";
}
}
} elseif($operation == 'copy') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$source = intval($source);
$sourceforum = $_DCACHE['forums'][$source];
if(empty($sourceforum) || $sourceforum['type'] == 'group') {
cpmsg('forums_copy_source_invalid', '', 'error');
}
$optgroups = array
(
'normal' => array('modnewposts', 'recyclebin', 'allowshare', 'allowhtml', 'allowbbcode', 'allowimgcode', 'allowmediacode', 'allowsmilies', 'jammer', 'allowanonymous', 'disablewatermark', 'allowpostspecial'),
'credits' => array('postcredits', 'replycredits'),
'access' => array('password', 'viewperm', 'postperm', 'replyperm', 'getattachperm' ,'postattachperm', 'formulaperm'),
'misc' => array('threadtypes', 'attachextensions', 'modrecommend', 'tradetypes')
);
if(!submitcheck('copysubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="target[]" size="10" multiple="multiple">'.forumselect().'</select>';
$optselect = '<select name="options[]" size="10" multiple="multiple">';
foreach($optgroups as $optgroup => $options) {
$optselect .= '<optgroup label="'.$lang['forums_copy_optgroups_'.$optgroup]."\">\n";
foreach($options as $option) {
$optselect .= "<option value=\"$option\">".$lang['forums_copy_options_'.$option]."</option>\n";
}
}
$optselect .= '</select>';
shownav('forum', 'forums_copy');
showsubmenu('forums_copy');
showtips('forums_copy_tips');
showformheader('forums&operation=copy');
showhiddenfields(array('source' => $source));
showtableheader();
showtitle($lang['forums_copy']);
showsetting(lang('forums_copy_source').':','','', $sourceforum['name']);
showsetting('forums_copy_target', '', '', $forumselect);
showsetting('forums_copy_options', '', '', $optselect);
showsubmit('copysubmit');
showtablefooter();
showformfooter();
} else {
$fids = $comma = '';
if(is_array($target) && count($target)) {
foreach($target as $fid) {
if(($fid = intval($fid)) && $fid != $source ) {
$fids .= $comma.$fid;
$comma = ',';
}
}
}
if(empty($fids)) {
cpmsg('forums_copy_target_invalid', '', 'error');
}
$forumoptions = array();
if(is_array($options) && !empty($options)) {
foreach($options as $option) {
if($option = trim($option)) {
if(in_array($option, $optgroups['normal'])) {
$forumoptions['forums'][] = $option;
} elseif(in_array($option, $optgroups['misc']) || in_array($option, $optgroups['credits']) || in_array($option, $optgroups['access'])) {
$forumoptions['forumfields'][] = $option;
}
}
}
}
if(empty($forumoptions)) {
cpmsg('forums_copy_options_invalid', '', 'error');
}
foreach(array('forums', 'forumfields') as $table) {
if(is_array($forumoptions[$table]) && !empty($forumoptions[$table])) {
$sourceforum = $db->fetch_first("SELECT ".implode($forumoptions[$table],',')." FROM {$tablepre}$table WHERE fid='$source'");
if(!$sourceforum) {
cpmsg('forums_copy_source_invalid', '', 'error');
}
$updatequery = 'fid=fid';
foreach($sourceforum as $key => $val) {
$updatequery .= ", $key='".addslashes($val)."'";
}
$db->query("UPDATE {$tablepre}$table SET $updatequery WHERE fid IN ($fids)");
}
}
updatecache('forums');
cpmsg('forums_copy_succeed', $BASESCRIPT.'?action=forums', 'succeed');
}
}
function showforum($key, $type = '', $last = '') {
global $forums, $showedforums, $lang, $indexname;
$forum = $forums[$key];
$showedforums[] = $key;
if($last == '') {
$return = '<tr class="hover"><td class="td25"><input type="text" class="txt" name="order['.$forum['fid'].']" value="'.$forum['displayorder'].'" /></td><td>';
if($type == 'group') {
$return .= '<div class="parentboard">';
} elseif($type == '') {
$return .= '<div class="board">';
} elseif($type == 'sub') {
$return .= '<div id="cb_'.$forum['fid'].'" class="childboard">';
}
$boardattr = '';
if(!$forum['status'] || $forum['password'] || $forum['redirect']) {
$boardattr = '<div class="boardattr">';
$boardattr .= $forum['status'] ? '' : $lang['forums_admin_hidden'];
$boardattr .= !$forum['password'] ? '' : ' '.$lang['forums_admin_password'];
$boardattr .= !$forum['redirect'] ? '' : ' '.$lang['forums_admin_url'];
$boardattr .= '</div>';
}
$return .= '<input type="text" name="name['.$forum['fid'].']" value="'.htmlspecialchars($forum['name']).'" class="txt" />'.
($type == '' ? '<a href="###" onclick="addrowdirect = 1;addrow(this, 2, '.$forum['fid'].')" class="addchildboard">'.$lang['forums_admin_add_sub'].'</a>' : '').
'</div>'.$boardattr.
'</td><td>'.showforum_moderators($forum).'</td>
<td><a href="'.$BASESCRIPT.'?action=forums&operation=edit&fid='.$forum['fid'].'" title="'.$lang['forums_edit_comment'].'" class="act">'.$lang['edit'].'</a>'.
($type != 'group' ? '<a href="'.$BASESCRIPT.'?action=forums&operation=copy&source='.$forum['fid'].'" title="'.$lang['forums_copy_comment'].'" class="act">'.$lang['forums_copy'].'</a>' : '').
'<a href="'.$BASESCRIPT.'?action=forums&operation=delete&fid='.$forum['fid'].'" title="'.$lang['forums_delete_comment'].'" class="act">'.$lang['delete'].'</a></td></tr>';
} else {
if($last == 'lastboard') {
$return = '<tr><td></td><td colspan="3"><div class="lastboard"><a href="###" onclick="addrow(this, 1, '.$forum['fid'].')" class="addtr">'.$lang['forums_admin_add_forum'].'</a></div></td></tr>';
} elseif($last == 'lastchildboard' && $type) {
$return = '<script type="text/JavaScript">$(\'cb_'.$type.'\').className = \'lastchildboard\';</script>';
} elseif($last == 'last') {
$return = '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['forums_admin_add_category'].'</a></div></td></tr>';
}
}
return $return;
}
function showforum_moderators($forum) {
if($forum['moderators']) {
$moderators = explode("\t", $forum['moderators']);
$count = count($moderators);
$max = $count > 2 ? 2 : $count;
$mods = array();
for($i = 0;$i < $max;$i++) {
$mods[] = $forum['inheritedmod'] ? '<b>'.$moderators[$i].'</b>' : $moderators[$i];
}
$r = implode(', ', $mods);
if($count > 2) {
$r = '<span onmouseover="showMenu(this.id)" id="mods_'.$forum['fid'].'">'.$r.'</span>';
$mods = array();
foreach($moderators as $moderator) {
$mods[] = $forum['inheritedmod'] ? '<b>'.$moderator.'</b>' : $moderator;
}
$r = '<a href="'.$BASESCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.lang('forums_moderators_comment').'">'.$r.'</a> ...';
$r .= '<div class="dropmenu1" id="mods_'.$forum['fid'].'_menu" style="display: none">'.implode('<br />', $mods).'</div>';
} else {
$r = '<a href="'.$BASESCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.lang('forums_moderators_comment').'">'.$r.'</a>';
}
} else {
$r = '<a href="'.$BASESCRIPT.'?action=forums&operation=moderators&fid='.$forum['fid'].'" title="'.lang('forums_moderators_comment').'">'.lang('forums_admin_no_moderator').'</a>';
}
return $r;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/forums.inc.php
|
PHP
|
asf20
| 75,105
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: misc.inc.php 17532 2009-01-19 01:44:42Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$operation = $operation ? $operation : 'custommenu';
if($operation == 'onlinelist') {
if(!submitcheck('onlinesubmit')) {
shownav('style', 'misc_onlinelist');
showsubmenu('nav_misc_onlinelist');
showtips('misc_onlinelist_tips');
showformheader('misc&operation=onlinelist&');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'display_order', 'usergroup', 'usergroups_title', 'misc_onlinelist_image'));
$listarray = array();
$query = $db->query("SELECT * FROM {$tablepre}onlinelist");
while($list = $db->fetch_array($query)) {
$list['title'] = dhtmlspecialchars($list['title']);
$listarray[$list['groupid']] = $list;
}
$onlinelist = '';
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type<>'member'");
$group = array('groupid' => 0, 'grouptitle' => 'Member');
do {
$id = $group['groupid'];
showtablerow('', array('class="td25"', 'class="td23 td28"', 'class="td24"', 'class="td24"', 'class="td21 td26"'), array(
$listarray[$id]['url'] ? " <img src=\"images/common/{$listarray[$id]['url']}\">" : '',
'<input type="text" class="txt" name="displayordernew['.$id.']" value="'.$listarray[$id]['displayorder'].'" size="3" />',
$group['groupid'] <= 8 ? lang('usergroups_system_'.$id) : $group['grouptitle'],
'<input type="text" class="txt" name="titlenew['.$id.']" value="'.($listarray[$id]['title'] ? $listarray[$id]['title'] : $group['grouptitle']).'" size="15" />',
'<input type="text" class="txt" name="urlnew['.$id.']" value="'.$listarray[$id]['url'].'" size="20" />'
));;
} while($group = $db->fetch_array($query));
showsubmit('onlinesubmit', 'submit', 'td');
showtablefooter();
showformfooter();
} else {
if(is_array($urlnew)) {
$db->query("DELETE FROM {$tablepre}onlinelist");
foreach($urlnew as $id => $url) {
$url = trim($url);
if($id == 0 || $url) {
$db->query("INSERT INTO {$tablepre}onlinelist (groupid, displayorder, title, url)
VALUES ('$id', '$displayordernew[$id]', '$titlenew[$id]', '$url')");
}
}
}
updatecache(array('onlinelist', 'groupicon'));
cpmsg('onlinelist_succeed', $BASESCRIPT.'?action=misc&operation=onlinelist', 'succeed');
}
} elseif($operation == 'link') {
if(!submitcheck('linksubmit')) {
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'<input type="text" class="txt" name="newname[]" size="15">'],
[1,'<input type="text" class="txt" name="newurl[]" size="20">'],
[1,'<input type="text" class="txt" name="newdescription[]" size="30">', 'td26'],
[1,'<input type="text" class="txt" name="newlogo[]" size="20">']
]
]
</script>
<?
shownav('adv', 'misc_link');
showsubmenu('nav_misc_links');
showtips('misc_link_tips');
showformheader('misc&operation=link');
showtableheader();
showsubtitle(array('', 'display_order', 'misc_link_edit_name', 'misc_link_edit_url', 'misc_link_edit_description', 'misc_link_edit_logo'));
$query = $db->query("SELECT * FROM {$tablepre}forumlinks ORDER BY displayorder");
while($forumlink = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td28"', '', '', 'class="td26"'), array(
'<input type="checkbox" class="checkbox" name="delete[]" value="'.$forumlink['id'].'" />',
'<input type="text" class="txt" name="displayorder['.$forumlink[id].']" value="'.$forumlink['displayorder'].'" size="3" />',
'<input type="text" class="txt" name="name['.$forumlink[id].']" value="'.$forumlink['name'].'" size="15" />',
'<input type="text" class="txt" name="url['.$forumlink[id].']" value="'.$forumlink['url'].'" size="20" />',
'<input type="text" class="txt" name="description['.$forumlink[id].']" value="'.$forumlink['description'].'" size="30" />',
'<input type="text" class="txt" name="logo['.$forumlink[id].']" value="'.$forumlink['logo'].'" size="20" />'
));
}
echo '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['misc_link_add'].'</a></div></td></tr>';
showsubmit('linksubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($delete)) {
$ids = $comma = '';
foreach($delete as $id) {
$ids .= "$comma'$id'";
$comma = ',';
}
$db->query("DELETE FROM {$tablepre}forumlinks WHERE id IN ($ids)");
}
if(is_array($name)) {
foreach($name as $id => $val) {
$db->query("UPDATE {$tablepre}forumlinks SET displayorder='$displayorder[$id]', name='$name[$id]', url='$url[$id]',description='$description[$id]',logo='$logo[$id]' WHERE id='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $key => $value) {
if($value) {
$db->query("INSERT INTO {$tablepre}forumlinks (displayorder, name, url, description, logo) VALUES ('$newdisplayorder[$key]', '$value', '$newurl[$key]', '$newdescription[$key]', '$newlogo[$key]')");
}
}
}
updatecache('forumlinks');
cpmsg('forumlinks_succeed', $BASESCRIPT.'?action=misc&operation=link', 'succeed');
}
} elseif($operation == 'bbcode') {
if(!submitcheck('bbcodessubmit') && !$edit) {
echo '<script type="text/JavaScript">loadcss("editor");</script>';
shownav('style', 'settings_editor');
showsubmenu('settings_editor', array(
array('settings_editor_global', 'settings&operation=editor', 0),
array('settings_editor_code', 'misc&operation=bbcode', 1),
));
showtips('misc_bbcode_edit_tips');
showformheader('misc&operation=bbcode');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'misc_bbcode_tag', 'available', 'display', 'display_order', 'type', 'misc_bbcode_icon', 'misc_bbcode_icon_file', ''));
$query = $db->query("SELECT * FROM {$tablepre}bbcodes ORDER BY displayorder");
while($bbcode = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td21"', 'class="td25"', 'class="td25"', 'class="td28 td24"', 'class="td25"', 'class="td25"', 'class="td21"'), array(
$bbcode['type'] == '0' ? "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$bbcode[id]\">" : '',
$bbcode['type'] == '0' ? "<input type=\"text\" class=\"txt\" size=\"15\" name=\"tagnew[$bbcode[id]]\" value=\"$bbcode[tag]\">" : "$bbcode[tag]<input type=\"hidden\" class=\"txt\" size=\"15\" name=\"tagnew[$bbcode[id]]\" value=\"\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$bbcode[id]]\" value=\"1\" ".($bbcode['available'] ? 'checked="checked"' : NULL).($bbcode['type'] == '1' ? ' disabled="disabled"' : NULL).">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"displaynew[$bbcode[id]]\" value=\"1\" ".($bbcode['available'] == '2' ? 'checked="checked"' : NULL).">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$bbcode[id]]\" value=\"$bbcode[displayorder]\">",
lang($bbcode['type'] == '1' ? 'inbuilt' : 'costom'),
$bbcode['icon'] ? ($bbcode['type'] == '0' ? "<em class=\"editor\"><a class=\"customedit\"><img src=\"images/common/$bbcode[icon]\" border=\"0\"></a></em>" : "<em class=\"editor\"><a id=\"e_".($bbcode['icon'] == 'popup_simple' ? 'cmd_bold' : $bbcode['icon'])."\"></em>") : ' ',
$bbcode['type'] == '0' ? "<input type=\"text\" class=\"txt\" size=\"25\" name=\"iconnew[$bbcode[id]]\" value=\"$bbcode[icon]\">" : $bbcode['explanation'],
$bbcode['type'] == '0' ? "<a href=\"$BASESCRIPT?action=misc&operation=bbcode&edit=$bbcode[id]\" class=\"act\">$lang[detail]</a>" : ''
));
}
showtablerow('', array('class="td25"', 'class="td21"', 'class="td25"', 'class="td25"', 'class="td28 td24"', 'class="td25"', 'class="td25"', 'class="td21"'), array(
lang('add_new'),
'<input type="text" class="txt" size="15" name="newtag">',
'',
'',
'<input type="text" class="txt" size="2" name="newdisplayorder">',
'',
'',
'<input type="text" class="txt" size="25" name="newicon">',
''
));
showsubmit('bbcodessubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} elseif(submitcheck('bbcodessubmit')) {
if(is_array($delete)) {
$ids = '\''.implode('\',\'', $delete).'\'';
$db->query("DELETE FROM {$tablepre}bbcodes WHERE id IN ($ids) AND type='0'");
}
if(is_array($tagnew)) {
$custom_ids = array();
$query = $db->query("SELECT id FROM {$tablepre}bbcodes WHERE type='0'");
while($bbcode = $db->fetch_array($query)) {
$custom_ids[] = $bbcode['id'];
}
foreach($tagnew as $id => $val) {
if(in_array($id, $custom_ids) && !preg_match("/^[0-9a-z]+$/i", $tagnew[$id]) && strlen($tagnew[$id]) < 20) {
cpmsg('dzcode_edit_tag_invalid', '', 'error');
}
$availablenew[$id] = in_array($id, $custom_ids) ? $availablenew[$id] : 1;
$availablenew[$id] = $availablenew[$id] && $displaynew[$id] ? 2 : $availablenew[$id];
$sqladd = in_array($id, $custom_ids) ? ", tag='$tagnew[$id]', icon='$iconnew[$id]'" : '';
$db->query("UPDATE {$tablepre}bbcodes SET available='$availablenew[$id]', displayorder='$displayordernew[$id]' $sqladd WHERE id='$id'");
}
}
if($newtag != '') {
if(!preg_match("/^[0-9a-z]+$/i", $newtag && strlen($newtag) < 20)) {
cpmsg('dzcode_edit_tag_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}bbcodes (tag, icon, available, displayorder, params, nest)
VALUES ('$newtag', '$newicon', '0', '$newdisplayorder', '1', '1')");
}
updatecache(array('bbcodes', 'bbcodes_display'));
cpmsg('dzcode_edit_succeed', $BASESCRIPT.'?action=misc&operation=bbcode', 'succeed');
} elseif($edit) {
$bbcode = $db->fetch_first("SELECT * FROM {$tablepre}bbcodes WHERE id='$edit' AND type='0'");
if(!$bbcode) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
$bbcode['prompt'] = str_replace("\t", "\n", $bbcode['prompt']);
shownav('style', 'nav_posting_bbcode');
showsubmenu($lang['misc_bbcode_edit'].' - '.$bbcode['tag']);
showformheader("misc&operation=bbcode&edit=$edit");
showtableheader();
showsetting('misc_bbcode_edit_tag', 'tagnew', $bbcode['tag'], 'text');
showsetting('misc_bbcode_edit_replacement', 'replacementnew', $bbcode['replacement'], 'textarea');
showsetting('misc_bbcode_edit_example', 'examplenew', $bbcode['example'], 'text');
showsetting('misc_bbcode_edit_explanation', 'explanationnew', $bbcode['explanation'], 'text');
showsetting('misc_bbcode_edit_params', 'paramsnew', $bbcode['params'], 'text');
showsetting('misc_bbcode_edit_prompt', 'promptnew', $bbcode['prompt'], 'textarea');
showsetting('misc_bbcode_edit_nest', 'nestnew', $bbcode['nest'], 'text');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$tagnew = trim($tagnew);
if(!preg_match("/^[0-9a-z]+$/i", $tagnew)) {
cpmsg('dzcode_edit_tag_invalid', '', 'error');
} elseif($paramsnew < 1 || $paramsnew > 3 || $nestnew < 1 || $nestnew > 3) {
cpmsg('dzcode_edit_range_invalid', '', 'error');
}
$promptnew = trim(str_replace(array("\t", "\r", "\n"), array('', '', "\t"), $promptnew));
$db->query("UPDATE {$tablepre}bbcodes SET tag='$tagnew', replacement='$replacementnew', example='$examplenew', explanation='$explanationnew', params='$paramsnew', prompt='$promptnew', nest='$nestnew' WHERE id='$edit'");
updatecache(array('bbcodes', 'bbcodes_display'));
cpmsg('dzcode_edit_succeed', $BASESCRIPT.'?action=misc&operation=bbcode', 'succeed');
}
}
} elseif($operation == 'censor') {
$page = max(1, intval($page));
$ppp = 30;
$addcensors = isset($addcensors) ? trim($addcensors) : '';
if($do == 'export') {
ob_end_clean();
dheader('Cache-control: max-age=0');
dheader('Expires: '.gmdate('D, d M Y H:i:s', $timestamp - 31536000).' GMT');
dheader('Content-Encoding: none');
dheader('Content-Disposition: attachment; filename=CensorWords.txt');
dheader('Content-Type: text/plain');
$query = $db->query("SELECT find, replacement FROM {$tablepre}words ORDER BY find ASC");
while($censor = $db->fetch_array($query)) {
$censor['replacement'] = str_replace('*', '', $censor['replacement']) <> '' ? $censor['replacement'] : '';
echo $censor['find'].($censor['replacement'] != '' ? '='.stripslashes($censor['replacement']) : '')."\n";
}
exit();
} elseif(submitcheck('addcensorsubmit') && $addcensors != '') {
$oldwords = array();
if($adminid == 1 && $overwrite == 2) {
$db->query("TRUNCATE {$tablepre}words");
} else {
$query = $db->query("SELECT find, admin FROM {$tablepre}words");
while($censor = $db->fetch_array($query)) {
$oldwords[md5($censor['find'])] = $censor['admin'];
}
$db->free_result($query);
}
$censorarray = explode("\n", $addcensors);
$updatecount = $newcount = $ignorecount = 0;
foreach($censorarray as $censor) {
list($newfind, $newreplace) = array_map('trim', explode('=', $censor));
$newreplace = $newreplace <> '' ? daddslashes(str_replace("\\\'", '\'', $newreplace), 1) : '**';
if(strlen($newfind) < 3) {
$ignorecount ++;
continue;
} elseif(isset($oldwords[md5($newfind)])) {
if($overwrite && ($adminid == 1 || $oldwords[md5($newfind)] == $discuz_userss)) {
$updatecount ++;
$db->query("UPDATE {$tablepre}words SET replacement='$newreplace' WHERE `find`='$newfind'");
} else {
$ignorecount ++;
}
} else {
$newcount ++;
$db->query("INSERT INTO {$tablepre}words (admin, find, replacement) VALUES
('$discuz_user', '$newfind', '$newreplace')");
$oldwords[md5($newfind)] = $discuz_userss;
}
}
updatecache('censor');
cpmsg('censor_batch_add_succeed', "$BASESCRIPT?action=misc&operation=censor&anchor=import", 'succeed');
} elseif(!submitcheck('censorsubmit')) {
$ppp = 50;
$page = max(1, intval($page));
$startlimit = ($page - 1) * $ppp;
$totalcount = $db->result_first("SELECT count(*) FROM {$tablepre}words");
$multipage = multi($totalcount, $ppp, $page, "$BASESCRIPT?action=misc&operation=censor");
shownav('topic', 'nav_posting_censor');
$anchor = in_array($anchor, array('list', 'import')) ? $anchor : 'list';
showsubmenuanchors('nav_posting_censor', array(
array('admin', 'list', $anchor == 'list'),
array('misc_censor_batch_add', 'import', $anchor == 'import')
));
showtips('misc_censor_tips', 'list_tips', $anchor == 'list');
showtips('misc_censor_batch_add_tips', 'import_tips', $anchor == 'import');
showtagheader('div', 'list', $anchor == 'list');
showformheader("misc&operation=censor&page=$page", '', 'listform');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'misc_censor_word', 'misc_censor_replacement', 'operator'));
$query = $db->query("SELECT * FROM {$tablepre}words ORDER BY find ASC LIMIT $startlimit, $ppp");
while($censor = $db->fetch_array($query)) {
$censor['replacement'] = stripslashes($censor['replacement']);
$disabled = $adminid != 1 && $censor['admin'] != $discuz_userss ? 'disabled' : NULL;
showtablerow('', array('class="td25"', 'class="td26"', 'class="td26"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$censor[id]\" $disabled>",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"find[$censor[id]]\" value=\"$censor[find]\" $disabled>",
"<input type=\"text\" class=\"txt\" size=\"30\" name=\"replace[$censor[id]]\" value=\"$censor[replacement]\" $disabled>",
$censor[admin]
));
}
showtablerow('', array('class="td25"', 'class="td26"', 'class="td26"'), array(
lang('add_new'),
'<input type="text" class="txt" size="30" name="newfind">',
'<input type="text" class="txt" size="30" name="newreplace">',
''
));
showsubmit('censorsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'import', $anchor == 'import');
showformheader("misc&operation=censor&page=$page", 'fixpadding');
showtableheader('', 'fixpadding', 'importform');
showtablerow('', 'class="vtop rowform"', '<br /><textarea name="addcensors" class="tarea" rows="10" cols="80"></textarea><br /><br />'.mradio('overwrite', array(
0 => lang('misc_censor_batch_add_no_overwrite'),
1 => lang('misc_censor_batch_add_overwrite'),
2 => lang('misc_censor_batch_add_clear')
), '', FALSE));
showsubmit('addcensorsubmit');
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}words WHERE id IN ($ids) AND ('$adminid'='1' OR admin='$discuz_user')");
}
if(is_array($find)) {
foreach($find as $id => $val) {
$find[$id] = $val = trim(str_replace('=', '', $find[$id]));
if(strlen($val) < 3) {
cpmsg('censor_keywords_tooshort', '', 'error');
}
$replace[$id] = daddslashes(str_replace("\\\'", '\'', $replace[$id]), 1);
$db->query("UPDATE {$tablepre}words SET find='$find[$id]', replacement='$replace[$id]' WHERE id='$id' AND ('$adminid'='1' OR admin='$discuz_user')");
}
}
$newfind = trim(str_replace('=', '', $newfind));
$newreplace = trim($newreplace);
if($newfind != '') {
if(strlen($newfind) < 3) {
cpmsg('censor_keywords_tooshort', '', 'error');
}
$newreplace = daddslashes(str_replace("\\\'", '\'', $newreplace), 1);
if($oldcenser = $db->fetch_first("SELECT admin FROM {$tablepre}words WHERE find='$newfind'")) {
cpmsg('censor_keywords_existence', '', 'error');
} else {
$db->query("INSERT INTO {$tablepre}words (admin, find, replacement) VALUES
('$discuz_user', '$newfind', '$newreplace')");
}
}
updatecache('censor');
cpmsg('censor_succeed', "$BASESCRIPT?action=misc&operation=censor&page=$page", 'succeed');
}
} elseif($operation == 'icon') {
if(!submitcheck('iconsubmit')) {
$anchor = in_array($anchor, array('list', 'add')) ? $anchor : 'list';
shownav('style', 'nav_thread_icon');
showsubmenuanchors('nav_thread_icon', array(
array('admin', 'list', $anchor == 'list'),
array('add', 'add', $anchor == 'add')
));
showtagheader('div', 'list', $anchor == 'list');
showformheader('misc&operation=icon');
showtableheader();
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_edit_filename'));
$imgfilter = array();
$query = $db->query("SELECT * FROM {$tablepre}smilies WHERE type='icon' ORDER BY displayorder");
while($smiley = $db->fetch_array($query)) {
showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$smiley[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayorder[$smiley[id]]\" value=\"$smiley[displayorder]\">",
"<img src=\"images/icons/$smiley[url]\">",
$smiley[url]
));
$imgfilter[] = $smiley[url];
}
showsubmit('iconsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
showtagfooter('div');
showtagheader('div', 'add', $anchor == 'add');
showformheader('misc&operation=icon');
showtableheader();
showsubtitle(array('', 'display_order', 'smilies_edit_image', 'smilies_edit_filename'));
$newid = 0;
$imgextarray = array('jpg', 'gif');
$iconsdir = dir(DISCUZ_ROOT.'./images/icons');
while($entry = $iconsdir->read()) {
if(in_array(strtolower(fileext($entry)), $imgextarray) && !in_array($entry, $imgfilter) && is_file(DISCUZ_ROOT.'./images/icons/'.$entry)) {
showtablerow('', array('class="td25"', 'class="td28 td24"', 'class="td23"'), array(
"<input type=\"checkbox\" name=\"addcheck[$newid]\" class=\"checkbox\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"adddisplayorder[$newid]\" value=\"0\">",
"<img src=\"images/icons/$entry\">",
"<input type=\"text\" class=\"txt\" size=\"35\" name=\"addurl[$newid]\" value=\"$entry\" readonly>"
));
$newid ++;
}
}
$iconsdir->close();
if(!$newid) {
showtablerow('', array('class="td25"', 'colspan="3"'), array('', lang('misc_icon_tips')));
} else {
showsubmit('iconsubmit', 'submit', '<input type="checkbox" class="checkbox" name="chkall2" onclick="checkAll(\'prefix\', this.form, \'addcheck\', \'chkall2\')">'.lang('enable'));
}
showtablefooter();
showformfooter();
showtagfooter('div');
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}smilies WHERE id IN ($ids)");
}
if(is_array($displayorder)) {
foreach($displayorder as $id => $val) {
$displayorder[$id] = intval($displayorder[$id]);
$db->query("UPDATE {$tablepre}smilies SET displayorder='$displayorder[$id]' WHERE id='$id'");
}
}
if(is_array($addurl)) {
foreach($addurl as $k => $v) {
if($addcheck[$k]) {
$query = $db->query("INSERT INTO {$tablepre}smilies (displayorder, type, url)
VALUES ('{$adddisplayorder[$k]}', 'icon', '$addurl[$k]')");
}
}
}
updatecache('icons');
cpmsg('thread_icon_succeed', "$BASESCRIPT?action=misc&operation=icon", 'succeed');
}
} elseif($operation == 'attachtype') {
if(!submitcheck('typesubmit')) {
$attachtypes = '';
$query = $db->query("SELECT * FROM {$tablepre}attachtypes");
while($type = $db->fetch_array($query)) {
$attachtypes .= showtablerow('', array('class="td25"', 'class="td24"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$type[id]\" />",
"<input type=\"text\" class=\"txt\" size=\"10\" name=\"extension[$type[id]]\" value=\"$type[extension]\" />",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"maxsize[$type[id]]\" value=\"$type[maxsize]\" />"
), TRUE);
}
?>
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input name="newextension[]" type="text" class="txt" size="10">', 'td24'],
[1,'<input name="newmaxsize[]" type="text" class="txt" size="15">']
]
];
</script>
<?
shownav('topic', 'nav_posting_attachtype');
showsubmenu('nav_posting_attachtype');
showtips('misc_attachtype_tips');
showformheader('misc&operation=attachtype');
showtableheader();
showtablerow('class="partition"', array('class="td25"'), array('', lang('misc_attachtype_ext'), lang('misc_attachtype_maxsize')));
echo $attachtypes;
echo '<tr><td></td><td colspan="2"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['misc_attachtype_add'].'</a></div></tr>';
showsubmit('typesubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}attachtypes WHERE id IN ($ids)");
}
if(is_array($extension)) {
foreach($extension as $id => $val) {
$db->query("UPDATE {$tablepre}attachtypes SET extension='$extension[$id]', maxsize='$maxsize[$id]' WHERE id='$id'");
}
}
if(is_array($newextension)) {
foreach($newextension as $key => $value) {
if($newextension1 = trim($value)) {
if($db->result_first("SELECT id FROM {$tablepre}attachtypes WHERE extension='$newextension1'")) {
cpmsg('attachtypes_duplicate', '', 'error');
}
$db->query("INSERT INTO {$tablepre}attachtypes (extension, maxsize) VALUES
('$newextension1', '$newmaxsize[$key]')");
}
}
}
cpmsg('attachtypes_succeed', $BASESCRIPT.'?action=misc&operation=attachtype', 'succeed');
}
} elseif($operation == 'cron') {
if(empty($edit) && empty($run)) {
if(!submitcheck('cronssubmit')) {
shownav('tools', 'misc_cron');
showsubmenu('nav_misc_cron');
showtips('misc_cron_tips');
showformheader('misc&operation=cron');
showtableheader('', 'fixpadding');
showsubtitle(array('', 'name', 'available', 'type', 'time', 'misc_cron_last_run', 'misc_cron_next_run', ''));
$query = $db->query("SELECT * FROM {$tablepre}crons ORDER BY type DESC");
while($cron = $db->fetch_array($query)) {
$disabled = $cron['weekday'] == -1 && $cron['day'] == -1 && $cron['hour'] == -1 && $cron['minute'] == '' ? 'disabled' : '';
if($cron['day'] > 0 && $cron['day'] < 32) {
$cron['time'] = lang('misc_cron_permonth').$cron['day'].lang('misc_cron_day');
} elseif($cron['weekday'] >= 0 && $cron['weekday'] < 7) {
$cron['time'] = lang('misc_cron_perweek').lang('misc_cron_week_day_'.$cron['weekday']);
} elseif($cron['hour'] >= 0 && $cron['hour'] < 24) {
$cron['time'] = lang('misc_cron_perday');
} else {
$cron['time'] = lang('misc_cron_perhour');
}
$cron['time'] .= $cron['hour'] >= 0 && $cron['hour'] < 24 ? sprintf('%02d', $cron[hour]).lang('misc_cron_hour') : '';
if(!in_array($cron['minute'], array(-1, ''))) {
foreach($cron['minute'] = explode("\t", $cron['minute']) as $k => $v) {
$cron['minute'][$k] = sprintf('%02d', $v);
}
$cron['minute'] = implode(',', $cron['minute']);
$cron['time'] .= $cron['minute'].lang('misc_cron_minute');
} else {
$cron['time'] .= '00'.lang('misc_cron_minute');
}
$cron['lastrun'] = $cron['lastrun'] ? gmdate("$dateformat<\b\\r />$timeformat", $cron['lastrun'] + $_DCACHE['settings']['timeoffset'] * 3600) : '<b>N/A</b>';
$cron['nextcolor'] = $cron['nextrun'] && $cron['nextrun'] + $_DCACHE['settings']['timeoffset'] * 3600 < $timestamp ? 'style="color: #ff0000"' : '';
$cron['nextrun'] = $cron['nextrun'] ? gmdate("$dateformat<\b\\r />$timeformat", $cron['nextrun'] + $_DCACHE['settings']['timeoffset'] * 3600) : '<b>N/A</b>';
showtablerow('', array('class="td25"', 'class="crons"', 'class="td25"', 'class="td25"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$cron[cronid]\" ".($cron['type'] == 'system' ? 'disabled' : '').">",
"<input type=\"text\" class=\"txt\" name=\"namenew[$cron[cronid]]\" size=\"20\" value=\"$cron[name]\"><br /><b>$cron[filename]</b>",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$cron[cronid]]\" value=\"1\" ".($cron['available'] ? 'checked' : '')." $disabled>",
lang($cron['type'] == 'system' ? 'inbuilt' : 'costom'),
$cron[time],
$cron[lastrun],
$cron[nextrun],
"<a href=\"$BASESCRIPT?action=misc&operation=cron&edit=$cron[cronid]\" class=\"act\">$lang[edit]</a><br />".
($cron['available'] ? " <a href=\"$BASESCRIPT?action=misc&operation=cron&run=$cron[cronid]\" class=\"act\">$lang[misc_cron_run]</a>" : " <a href=\"###\" class=\"act\" disabled>$lang[misc_cron_run]</a>")
));
}
showtablerow('', array('','colspan="10"'), array(
lang('add_new'),
'<input type="text" class="txt" name="newname" value="" size="20" />'
));
showsubmit('cronssubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}crons WHERE cronid IN ($ids) AND type='user'");
}
if(is_array($namenew)) {
foreach($namenew as $id => $name) {
$db->query("UPDATE {$tablepre}crons SET name='".dhtmlspecialchars($namenew[$id])."', available='".$availablenew[$id]."' ".($availablenew[$id] ? '' : ', nextrun=\'0\'')." WHERE cronid='$id'");
}
}
if($newname = trim($newname)) {
$db->query("INSERT INTO {$tablepre}crons (name, type, available, weekday, day, hour, minute, nextrun)
VALUES ('".dhtmlspecialchars($newname)."', 'user', '0', '-1', '-1', '-1', '', '$timestamp')");
}
$query = $db->query("SELECT cronid, filename FROM {$tablepre}crons");
while($cron = $db->fetch_array($query)) {
if(!file_exists(DISCUZ_ROOT.'./include/crons/'.$cron['filename'])) {
$db->query("UPDATE {$tablepre}crons SET available='0', nextrun='0' WHERE cronid='$cron[cronid]'");
}
}
//updatecache('crons');
updatecache('settings');
cpmsg('crons_succeed', $BASESCRIPT.'?action=misc&operation=cron', 'succeed');
}
} else {
$cronid = empty($run) ? $edit : $run;
$cron = $db->fetch_first("SELECT * FROM {$tablepre}crons WHERE cronid='$cronid'");
if(!$cron) {
cpmsg('undefined_action', '', 'error');
}
$cron['filename'] = str_replace(array('..', '/', '\\'), array('', '', ''), $cron['filename']);
$cronminute = str_replace("\t", ',', $cron['minute']);
$cron['minute'] = explode("\t", $cron['minute']);
if(!empty($edit)) {
if(!submitcheck('editsubmit')) {
shownav('tools', 'misc_cron');
showsubmenu($lang['misc_cron_edit'].' - '.$cron['name']);
showtips('misc_cron_edit_tips');
$weekdayselect = $dayselect = $hourselect = '';
for($i = 0; $i <= 6; $i++) {
$weekdayselect .= "<option value=\"$i\" ".($cron['weekday'] == $i ? 'selected' : '').">".$lang['misc_cron_week_day_'.$i]."</option>";
}
for($i = 1; $i <= 31; $i++) {
$dayselect .= "<option value=\"$i\" ".($cron['day'] == $i ? 'selected' : '').">$i $lang[misc_cron_day]</option>";
}
for($i = 0; $i <= 23; $i++) {
$hourselect .= "<option value=\"$i\" ".($cron['hour'] == $i ? 'selected' : '').">$i $lang[misc_cron_hour]</option>";
}
shownav('tools', 'misc_cron');
showformheader("misc&operation=cron&edit=$cronid");
showtableheader();
showsetting('misc_cron_edit_weekday', '', '', "<select name=\"weekdaynew\"><option value=\"-1\">*</option>$weekdayselect</select>");
showsetting('misc_cron_edit_day', '', '', "<select name=\"daynew\"><option value=\"-1\">*</option>$dayselect</select>");
showsetting('misc_cron_edit_hour', '', '', "<select name=\"hournew\"><option value=\"-1\">*</option>$hourselect</select>");
showsetting('misc_cron_edit_minute', 'minutenew', $cronminute, 'text');
showsetting('misc_cron_edit_filename', 'filenamenew', $cron['filename'], 'text');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$daynew = $weekdaynew != -1 ? -1 : $daynew;
if(strpos($minutenew, ',') !== FALSE) {
$minutenew = explode(',', $minutenew);
foreach($minutenew as $key => $val) {
$minutenew[$key] = $val = intval($val);
if($val < 0 || $var > 59) {
unset($minutenew[$key]);
}
}
$minutenew = array_slice(array_unique($minutenew), 0, 12);
$minutenew = implode("\t", $minutenew);
} else {
$minutenew = intval($minutenew);
$minutenew = $minutenew >= 0 && $minutenew < 60 ? $minutenew : '';
}
if(preg_match("/[\\\\\/\:\*\?\"\<\>\|]+/", $filenamenew)) {
cpmsg('crons_filename_illegal', '', 'error');
} elseif(!is_readable(DISCUZ_ROOT.($cronfile = "./include/crons/$filenamenew"))) {
cpmsg('crons_filename_invalid', '', 'error');
} elseif($weekdaynew == -1 && $daynew == -1 && $hournew == -1 && $minutenew === '') {
cpmsg('crons_time_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}crons SET weekday='$weekdaynew', day='$daynew', hour='$hournew', minute='$minutenew', filename='".trim($filenamenew)."' WHERE cronid='$cronid'");
updatecache('crons');
require_once DISCUZ_ROOT.'./include/cron.func.php';
cronnextrun($cron);
cpmsg('crons_succeed', $BASESCRIPT.'?action=misc&operation=cron', 'succeed');
}
} else {
if(!@include_once DISCUZ_ROOT.($cronfile = "./include/crons/$cron[filename]")) {
cpmsg('crons_run_invalid', '', 'error');
} else {
require_once DISCUZ_ROOT.'./include/cron.func.php';
cronnextrun($cron);
cpmsg('crons_run_succeed', $BASESCRIPT.'?action=misc&operation=cron', 'succeed');
}
}
}
} elseif($operation == 'tag') {
if(!$tagstatus) {
cpmsg('tags_not_open', "$BASESCRIPT?action=settings&operation=functions#subtitle_tags");
}
if(submitcheck('tagsubmit') && !empty($tag)) {
$tagdelete = $tagclose = $tagopen = array();
foreach($tag as $key => $value) {
if($value == -1) {
$tagdelete[] = $key;
} elseif($value == 1) {
$tagclose[] = $key;
} elseif($value == 0) {
$tagopen[] = $key;
}
}
if($tagdelete) {
$db->query("DELETE FROM {$tablepre}tags WHERE tagname IN (".implodeids($tagdelete).")", 'UNBUFFERED');
$db->query("DELETE FROM {$tablepre}threadtags WHERE tagname IN (".implodeids($tagdelete).")", 'UNBUFFERED');
}
if($tagclose) {
$db->query("UPDATE {$tablepre}tags SET closed=1 WHERE tagname IN (".implodeids($tagclose).")", 'UNBUFFERED');
}
if($tagopen) {
$db->query("UPDATE {$tablepre}tags SET closed=0 WHERE tagname IN (".implodeids($tagopen).")", 'UNBUFFERED');
}
if($tagdelete || $tagclose || $tagopen) {
updatecache(array('tags_index', 'tags_viewthread'));
}
cpmsg('tags_updated', $BASESCRIPT.'?action=misc&operation=tag&tagsearchsubmit=yes&tagname='.rawurlencode($tagname).'&threadnumlower='.intval($threadnumlower).'&threadnumhigher='.intval($threadnumhigher).'&status='.intval($status), 'succeed');
}
shownav('topic', 'nav_posting_tag');
showsubmenu('nav_posting_tag');
if(!submitcheck('tagsearchsubmit', 1)) {
$tagcount[0] = $db->result_first("SELECT count(*) FROM {$tablepre}tags");
$tagcount[1] = $db->result_first("SELECT count(*) FROM {$tablepre}tags WHERE closed=1");
$tagcount[2] = $tagcount[0] - $tagcount[1];
showformheader('misc&operation=tag');
showtableheader('misc_tag_search');
showsetting('misc_tag', 'tagname', '', 'text');
showsetting('misc_tag_threadnum_between', array('threadnumhigher', 'threadnumlower'), array(), 'range');
showsetting('misc_tag_status', array( 'status', array(
array(-1, lang('all')."($tagcount[0])"),
array(1, lang('misc_tag_status_1')."($tagcount[1])"),
array(0, lang('misc_tag_status_0')."($tagcount[2])")
), TRUE), -1, 'mradio');
showsubmit('tagsearchsubmit', 'misc_tag_search');
showtablefooter();
showformfooter();
} else {
$tagpp = 100;
$page = max(1, intval($page));
$threadnumlower = !empty($threadnumlower) ? intval($threadnumlower) : '';
$threadnumhigher = !empty($threadnumhigher) ? intval($threadnumhigher) : '';
$sqladd = $tagname ? "tagname LIKE '%".str_replace(array('%', '*', '_'), array('\%', '%', '\_'), $tagname)."%'" : '1';
$sqladd .= $threadnumlower ? " AND total<'".intval($threadnumlower)."'" : '';
$sqladd .= $threadnumhigher ? " AND total>'".intval($threadnumhigher)."'" : '';
$sqladd .= $status != -1 ? " AND closed='".intval($status)."'" : '';
$pagetmp = $page;
$num = $db->result_first("SELECT count(*) FROM {$tablepre}tags WHERE $sqladd");
$multipage = multi($num, $tagpp, $page, $BASESCRIPT.'?action=misc&operation=tag&tagsearchsubmit=yes&tagname='.rawurlencode($tagname).'&threadnumlower='.intval($threadnumlower).'&threadnumhigher='.intval($threadnumhigher).'&status='.intval($status));
do {
$query = $db->query("SELECT * FROM {$tablepre}tags WHERE $sqladd ORDER BY total DESC LIMIT ".(($pagetmp - 1) * $tagpp).", $tagpp");
$pagetmp--;
} while(!$db->num_rows($query) && $pagetmp);
showformheader('misc&operation=tag&page='.$page);
showhiddenfields(array(
'tagname' => $tagname,
'threadnumlower' => $threadnumlower,
'threadnumhigher' => $threadnumhigher,
'tagname' => $tagname,
'status' => $status,
));
showtableheader('nav_posting_tag', 'fixpadding');
showtablerow('', array('class="td21"', 'class="td25"'), array(
lang('misc_tag'),
lang('misc_tag_threadnum'),
''
));
while($tag = $db->fetch_array($query)) {
showtablerow('', array('class="td21"', 'class="td25"'), array(
'<a href="tag.php?name='.rawurlencode($tag['tagname']).'" target="_blank">'.$tag['tagname'].'</a>',
$tag['total'],
'<input name="tag['.$tag['tagname'].']" type="radio" class="radio" value="-1"> '.$lang['delete'].' <input name="tag['.$tag['tagname'].']" type="radio" class="radio" value="1"'.($tag['closed'] ? ' checked' : '').'> '.$lang['misc_tag_status_1'].' <input name="tag['.$tag['tagname'].']" type="radio" class="radio" value="0"'.(!$tag['closed'] ? ' checked' : '').'> '.$lang['misc_tag_status_0']
));
}
showsubmit('tagsubmit', 'submit', '', '<a href="#" onclick="checkAll(\'option\', $(\'cpform\'), \'-1\')">'.lang('misc_tag_all_delete').'</a> <a href="#" onclick="checkAll(\'option\', $(\'cpform\'), \'1\')">'.lang('misc_tag_all_close').'</a> <a href="#" onclick="checkAll(\'option\', $(\'cpform\'), \'0\')">'.lang('misc_tag_all_open').'</a>', $multipage);
showtablefooter();
showformfooter();
}
} elseif($operation == 'custommenu') {
if(!$do) {
if(!submitcheck('optionsubmit')) {
$page = max(1, intval($page));
$mpp = 10;
$startlimit = ($page - 1) * $mpp;
$num = $db->result_first("SELECT count(*) FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='1'");
$multipage = $inajax ? multi($num, $mpp, $page, $BASESCRIPT.'?action=misc&operation=custommenu', 0, 3, TRUE, TRUE) :
multi($num, $mpp, $page, $BASESCRIPT.'?action=misc&operation=custommenu');
$optionlist = $ajaxoptionlist = '';
$query = $db->query("SELECT id, title, displayorder, url FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='1' ORDER BY displayorder, dateline DESC, clicks DESC LIMIT $startlimit, $mpp");
while($custom = $db->fetch_array($query)) {
$optionlist .= showtablerow('', array('class="td25"', 'class="td28"', '', 'class="td26"'), array(
"<input type=\"checkbox\" class=\"checkbox\" name=\"delete[]\" value=\"$custom[id]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayordernew[$custom[id]]\" value=\"$custom[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"25\" name=\"titlenew[$custom[id]]\" value=\"".lang($custom['title'])."\"><input type=\"hidden\" name=\"langnew[$custom[id]]\" value=\"$custom[title]\">",
"<input type=\"text\" class=\"txt\" size=\"40\" name=\"urlnew[$custom[id]]\" value=\"$custom[url]\">"
), TRUE);
$ajaxoptionlist .= '<li><a href="'.$custom['url'].'" target="'.(substr($custom['url'], 0, 19) == $BASESCRIPT.'?action=' ? 'main' : '_blank').'">'.lang($custom['title']).'</a></li>';
}
if($inajax) {
ajaxshowheader();
echo $ajaxoptionlist.'<li>'.$multipage.'</li><script reload="1">initCpMenus(\'custommenu\');parent.cmcache=true;</script>';
ajaxshowfooter();
exit;
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'<input type="text" class="txt" name="newdisplayorder[]" size="3">', 'td28'],
[1,'<input type="text" class="txt" name="newtitle[]" size="25">'],
[1,'<input type="text" class="txt" name="newurl[]" size="40">', 'td26']
]
];
</script>
EOT;
shownav('tools', 'nav_custommenu');
showsubmenu('nav_custommenu');
showformheader('misc&operation=custommenu');
showtableheader();
showsubtitle(array('', 'display_order', 'name', 'URL'));
echo $optionlist;
echo '<tr><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['misc_custommenu_add'].'</a></div></td></tr>';
showsubmit('optionsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}admincustom WHERE id IN ($ids) AND uid='$discuz_uid'");
}
if(is_array($titlenew)) {
foreach($titlenew as $id => $title) {
$title = dhtmlspecialchars($langnew[$id] && lang($langnew[$id], false) ? $langnew[$id] : $title);
$db->query("UPDATE {$tablepre}admincustom SET title='$title', displayorder='$displayordernew[$id]', url='".dhtmlspecialchars($urlnew[$id])."' WHERE id='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $k => $v) {
$db->query("INSERT INTO {$tablepre}admincustom (title, displayorder, url, sort, uid) VALUES ('".dhtmlspecialchars($v)."', '".intval($newdisplayorder[$k])."', '".dhtmlspecialchars($newurl[$k])."', '1', '$discuz_uid')");
}
}
cpmsg('custommenu_edit_succeed', $BASESCRIPT.'?action=misc&operation=custommenu', 'succeed', '<script type="text/JavaScript">parent.cmcache=false;</script>');
}
} elseif($do == 'add') {
if($title && $url) {
admincustom($title, dhtmlspecialchars($url), 1);
cpmsg('custommenu_add_succeed', $BASESCRIPT.'?'.$url, 'succeed', '<script type="text/JavaScript">parent.cmcache=false;</script>');
} else {
cpmsg('undefined_action', '', 'error');
}
} elseif($do == 'clean') {
if(!$confirmed) {
cpmsg('custommenu_history_delete_confirm', "$BASESCRIPT?action=misc&operation=custommenu&do=clean", 'form');
} else {
$db->query("DELETE FROM {$tablepre}admincustom WHERE uid='$discuz_uid' AND sort='0'");
cpmsg('custommenu_history_delete_succeed', '#', 'succeed', '<script type="text/JavaScript">setTimeout("parent.location.reload();", 2999);</script>');
}
} else {
cpmsg('undefined_action');
}
} elseif($operation == 'customnav') {
if(!$do) {
if(!submitcheck('submit')) {
shownav('style', 'settings_styles');
showsubmenu('settings_styles', array(
array('nav_settings_global', 'settings&operation=styles&anchor=global', 0),
array('nav_settings_index', 'settings&operation=styles&anchor=index', 0),
array('nav_settings_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', 0),
array('nav_settings_viewthread', 'settings&operation=styles&anchor=viewthread', 0),
array('nav_settings_member', 'settings&operation=styles&anchor=member', 0),
array('nav_settings_customnav', 'misc&operation=customnav', 1),
array(array('menu' => 'jswizard_infoside', 'submenu' => array(
array('jswizard_infoside_global', 'jswizard&operation=infoside&from=style'),
array('jswizard_infoside_2', 'jswizard&operation=infoside&sideid=2&from=style'),
array('jswizard_infoside_0', 'jswizard&operation=infoside&sideid=0&from=style'),
))),
array('nav_settings_refresh', 'settings&operation=styles&anchor=refresh', 0),
array('nav_settings_sitemessage', 'settings&operation=styles&anchor=sitemessage', 0)
));
showformheader('misc&operation=customnav');
showtableheader();
showsubtitle(array('', 'display_order', 'name', 'url', 'type', 'available', ''));
$navlist = $subnavlist = array();
$query = $db->query("SELECT * FROM {$tablepre}navs ORDER BY displayorder");
while($nav = $db->fetch_array($query)) {
if($nav['parentid']) {
$subnavlist[$nav['parentid']][] = $nav;
} else {
$navlist[$nav['id']] = $nav;
}
}
foreach($navlist as $nav) {
showtablerow('', array('class="td25"', 'class="td25"', 'width="210"'), array(
$nav['type'] == '0' ? '' : "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$nav[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$nav[id]]\" value=\"$nav[displayorder]\">",
"<div><input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$nav[id]]\" value=\"".dhtmlspecialchars($nav['name'])."\">".($nav['type'] == '1' ? "<a href=\"###\" onclick=\"addrowdirect=1;addrow(this, 1, $nav[id])\" class=\"addchildboard\">$lang[misc_customnav_add_submenu]</a>" : '').'</div>',
$nav['type'] == '0' ? $nav['url'] : "<input type=\"text\" class=\"txt\" size=\"15\" name=\"urlnew[$nav[id]]\" value=\"".dhtmlspecialchars($nav['url'])."\">",
lang($nav['type'] == '0' ? 'inbuilt' : 'costom'),
$nav['id'] == 1 ? "<input type=\"hidden\" name=\"availablenew[$nav[id]]\" value=\"1\">" : "<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$nav[id]]\" value=\"1\" ".($nav['available'] ? 'checked' : '').">",
"<a href=\"$BASESCRIPT?action=misc&operation=customnav&do=edit&id=$nav[id]\" class=\"act\">$lang[detail]</a>"
));
if(!empty($subnavlist[$nav['id']])) {
$subnavnum = count($subnavlist[$nav['id']]);
foreach($subnavlist[$nav['id']] as $sub) {
$subnavnum--;
showtablerow('', array('class="td25"', 'class="td25"'), array(
$sub['type'] == '0' ? '' : "<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$sub[id]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$sub[id]]\" value=\"$sub[displayorder]\">",
"<div class=\"".($subnavnum ? 'board' : 'lastboard')."\"><input type=\"text\" class=\"txt\" size=\"15\" name=\"namenew[$sub[id]]\" value=\"".dhtmlspecialchars($sub['name'])."\"></div>",
$sub['type'] == '0' ? $sub['url'] : "<input type=\"text\" class=\"txt\" size=\"15\" name=\"urlnew[$sub[id]]\" value=\"".dhtmlspecialchars($sub['url'])."\">",
lang($sub['type'] == '0' ? 'inbuilt' : 'costom'),
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$sub[id]]\" value=\"1\" ".($sub['available'] ? 'checked' : '').">",
"<a href=\"$BASESCRIPT?action=misc&operation=customnav&do=edit&id=$sub[id]\" class=\"act\">$lang[detail]</a>"
));
}
}
}
echo '<tr><td colspan="2"></td><td colspan="5"><div><a href="###" onclick="addrow(this, 0, 0)" class="addtr">'.$lang['misc_customnav_add_menu'].'</a></div></td></tr>';
showsubmit('submit', 'submit', 'del');
showtablefooter();
showformfooter();
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucapparray = uc_app_ls();
$applist = '';
if(count($ucapparray) > 1) {
$applist = $lang['misc_customnav_add_ucenter'].'<select name="applist" onchange="app(this)"><option value=""></option>';
foreach($ucapparray as $app) {
if($app['appid'] != UC_APPID) {
$applist .= "<option value=\"$app[url]\">$app[name]</option>";
}
}
$applist .= '</select>';
}
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1, '', 'td25'], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td28'], [1, '<input name="newname[]" value="" size="30" type="text" class="txt">'], [1, '<input name="newurl[]" value="" size="30" type="text" class="txt">', 'td29'], [3, '$applist <input type="hidden" name="newparentid[]" value="0" />']],
[[1, '', 'td25'], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td28'], [1, '<div class=\"board\"><input name="newname[]" value="" size="30" type="text" class="txt"></div>'], [1, '<input name="newurl[]" value="" size="30" type="text" class="txt">', 'td29'], [3, '$applist <input type="hidden" name="newparentid[]" value="{1}" />']]
];
function app(obj) {
var inputs = obj.parentNode.parentNode.getElementsByTagName('input');
for(var i = 0; i < inputs.length; i++) {
if(inputs[i].name == 'newname[]') {
inputs[i].value = obj.options[obj.options.selectedIndex].innerHTML;
} else if(inputs[i].name == 'newurl[]') {
inputs[i].value = obj.value;
}
}
}
</script>
EOT;
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}navs WHERE id IN ($ids)");
$db->query("DELETE FROM {$tablepre}navs WHERE parentid IN ($ids)");
}
if(is_array($namenew)) {
foreach($namenew as $id => $name) {
$name = dhtmlspecialchars($name);
$urladd = !empty($urlnew[$id]) ? ", url='".str_replace('&', '&', dhtmlspecialchars($urlnew[$id]))."'" : '';
$availablenew[$id] = $name && (!isset($urlnew[$id]) || $urlnew[$id]) && $availablenew[$id];
$displayordernew[$id] = intval($displayordernew[$id]);
$db->query("UPDATE {$tablepre}navs SET name='$name', displayorder='$displayordernew[$id]', available='$availablenew[$id]' $urladd WHERE id='$id'");
}
}
if(is_array($newname)) {
foreach($newname as $k => $v) {
$v = dhtmlspecialchars(trim($v));
if(!empty($v)) {
$newavailable = $v && $newurl[$k];
$newparentid[$k] = intval($newparentid[$k]);
$newdisplayorder[$k] = intval($newdisplayorder[$k]);
$newurl[$k] = str_replace('&', '&', dhtmlspecialchars($newurl[$k]));
$db->query("INSERT INTO {$tablepre}navs (parentid, name, displayorder, url, type, available) VALUES ('$newparentid[$k]', '$v', '$newdisplayorder[$k]', '$newurl[$k]', '1', '$newavailable')");
}
}
}
updatecache('settings');
cpmsg('nav_add_succeed', $BASESCRIPT.'?action=misc&operation=customnav', 'succeed');
}
} elseif($do == 'edit' && $id) {
$nav = $db->fetch_first("SELECT * FROM {$tablepre}navs WHERE id='$id'");
if(!$nav) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
$string = sprintf('%02d', $nav['highlight']);
shownav('global', 'misc_customnav');
showsubmenu('settings_styles', array(
array('nav_settings_global', 'settings&operation=styles&anchor=global', 0),
array('nav_settings_customnav', 'misc&operation=customnav', 1),
array('nav_settings_index', 'settings&operation=styles&anchor=index', 0),
array('nav_settings_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', 0),
array('nav_settings_viewthread', 'settings&operation=styles&anchor=viewthread', 0),
array('nav_settings_member', 'settings&operation=styles&anchor=member', 0),
array('nav_settings_refresh', 'settings&operation=styles&anchor=refresh', 0)
));
showformheader("misc&operation=customnav&do=edit&id=$id");
showtableheader();
showtitle('misc_customnav_detail');
showsetting('misc_customnav_name', 'namenew', $nav['name'], 'text');
showsetting('misc_customnav_title', 'titlenew', $nav['title'], 'text');
showsetting('misc_customnav_url', 'urlnew', $nav['url'], 'text', $nav['type'] == '0');
showsetting('misc_customnav_style', array('stylenew', array(lang('misc_customnav_style_underline'), lang('misc_customnav_style_italic'), lang('misc_customnav_style_bold'))), $string[0], 'binmcheckbox');
showsetting('misc_customnav_style_color', array('colornew', array(
array(0, '<span style="color: '.LINK.';">Default</span>'),
array(1, '<span style="color: Red;">Red</span>'),
array(2, '<span style="color: Orange;">Orange</span>'),
array(3, '<span style="color: Yellow;">Yellow</span>'),
array(4, '<span style="color: Green;">Green</span>'),
array(5, '<span style="color: Cyan;">Cyan</span>'),
array(6, '<span style="color: Blue;">Blue</span>'),
array(7, '<span style="color: Purple;">Purple</span>'),
array(8, '<span style="color: Gray;">Gray</span>'),
)), $string[1], 'mradio');
showsetting('misc_customnav_url_open', array('targetnew', array(
array(0, lang('misc_customnav_url_open_default')),
array(1, lang('misc_customnav_url_open_blank'))
), TRUE), $nav['target'], 'mradio');
showsetting('plugins_edit_modules_adminid', array('levelnew', array(
array(0, lang('nolimit')),
array(1, lang('member')),
array(2, lang('usergroups_system_3')),
array(3, lang('usergroups_system_1')),
)), $nav['level'], 'select');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$namenew = dhtmlspecialchars(trim($namenew));
$titlenew = dhtmlspecialchars(trim($titlenew));
$urlnew = dhtmlspecialchars(trim($urlnew));
$stylebin = '';
for($i = 3; $i >= 1; $i--) {
$stylebin .= empty($stylenew[$i]) ? '0' : '1';
}
$stylenew = bindec($stylebin);
$targetnew = intval($targetnew) ? 1 : 0;
$levelnew = intval($levelnew) && $levelnew > 0 && $levelnew < 4 ? intval($levelnew) : 0 ;
$urladd = $nav['type'] == '1' && $urlnew ? ", url='".dhtmlspecialchars($urlnew)."'" : '';
$db->query("UPDATE {$tablepre}navs SET name='$namenew', title='$titlenew', highlight='$stylenew$colornew', target='$targetnew', level='$levelnew' $urladd WHERE id='$id'");
updatecache('settings');
cpmsg('nav_add_succeed', $BASESCRIPT.'?action=misc&operation=customnav', 'succeed');
}
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/misc.inc.php
|
PHP
|
asf20
| 52,678
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: insenz.func.php 17311 2008-12-12 09:43:53Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
function insenz_checkfiles() {
global $file;
if(INSENZ_CHECKFILES) {
$insenzfiles = array(
'727ee8758b60a8d281f9d4a7e9778fbc' => './api/insenz.php',
'b19e7fd23c85e4612674d144b20fb95c' => './include/insenz.func.php',
'7a283729f138829bfd3eeae975338ed3' => './include/insenz_cron.func.php',
'e1b1d72d90ef300dedac7c8c8f872fd8' => './include/xmlparser.class.php'
);
foreach($insenzfiles as $md5 => $file) {
if(!file_exists($file) || $md5 != md5_file(DISCUZ_ROOT.$file)) {
cpmsg('insenz_upload_failed', '', 'error');
}
}
}
}
function checkusername($username) {
$username = trim($username);
if(strlen($username) < 4 || strlen($username) > 20) {
insenz_alert('insenz_username_length_outof_range', 'username');
} elseif(!preg_match("/^\w+$/i", $username)) {
insenz_alert('insenz_username_length_out_of_ranger', 'username');
}
return $username;
}
function checkpassword($password, $password2) {
if($password != $password2) {
insenz_alert('insenz_password_twice_diffenrent', 'password2');
} elseif(strlen($password) < 6 || strlen($password) > 20) {
insenz_alert('insenz_password_length_outof_range', 'password');
} elseif(!preg_match("/^[0-9a-z!#$%&()+\\-.\\[\\]\\/\\\\@?{}|:;]+$/i", $password)) {
insenz_alert('insenz_password_include_special_character', 'password');
}
return $password;
}
function checkname($name) {
$name = trim($name);
if(strlen($name) < 4 || strlen($name) > 30) {
insenz_alert('insenz_name_length_outof_range', 'name');
} elseif(htmlspecialchars($name) != $name) {
insenz_alert('insenz_name_illegal', 'name');
}
return $name;
}
function checkemail($email, $emailname) {
$email = trim($email);
if(strlen($email) < 7 || !preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email)) {
insenz_alert('insenz_'.$emailname.'_illegal', $emailname);
}
return htmlspecialchars($email);
}
function checkidcard($idcard) {
$idcard = htmlspecialchars(trim($idcard));
if(strlen($idcard) == 18) {
if(idcard_verify_number(substr($idcard, 0, 17)) == strtoupper($idcard{17})) {
return $idcard;
}
}
insenz_alert('insenz_idcard_illegal', 'idcard');
}
function checktel($tel1, $tel2, $tel3, $telname) {
if(!preg_match("/^\d{2,4}$/", $tel1) || !preg_match("/^\d{5,10}$/", $tel2) || ($tel3 && !preg_match("/^\d{1,5}$/", $tel3))) {
insenz_alert($telname.'insenz_illegal', $telname);
}
return $tel1.'-'.$tel2.'-'.$tel3;
}
function checkqq($qq) {
if(!(preg_match("/^([0-9]+)$/", $qq) && strlen($qq) >= 5 && strlen($qq) <= 12)) {
insenz_alert('insenz_qq_illegal', 'qq');
}
return $qq;
}
function checkmobile($mobile) {
if(!preg_match("/^1(3|5)\d{9}$/", $mobile)) {
insenz_alert('insenz_mobile_illegal', 'mobile');
}
return $mobile;
}
function checkcpc($country, $province, $city) {
$country = intval($country);
if($country < 10000 || $country > 70300) {
insenz_alert('insenz_country_illegal', 'country');
}
$province = intval($province);
if($country == 10000 && ($province < 10100 || $province > 13100)) {
insenz_alert('insenz_province_illegal', 'province');
}
$city = intval($city);
if($country == 10000 && ($city < 10101 || $city > 13107)) {
insenz_alert('insenz_city_illegal', 'city');
}
return array($country, $province, $city);
}
function checkaddress($address) {
$address = htmlspecialchars(trim($address));
if(strlen($address) < 8) {
insenz_alert('insenz_real_address_illegal', 'address');
}
return cutstr($address, 200);
}
function checkpostcode($postcode) {
if(!preg_match("/^\d{6}$/", $postcode)) {
insenz_alert('insenz_post_code_illegal', 'postcode');
}
return $postcode;
}
function idcard_verify_number($idcard_base) {
$factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
$verify_number_list = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
$checksum = 0;
for($i = 0; $i < strlen($idcard_base); $i++) {
$checksum += substr($idcard_base, $i, 1) * $factor[$i];
}
$mod = $checksum % 11;
$verify_number = $verify_number_list[$mod];
return $verify_number;
}
function checkmasks($return = FALSE) {
global $insenz, $db, $tablepre, $admins, $members, $noneexistusers, $member;
if(!$admins = trim($admins)) {
$return ? cpmsg('insenz_require_one_admin', '', 'error') : insenz_alert('insenz_require_one_admin', 'admins');
} else {
$admins = array_unique(explode("\n", str_replace(array("\r\n", "\r"), array("\n", "\n"), $admins)));
}
$admin_masks = $member_masks = array();
$query = $db->query("SELECT uid, username, adminid FROM {$tablepre}members WHERE username IN ('".implode("','", $admins)."')");
while($member = $db->fetch_array($query)) {
if($member['adminid'] <= 0) {
$return ? cpmsg('insenz_illegal_admin', '', 'error') : insenz_alert('insenz_illegal_admin', 'admins');
}
$admin_masks[$member['uid']] = addslashes($member['username']);
}
if($noneexistusers = array_diff($admins, $admin_masks)) {
$noneexistusers = stripslashes(implode(', ', $noneexistusers));
$return ? cpmsg('insenz_user_not_exists', '', 'error') : insenz_alert('insenz_user_not_exists', 'admins');
}
$members = array_unique(explode("\n", str_replace(array("\r\n", "\r"), array("\n", "\n"), trim($members))));
if(count($members) < 2) {
$return ? cpmsg('insenz_require_two_normal_poster', '', 'error') : insenz_alert('insenz_require_two_normal_poster', 'members');
}
$query = $db->query("SELECT uid, username, adminid FROM {$tablepre}members WHERE username IN ('".implode("','", $members)."')");
while($member = $db->fetch_array($query)) {
if($member['adminid'] > 0) {
$return ? cpmsg('insenz_not_normal_user', '', 'error') : insenz_alert('insenz_not_normal_user', 'members');
}
$member_masks[$member['uid']] = addslashes($member['username']);
}
if($noneexistusers = array_diff($members, $member_masks)) {
$noneexistusers = stripslashes(implode(', ', $noneexistusers));
$return ? cpmsg('insenz_user_not_exists', '', 'error') : insenz_alert('insenz_user_not_exists', 'members');
}
$modified = $insenz['admin_masks'] != $admin_masks || $insenz['member_masks'] != $member_masks;
if(INSENZ_SAFEMODE && $insenz['member_masks'] != $member_masks) {
if(!empty($insenz['groupid'])) {
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}usergroups WHERE groupid='$insenz[groupid]'");
if(!$db->result($query, 0)) {
unset($insenz['groupid']);
}
}
if(empty($insenz['groupid'])) {
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type='member' ORDER BY creditslower DESC LIMIT 5");
$groups = array();
while($group = $db->fetch_array($query)) {
$groups[$group['groupid']] = $group['grouptitle'];
}
$randgid = array_rand($groups);
$grouptitle = $groups[$randgid] ? $groups[$randgid] : 'Member';
$query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE groupid='$randgid'");
$fieldnums = mysql_num_fields($query);
$group = $db->fetch_array($query);
$fields = '';
for($i = 0; $i < $fieldnums; $i++) {
$field = mysql_field_name($query, $i);
if(!in_array($field, array('groupid', 'type', 'grouptitle', 'allowpost', 'allowreply'))) {
$fields .= ", $field='$group[$field]'";
}
}
$db->query("INSERT INTO {$tablepre}usergroups SET type='special', grouptitle='$grouptitle', allowpost='1', allowreply='1' $fields");
$insenz['groupid'] = $db->insert_id();
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('usergroups');
}
$db->query("UPDATE {$tablepre}members SET adminid=-1, groupid='$insenz[groupid]' WHERE uid IN (".implodeids(array_keys($member_masks)).")");
}
$insenz['admin_masks'] = array_keys($admin_masks);
$insenz['member_masks'] = array_keys($member_masks);
if($return) {
return $modified;
}
}
function checkip() {
global $boardurl, $onlineip;
if(INSENZ_CHECKIP) {
$longip = ip2long($onlineip);
if(substr($onlineip, 0, 1) == '0' || substr($onlineip, 0, 3) == '127' || isInRange($longip, 167772160, 184549375) || isInRange($longip, -1408237568, -1407188993) || isInRange($longip, -1062731776, -1062666241)) {
cpmsg('insenz_intranet_not_allowed', '', 'error');
}
}
}
function isInRange($x, $min, $max) {
return $x >= $min && $x <= $max;
}
function insenz_register($type) {
global $insenz, $db, $tablepre, $_DCACHE, $boardurl, $timestamp, $authkey, $discuz_uid, $discuz_user, $response, $BASESCRIPT;
checkip();
if($type == 1) {
@extract($insenz['profile']);
foreach(array('username', 'password', 'name', 'idcard', 'email1', 'email2', 'qq', 'msn', 'tel1', 'tel2', 'tel3', 'mobile', 'fax1', 'fax2', 'fax3', 'country', 'province', 'city', 'address', 'postcode', 'alipay') as $item) {
$$item = stripslashes($$item);
}
} else {
$username = $insenz['profile']['username'];
$password = $insenz['profile']['password'];
}
$insenz['notify'] = is_array($insenz['notify']) ? $insenz['notify'] : array(2);
$insenz['hardadstatus'] = is_array($insenz['hardadstatus']) ? $insenz['hardadstatus'] : array(1, 2, 3, 4, 5);
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}members");
$members = $db->result($query, 0);
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}members WHERE posts>0");
$post_members = $db->result($query, 0);
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}threads WHERE displayorder>='0'");
$threads = $db->result($query, 0);
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}posts WHERE invisible='0'");
$posts = $db->result($query, 0);
$date = getdate($timestamp);
$yesterday_end = mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']);
$lastweek_start = $yesterday_end - 7*86400;
$lastweek_pertopics = $lastweek_perposts = $forumstats = array();
$query = $db->query("SELECT DISTINCT(fid) AS fid, COUNT(tid) AS topics FROM {$tablepre}threads WHERE dateline BETWEEN $lastweek_start AND $yesterday_end GROUP BY fid ORDER BY topics DESC");
while($p = $db->fetch_array($query)) {
$lastweek_pertopics[$p['fid']] = ceil($p['topics'] / 7);
}
$query = $db->query("SELECT DISTINCT(fid) AS fid, COUNT(pid) AS posts FROM {$tablepre}posts WHERE dateline BETWEEN $lastweek_start AND $yesterday_end GROUP BY fid ORDER BY posts DESC");
while($p = $db->fetch_array($query)) {
$lastweek_perposts[$p['fid']] = ceil($p['posts'] / 7);
}
$query = $db->query("SELECT f.fid, f.fup, f.type, f.name, f.threads, f.posts, f.displayorder, f.status, f.simple, ff.description, ff.redirect FROM {$tablepre}forums f LEFT JOIN {$tablepre}forumfields ff ON f.fid=ff.fid");
while($forum = $db->fetch_array($query)) {
$fid = $forum['fid'];
unset($forum['fid']);
$forum['lastweek_pertopics'] = intval($lastweek_pertopics[$fid]);
$forum['lastweek_perposts'] = intval($lastweek_perposts[$fid]);
$forumstats[$fid] = $forum;
}
$postdata = '<cmd id="register"><handle>'.insenz_convert($username).'</handle>
<passwd>'.$password.'</passwd>';
if($type == 1) {
$postdata .= '<name>'.insenz_convert($name).'</name>
<idcard>'.$idcard.'</idcard>
<tel>'.$tel1.'-'.$tel2.'-'.$tel3.'</tel>
<mobile>'.$mobile.'</mobile>
<fax>'.$fax1.'-'.$fax2.'-'.$fax3.'</fax>
<email>'.$email1.'</email>
<email2>'.$email2.'</email2>
<qq>'.$qq.'</qq>
<msn>'.$msn.'</msn>
<alipay>'.$alipay.'</alipay>
<country>'.$country.'</country>
<province>'.$province.'</province>
<city>'.$city.'</city>
<addr>'.insenz_convert($address).'</addr>
<postcode>'.$postcode.'</postcode>';
}
$postdata .= '<url>'.$boardurl.'</url>
<s_key>'.md5($authkey.'Discuz!INSENZ').'</s_key>
<bbname>'.insenz_convert($_DCACHE['settings']['bbname']).'</bbname>
<members>'.$members.'</members>
<post_members>'.$post_members.'</post_members>
<topics>'.$threads.'</topics>
<posts>'.$posts.'</posts>
<softadstatus>'.intval($insenz['softadstatus']).'</softadstatus>
<notify>'.implode(',', $insenz['notify']).'</notify>
<autoextend>'.intval($insenz['autoextend']).'</autoextend>
<hardadstatus>'.implode(',', $insenz['hardadstatus']).'</hardadstatus>
<relatedadstatus>'.intval($insenz['relatedadstatus']).'</relatedadstatus>
<virtualforumstatus>'.intval($insenz['virtualforumstatus']).'</virtualforumstatus>';
foreach($forumstats as $fid => $forum) {
$postdata .= '<board>
<board_id>'.$fid.'</board_id>
<parent_id>'.$forum['fup'].'</parent_id>
<board_type>'.$forum['type'].'</board_type>
<name>'.insenz_convert($forum['name']).'</name>
<topics>'.$forum['threads'].'</topics>
<posts>'.$forum['posts'].'</posts>
<lastweek_pertopics>'.$forum['lastweek_pertopics'].'</lastweek_pertopics>
<lastweek_perposts>'.$forum['lastweek_perposts'].'</lastweek_perposts>
<description>'.insenz_convert($forum['description']).'</description>
<status>'.$forum['status'].'</status>
<simple>'.$forum['simple'].'</simple>
<redirect>'.insenz_convert($forum['redirect']).'</redirect>
<displayorder>'.$forum['displayorder'].'</displayorder></board>';
}
$postdata .= '<type>'.($type == 1 ? 'register' : 'bind').'</type></cmd>';
unset($insenz['siteid']);
$response = insenz_request($postdata);
if($response['status']) {
insenz_alert($response['data']);
} else {
$response = $response['data'];
}
$status = $response['response'][0]['status'][0]['VALUE'];
if($status == 0) {
$insenz['authkey'] = $response['response'][0]['authkey'][0]['VALUE'];
$insenz['siteid'] = $response['response'][0]['site_id'][0]['VALUE'];
$insenz['uid'] = $discuz_uid;
$insenz['username'] = $discuz_userss;
$insenz['handle'] = $username;
insenz_updatesettings();
unset($insenz['profile'], $insenz['step']);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('settings');
insenz_cpmsg('insenz_register_succeed', $BASESCRIPT.'?action=insenz', 'succeed');
} else {
$response['reason'] = insenz_convert($response['response'][0]['reason'][0]['VALUE'], 0);
unset($insenz['authkey'], $insenz['siteid']);
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
insenz_alert('insenz_register_failed');
}
}
function insenz_showsettings($do = '') {
global $insenz, $db, $tablepre, $discuz_user, $timestamp, $lang;
$type = array('basic' => $lang['insenz_settings_basic'], 'softad' => $lang['insenz_settings_softad'], 'hardad' => $lang['insenz_settings_hardad'], 'relatedad' => $lang['insenz_settings_relatedad'], 'virtualforum' => $lang['insenz_settings_virtualforum']);
if(!$do || $do == 'basic') {
$insenz['notify'] = is_array($insenz['notify']) ? $insenz['notify'] : array();
$insenz['notify'][2] = 1;
$insenz_notify = bindec(intval($insenz['notify'][2]).intval($insenz['notify'][1]));
$msgto = '';
if(!empty($insenz['msgtoid'])) {
$query = $db->query("SELECT username FROM {$tablepre}members WHERE uid='$insenz[msgtoid]'");
$msgto = $db->result($query, 0);
}
$msgto = $msgto ? $msgto : $discuz_userss;
$disabled = $insenz['notify'][1] ? 0 : 1;
if(!$do) {
showtitle($type['basic']);
} else {
showtableheader();
showtitle($type['basic']);
if(empty($insenz['handle'])) {
$response = insenz_request('<cmd id="queryhandle"></cmd>');
if($response['status']) {
$insenz['handle'] = '';
} else {
$insenz['handle'] = $response['data']['response'][0]['handle'][0]['VALUE'];
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('insenz', '".addslashes(serialize($insenz))."')");
}
}
if($insenz['handle']) {
showsetting('insenz_username', '', '', $insenz['handle']);
}
}
showsetting('insenz_settings_notify', array('notify', array($lang['insenz_settings_notify1'], $lang['insenz_settings_notify2']), array('onclick="this.form.msgto.disabled=this.checked?false:true;"', '')), $insenz_notify, 'binmcheckbox');
showsetting('insenz_settings_msgto', 'msgto', $msgto, 'text', $disabled);
}
if(!$do || $do == 'softad') {
$insenz['softadstatus'] = isset($insenz['softadstatus']) ? $insenz['softadstatus'] : 2;
$softadstatus1 = $insenz['softadstatus'] ? 1 : 0;
$softadstatus2 = $insenz['softadstatus'] == 2 ? 1 : 0;
$nextmodified = gmdate("$GLOBALS[dateformat] $GLOBALS[timeformat]", (empty($insenz['lastmodified']) || $insenz['lastmodified'] + 14 * 86400 < $timestamp ? $timestamp : $insenz['lastmodified'] + 14 * 86400) + $GLOBALS['timeoffset'] * 3600);
$admin_masks = $member_masks = array();
if($insenz['admin_masks'] && is_array($insenz['admin_masks'])) {
$query = $db->query("SELECT username FROM {$tablepre}members WHERE uid IN ('".implode("','", $insenz['admin_masks'])."')");
while($member = $db->fetch_array($query)) {
$admin_masks[] = $member['username'];
}
}
$admin_masks = stripslashes(implode("\n", $admin_masks));
if($insenz['member_masks'] && is_array($insenz['member_masks'])) {
$query = $db->query("SELECT username FROM {$tablepre}members WHERE uid IN ('".implode("','", $insenz['member_masks'])."')");
while($member = $db->fetch_array($query)) {
$member_masks[] = $member['username'];
}
}
$member_masks = stripslashes(implode("\n", $member_masks));
if(!$do) {
showtitle($type['softad']);
} else {
showtableheader();
showtitle($type['softad']);
}
showsetting('insenz_settings_softadstatus1', 'softadstatus1', $softadstatus1, 'radio', '', 1);
showsetting('insenz_settings_softadstatus2', 'softadstatus2', $softadstatus2, 'radio');
showsetting('insenz_settings_admins', 'admins', $insenz['admin_masks'] ? $admin_masks : '', 'textarea');
showsetting('insenz_settings_members', 'members', $insenz['member_masks'] ? $member_masks : '', 'textarea');
showtagfooter('tbody');
}
if(!$do || $do == 'hardad') {
$availableadvs = array(
1 => $lang['insenz_settings_availableadvs1'],
2 => $lang['insenz_settings_availableadvs2'],
3 => $lang['insenz_settings_availableadvs3'],
4 => $lang['insenz_settings_availableadvs4'],
5 => $lang['insenz_settings_availableadvs5'],
6 => $lang['insenz_settings_availableadvs6'],
7 => $lang['insenz_settings_availableadvs7'],
8 => $lang['insenz_settings_availableadvs8']
);
$insenz['availableadvs'] = is_array($insenz['availableadvs']) ? $insenz['availableadvs'] : array(1, 2, 3, 4, 5);
$insenz['hardadstatus'] = is_array($insenz['hardadstatus']) ? $insenz['hardadstatus']: array(1, 2, 3, 4, 5);
$insenz_availableadvs = array();
foreach($insenz['availableadvs'] as $ad) {
$insenz_availableadvs[$ad] = $availableadvs[$ad];
}
if(!$do) {
showtitle($type['hardad']);
} else {
showtableheader();
showtitle($type['hardad']);
}
$insenz_hardadstatus = '';
for($i = count($insenz['availableadvs']); $i >= 1; $i--) {
$insenz_hardadstatus .= in_array($i, $insenz['hardadstatus']) ? 1 : 0;
}
$insenz_hardadstatus = bindec($insenz_hardadstatus);
showsetting('insenz_settings_hardadstatus', array('hardadstatus', $insenz_availableadvs), $insenz_hardadstatus, 'binmcheckbox');
}
if(!$do || $do == 'relatedad') {
$insenz['relatedadstatus'] = isset($insenz['relatedadstatus']) ? $insenz['relatedadstatus'] : 1;
if(!$do) {
showtitle($type['relatedad']);
} else {
showtableheader();
showtitle($type['relatedad']);
}
showsetting('insenz_settings_relatedadstatus', 'relatedadstatus', $insenz['relatedadstatus'], 'radio');
}
if(!$do || $do == 'virtualforum') {
$insenz['virtualforumstatus'] = isset($insenz['virtualforumstatus']) ? $insenz['virtualforumstatus'] : 1;
if(!$do) {
showtitle($type['virtualforum']);
} else {
showtableheader();
showtitle($type['virtualforum']);
}
showsetting('insenz_settings_virtualforumstatus', 'virtualforumstatus', $insenz['virtualforumstatus'], 'radio');
}
}
function insenz_updatesettings() {
global $insenz, $response;
$insenz['availableadvs'] = explode(',', $response['response'][0]['availableadvs'][0]['VALUE']);
$insenz['hardadstatus'] = array_intersect(is_array($insenz['hardadstatus']) ? $insenz['hardadstatus'] : array(), $insenz['availableadvs']);
if($insenz['relatedadstatus']) {
$insenz['topicrelatedad'] = insenz_convert($response['response'][0]['topicrelatedad'][0]['VALUE'], 0);
$insenz['traderelatedad'] = insenz_convert($response['response'][0]['traderelatedad'][0]['VALUE'], 0);
$insenz['relatedtrades'] = insenz_convert($response['response'][0]['relatedtrades'][0]['VALUE'], 0);
} else {
$insenz['topicrelatedad'] = $insenz['traderelatedad'] = $insenz['relatedtrades'] = '';
}
$jsurl = $response['response'][0]['jsurl'][0]['VALUE'];
$insenz['jsurl'] = $jsurl ? $jsurl : $insenz['jsurl'];
if(isset($response['response'][0]['topicstatus'])) {
$insenz['topicstatus'] = intval($response['response'][0]['topicstatus'][0]['VALUE']);
}
$insenz['status'] = $insenz['softadstatus'] || $insenz['hardadstatus'] || $insenz['topicrelatedad'] || $insenz['traderelatedad'] || $insenz['topicstatus'];
}
function insenz_request($data, $return = TRUE, $fp = '') {
global $insenz, $timestamp;
@include_once DISCUZ_ROOT.'./discuz_version.php';
$authkey = !empty($insenz['authkey']) ? $insenz['authkey'] : 'Discuz!INSENZ';
$t_hex = sprintf("%08x", $timestamp);
$postdata = '<?xml version="1.0" encoding="UTF'.'-8"?><request insenz_version="'.INSENZ_VERSION.'" discuz_version="'.DISCUZ_VERSION.' - '.DISCUZ_RELEASE.'">'.$data.'</request>';
$postdata = insenz_authcode($t_hex.md5($authkey.$postdata.$t_hex).$postdata, 'ENCODE', $authkey);
if(!$fp && !$fp = @fsockopen($insenz['host'], 80)) {
if(!$return) {
return;
} else {
return array('status' => 1, 'data' => lang('insenz_connect_failed'));
}
}
$insenz['siteid'] = intval($insenz['siteid']);
@fwrite($fp, "POST http://$insenz[url]/discuz.php?s_id=$insenz[siteid] HTTP/1.0\r\n");
@fwrite($fp, "Host: $insenz[host]\r\n");
@fwrite($fp, "Content-Type: file\r\n");
@fwrite($fp, "Content-Length: " . strlen($postdata) ."\r\n\r\n");
@fwrite($fp, $postdata);
if(!$return) {
@fclose($fp);
return;
}
$res = '';
$isheader = 1;
while(!feof($fp)) {
$buffer = @fgets($fp, 1024);
if(!$isheader) {
$res .= $buffer;
} elseif(trim($buffer) == '') {
$isheader = 0;
}
}
@fclose($fp);
if(empty($res)) {
return array('status' => 1, 'data' => lang('insenz_connect_failed'));
}
if(!$response = insenz_authcode($res, 'DECODE', $authkey)) {
return array('status' => 1, 'data' => lang('insenz_connect_failed'));
}
$checkKey = substr($response, 0, 40);
$response = substr($response, 40);
$t_hex = substr($checkKey, 0, 8);
$t = base_convert($t_hex, 16, 10);
if(abs($timestamp - $t) > 1200) {
return array('status' => 1, 'data' => lang('insenz_connect_timeout'));
} elseif($checkKey != $t_hex.md5($authkey.$response.$t_hex)) {
return array('status' => 1, 'data' => 'Invalid Key or Data');
}
require_once DISCUZ_ROOT.'./include/xmlparser.class.php';
$xmlparse = new XMLParser;
$xmlparseddata = $xmlparse->getXMLTree($response);
if(!is_array($xmlparseddata) || !is_array($xmlparseddata['response'])) {
return array('status' => 1, 'data' => lang('insenz_transport_failed'));
}
return array('status' => 0, 'data' => $xmlparseddata);
}
function insenz_alert($message, $focusobj = '') {
extract($GLOBALS, EXTR_SKIP);
include language('admincp.msg');
eval("\$message = \"".(isset($msglang[$message]) ? $msglang[$message] : $message)."\";");
echo '<script type="text/JavaScript">alert(\''.str_replace('\'', '\\\'', $message).'\');'.($focusobj ? 'parent.document.form1.'.$focusobj.'.focus();' : '').'</script>';
exit;
}
function insenz_cpmsg($message, $url, $type = '') {
extract($GLOBALS, EXTR_SKIP);
include language('admincp.msg');
eval("\$message = \"".(isset($msglang[$message]) ? $msglang[$message] : $message)."\";");
switch($type) {
case 'succeed': $classname = 'infotitle2';break;
case 'error': $classname = 'infotitle3';break;
case 'loading': $classname = 'infotitle1';break;
default: $classname = 'marginbot normal';break;
}
$message = '<h4 class="'.$classname.'">'.$message.'</h4><p class="marginbot"><a href="'.$url.'" class="lightlink">'.lang('message_redirect').'</a></p>';
$url = transsid($url);
echo '<script type="text/JavaScript">parent.setTimeout("redirect(\''.$url.'\');", 2000);parent.$("cpcontainer").innerHTML = \'<h3>'.$lang['discuz_message'].'</h3><div class="infobox">'.$message.'</div>\';</script>';
dexit();
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/insenz.func.php
|
PHP
|
asf20
| 25,314
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: zip.func.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
// vim: expandtab sw=4 ts=4 sts=4:
class zipfile {
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
var $old_offset = 0;
function unix2DosTime($unixtime = 0) {
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
if($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
} // end if
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
} // end of the 'unix2DosTime()' method
function addFile($data, $name, $time = 0) {
$name = str_replace('\\', '/', $name);
$dtime = dechex($this->unix2DosTime($time));
$hexdtime = '\x' . $dtime[6] . $dtime[7]
. '\x' . $dtime[4] . $dtime[5]
. '\x' . $dtime[2] . $dtime[3]
. '\x' . $dtime[0] . $dtime[1];
eval('$hexdtime = "' . $hexdtime . '";');
$fr = "\x50\x4b\x03\x04";
$fr .= "\x14\x00"; // ver needed to extract
$fr .= "\x00\x00"; // gen purpose bit flag
$fr .= "\x08\x00"; // compression method
$fr .= $hexdtime; // last mod time and date
// "local file header" segment
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$c_len = strlen($zdata);
$fr .= pack('V', $crc); // crc32
$fr .= pack('V', $c_len); // compressed filesize
$fr .= pack('V', $unc_len); // uncompressed filesize
$fr .= pack('v', strlen($name)); // length of filename
$fr .= pack('v', 0); // extra field length
$fr .= $name;
// "file data" segment
$fr .= $zdata;
// "data descriptor" segment (optional but necessary if archive is not
// served as file)
// nijel(2004-10-19): this seems not to be needed at all and causes
// problems in some cases (bug #1037737)
//$fr .= pack('V', $crc); // crc32
//$fr .= pack('V', $c_len); // compressed filesize
//$fr .= pack('V', $unc_len); // uncompressed filesize
// add this entry to array
$this -> datasec[] = $fr;
// now add to central directory record
$cdrec = "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"; // version made by
$cdrec .= "\x14\x00"; // version needed to extract
$cdrec .= "\x00\x00"; // gen purpose bit flag
$cdrec .= "\x08\x00"; // compression method
$cdrec .= $hexdtime; // last mod time & date
$cdrec .= pack('V', $crc); // crc32
$cdrec .= pack('V', $c_len); // compressed filesize
$cdrec .= pack('V', $unc_len); // uncompressed filesize
$cdrec .= pack('v', strlen($name) ); // length of filename
$cdrec .= pack('v', 0 ); // extra field length
$cdrec .= pack('v', 0 ); // file comment length
$cdrec .= pack('v', 0 ); // disk number start
$cdrec .= pack('v', 0 ); // internal file attributes
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
$this -> old_offset += strlen($fr);
$cdrec .= $name;
// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'addFile()' method
function file() {
$data = implode('', $this -> datasec);
$ctrldir = implode('', $this -> ctrl_dir);
return
$data .
$ctrldir .
$this -> eof_ctrl_dir .
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
pack('V', strlen($ctrldir)) . // size of central dir
pack('V', strlen($data)) . // offset to start of central dir
"\x00\x00"; // .zip file comment length
} // end of the 'file()' method
} // end of the 'zipfile' class
class SimpleUnzip {
// 2003-12-02 - HB >
var $Comment = '';
// 2003-12-02 - HB <
var $Entries = array();
var $Name = '';
var $Size = 0;
var $Time = 0;
function SimpleUnzip($in_FileName = '') {
if($in_FileName !== '') {
SimpleUnzip::ReadFile($in_FileName);
}
} // end of the 'SimpleUnzip' constructor
function Count() {
return count($this->Entries);
} // end of the 'Count()' method
function GetData($in_Index) {
return $this->Entries[$in_Index]->Data;
} // end of the 'GetData()' method
function GetEntry($in_Index) {
return $this->Entries[$in_Index];
} // end of the 'GetEntry()' method
function GetError($in_Index) {
return $this->Entries[$in_Index]->Error;
} // end of the 'GetError()' method
function GetErrorMsg($in_Index) {
return $this->Entries[$in_Index]->ErrorMsg;
} // end of the 'GetErrorMsg()' method
function GetName($in_Index) {
return $this->Entries[$in_Index]->Name;
} // end of the 'GetName()' method
function GetPath($in_Index) {
return $this->Entries[$in_Index]->Path;
} // end of the 'GetPath()' method
function GetTime($in_Index) {
return $this->Entries[$in_Index]->Time;
} // end of the 'GetTime()' method
function ReadFile($in_FileName) {
$this->Entries = array();
// Get file parameters
$this->Name = $in_FileName;
$this->Time = filemtime($in_FileName);
$this->Size = filesize($in_FileName);
// Read file
$oF = fopen($in_FileName, 'rb');
$vZ = fread($oF, $this->Size);
fclose($oF);
// 2003-12-02 - HB >
// Cut end of central directory
$aE = explode("\x50\x4b\x05\x06", $vZ);
// Easiest way, but not sure if format changes
//$this->Comment = substr($aE[1], 18);
// Normal way
$aP = unpack('x16/v1CL', $aE[1]);
$this->Comment = substr($aE[1], 18, $aP['CL']);
// Translates end of line from other operating systems
$this->Comment = strtr($this->Comment, array("\r\n" => "\n",
"\r" => "\n"));
// 2003-12-02 - HB <
// Cut the entries from the central directory
$aE = explode("\x50\x4b\x01\x02", $vZ);
// Explode to each part
$aE = explode("\x50\x4b\x03\x04", $aE[0]);
// Shift out spanning signature or empty entry
array_shift($aE);
// Loop through the entries
foreach($aE as $vZ) {
$aI = array();
$aI['E'] = 0;
$aI['EM'] = '';
// Retrieving local file header information
$aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
// Check if data is encrypted
$bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE;
$nF = $aP['FNL'];
// Special case : value block after the compressed data
if($aP['GPF'] & 0x0008) {
$aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
$aP['CRC'] = $aP1['CRC'];
$aP['CS'] = $aP1['CS'];
$aP['UCS'] = $aP1['UCS'];
$vZ = substr($vZ, 0, -12);
}
// Getting stored filename
$aI['N'] = substr($vZ, 26, $nF);
if(substr($aI['N'], -1) == '/') {
// is a directory entry - will be skipped
continue;
}
// Truncate full filename in path and filename
$aI['P'] = dirname($aI['N']);
$aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
$aI['N'] = basename($aI['N']);
$vZ = substr($vZ, 26 + $nF);
if(strlen($vZ) != $aP['CS']) {
$aI['E'] = 1;
$aI['EM'] = 'Compressed size is not equal with the value in header information.';
} else {
if($bE) {
$aI['E'] = 5;
$aI['EM'] = 'File is encrypted, which is not supported from this class.';
} else {
switch($aP['CM']) {
case 0: // Stored
// Here is nothing to do, the file ist flat.
break;
case 8: // Deflated
$vZ = gzinflate($vZ);
break;
case 12: // BZIP2
// 2003-12-02 - HB >
if(! extension_loaded('bz2')) {
if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
@dl('php_bz2.dll');
} else {
@dl('bz2.so');
}
}
if(extension_loaded('bz2')) {
// 2003-12-02 - HB <
$vZ = bzdecompress($vZ);
// 2003-12-02 - HB >
} else {
$aI['E'] = 7;
$aI['EM'] = "PHP BZIP2 extension not available.";
}
// 2003-12-02 - HB <
break;
default:
$aI['E'] = 6;
$aI['EM'] = "De-/Compression method {$aP['CM']} is not supported.";
}
// 2003-12-02 - HB >
if(! $aI['E']) {
// 2003-12-02 - HB <
if($vZ === FALSE) {
$aI['E'] = 2;
$aI['EM'] = 'Decompression of data failed.';
} else {
if(strlen($vZ) != $aP['UCS']) {
$aI['E'] = 3;
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
} else {
if(crc32($vZ) != $aP['CRC']) {
$aI['E'] = 4;
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
}
}
}
// 2003-12-02 - HB >
}
// 2003-12-02 - HB <
}
}
$aI['D'] = $vZ;
// DOS to UNIX timestamp
$aI['T'] = mktime(($aP['FT'] & 0xf800) >> 11,
($aP['FT'] & 0x07e0) >> 5,
($aP['FT'] & 0x001f) << 1,
($aP['FD'] & 0x01e0) >> 5,
($aP['FD'] & 0x001f),
(($aP['FD'] & 0xfe00) >> 9) + 1980);
$this->Entries[] = &new SimpleUnzipEntry($aI);
} // end for each entries
return $this->Entries;
} // end of the 'ReadFile()' method
} // end of the 'SimpleUnzip' class
class SimpleUnzipEntry {
var $Data = '';
var $Error = 0;
var $ErrorMsg = '';
var $Name = '';
var $Path = '';
var $Time = 0;
function SimpleUnzipEntry($in_Entry) {
$this->Data = $in_Entry['D'];
$this->Error = $in_Entry['E'];
$this->ErrorMsg = $in_Entry['EM'];
$this->Name = $in_Entry['N'];
$this->Path = $in_Entry['P'];
$this->Time = $in_Entry['T'];
} // end of the 'SimpleUnzipEntry' constructor
} // end of the 'SimpleUnzipEntry' class
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/zip.func.php
|
PHP
|
asf20
| 13,678
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: templates.inc.php 17432 2008-12-20 13:28:29Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$operation = empty($operation) ? 'admin' : $operation;
if($operation == 'admin') {
if(!submitcheck('tplsubmit')) {
$templates = '';
$query = $db->query("SELECT * FROM {$tablepre}templates");
while($tpl = $db->fetch_array($query)) {
$templates .= showtablerow('', array('class="td25"', '', 'class="td29"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" ".($tpl[templateid] == 1 ? 'disabled ' : '')."value=\"$tpl[templateid]\">",
"<input type=\"text\" class=\"txt\" size=\"8\" name=\"namenew[$tpl[templateid]]\" value=\"$tpl[name]\">",
"<input type=\"text\" class=\"txt\" size=\"20\" name=\"directorynew[$tpl[templateid]]\" value=\"$tpl[directory]\">",
!empty($tpl['copyright']) ? $tpl['copyright'] : "<input type=\"text\" class=\"txt\" size=\"8\" name=\"copyrightnew[$tpl[templateid]]\" value=>",
"<a href=\"$BASESCRIPT?action=templates&operation=maint&id=$tpl[templateid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
shownav('style', 'templates_admin');
showsubmenu('templates_admin');
showformheader('templates');
showtableheader();
showsubtitle(array('', 'templates_admin_name', 'dir', 'copyright', ''));
echo $templates;
echo '<tr><td>'.$lang['add_new'].'</td><td><input type="text" class="txt" size="8" name="newname"></td><td class="td29"><input type="text" class="txt" size="20" name="newdirectory"></td><td><input type="text" class="txt" size="25" name="newcopyright"></td><td> </td></tr>';
showsubmit('tplsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($newname) {
if(!$newdirectory) {
cpmsg('tpl_new_directory_invalid', '', 'error');
} elseif(!istpldir($newdirectory)) {
$directory = $newdirectory;
cpmsg('tpl_directory_invalid', '', 'error');
}
$db->query("INSERT INTO {$tablepre}templates (name, directory, copyright)
VALUES ('$newname', '$newdirectory', '$newcopyright')", 'UNBUFFERED');
}
foreach($directorynew as $id => $directory) {
if(!$delete || ($delete && !in_array($id, $delete))) {
if(!istpldir($directory)) {
cpmsg('tpl_directory_invalid', '', 'error');
} elseif($id == 1 && $directory != './templates/default') {
cpmsg('tpl_default_directory_invalid', '', 'error');
}
$db->query("UPDATE {$tablepre}templates SET name='$namenew[$id]', directory='$directorynew[$id]' WHERE templateid='$id'", 'UNBUFFERED');
if(!empty($copyrightnew[$id])) {
$db->query("UPDATE {$tablepre}templates SET copyright='$copyrightnew[$id]' WHERE templateid='$id' AND copyright=''", 'UNBUFFERED');
}
}
}
if(is_array($delete)) {
if(in_array('1', $delete)) {
cpmsg('tpl_delete_invalid', '', 'error');
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}templates WHERE templateid IN ($ids) AND templateid<>'1'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}styles SET templateid='1' WHERE templateid IN ($ids)", 'UNBUFFERED');
}
}
updatecache('styles');
cpmsg('tpl_update_succeed', $BASESCRIPT.'?action=templates', 'succeed');
}
} elseif($operation == 'maint') {
if(empty($id)) {
$tplselect = "<select name=\"id\" style=\"width: 150px\">\n";
$query = $db->query("SELECT templateid, name FROM {$tablepre}templates");
while($tpl = $db->fetch_array($query)) {
$tplselect .= "<option value=\"$tpl[templateid]\">$tpl[name]</option>\n";
}
$tplselect .= '</select>';
cpmsg('templates_edit_select', $BASESCRIPT.'?action=templates&operation=maint'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $tplselect);
}
$template = $db->fetch_first("SELECT * FROM {$tablepre}templates WHERE templateid='$id'");
if(!$template) {
cpmsg('undefined_action', '', 'error');
} elseif(!istpldir($template['directory'])) {
$directory = $template['directory'];
cpmsg('tpl_directory_invalid', '', 'error');
}
$warning = $template['templateid'] == 1 ? 'templates_maint_default_comment' : 'templates_maint_nondefault_comment';
if($keyword) {
$keywordadd = " - $lang[templates_maint_keyword] <i>".dhtmlspecialchars(stripslashes($keyword))."</i> - <a href=\"$BASESCRIPT?action=templates&operation=maint&id=$id\">[$lang[templates_maint_view_all]]</a>";
$keywordenc = rawurlencode($keyword);
}
$tpldir = dir(DISCUZ_ROOT.'./'.$template['directory']);
$tplarray = $langarray = $differ = $new = array();
while($entry = $tpldir->read()) {
$extension = strtolower(fileext($entry));
if($extension == 'htm' || $extension == 'php') {
if($extension == 'htm') {
$tplname = substr($entry, 0, -4);
$pos = strpos($tplname, '_');
if($keyword) {
if(!stristr(implode("\n", file(DISCUZ_ROOT."./$template[directory]/$entry")), $keyword)) {
continue;
}
}
if(!$pos) {
$tplarray[$tplname][] = $tplname;
} else {
$tplarray[substr($tplname, 0, $pos)][] = $tplname;
}
} else {
$langarray[] = substr($entry, 0, -9);
}
if($template['templateid'] != 1) {
if(file_exists(DISCUZ_ROOT."./templates/default/$entry")) {
if(md5_file(DISCUZ_ROOT."./templates/default/$entry") != md5_file(DISCUZ_ROOT."./$template[directory]/$entry")) {
$differ[] = $entry;
}
} else {
$new[] = $entry;
}
}
}
}
$tpldir->close();
ksort($tplarray);
ksort($langarray);
$templates = $languages = '';
$allowedittpls = checkpermission('tpledit', 0);
foreach($tplarray as $tpl => $subtpls) {
$templates .= "<li><h5>$tpl</h5><ul class=\"tpllist3\">";
foreach($subtpls as $subtpl) {
$filename = "$subtpl.htm";
$resetlink = '';
if(in_array($filename, $differ)) {
$subtpl = '<font color=\'#FF0000\'>'.$subtpl.'</font>';
$resetlink = " <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&reset=yes\" class=\"act\">$lang[templates_maint_reset]</a>";
}
if(in_array($filename, $new)) {
$subtpl = '<font color=\'#00FF00\'>'.$subtpl.'</font>';
}
$templates .= '<li>';
if($allowedittpls) {
$templates .= "$subtpl <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&keyword=$keywordenc\" class=\"act\">$lang[edit]</a> ".
"<a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&delete=yes\" class=\"act\">$lang[delete]</a>$resetlink";
} else {
$templates .= "$subtpl <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$filename&keyword=$keywordenc\" class=\"act\">$lang[view]</a> ";
}
$templates .= '</li>';
}
$templates .= "</ul></li>";
}
$languages .= '<ul class="tpllist3">';
foreach($langarray as $langpack) {
$resetlink = '';
$langpackname = $langpack;
if(is_array($differ) && in_array($langpack.'.lang.php', $differ)) {
$langpackname = '<font color=\'#FF0000\'>'.$langpackname.'</font>';
$resetlink = " <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php&reset=yes\" class=\"act\">$lang[templates_maint_reset]</a>";
}
$languages .= '<li>';
if($allowedittpls) {
$languages .= "$langpackname <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php\" class=\"act\">$lang[edit]</a>";
$languages .= $template['templateid'] != 1 ? " <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php&delete=yes\" class=\"act\">$lang[delete]</a>" : '';
$languages .= "$resetlink";
} else {
$languages .= "$langpackname <a href=\"$BASESCRIPT?action=templates&operation=edit&templateid=$template[templateid]&fn=$langpack.lang.php\" class=\"act\">$lang[view]</a>";
}
$languages .= '</li>';
}
$languages .= '</ul>';
shownav('style', 'templates_maint');
showsubmenu(lang('templates_maint').' - '.$template['name']);
showtips($warning);
showtableheader('', 'nobottom fixpadding');
showformheader("templates&operation=add&id=$id");
showtablerow('', array('class="td21"', 'class="td22"'), array(
lang('templates_maint_new'),
'<input type="text" class="txt" name="name" size="40" maxlength="40">',
'<input type="submit" class="btn" value="'.lang('submit').'">'
));
showformfooter();
showformheader("templates&operation=maint&id=$id");
showtablerow('', array('class="td21"', 'class="td22"'), array(
lang('templates_maint_search'),
'<input type="text" class="txt" name="keyword" size="40">',
'<input type="submit" class="btn" value="'.lang('submit').'">'
));
showformfooter();
showtablefooter();
showtableheader(lang('templates_maint_select').$keywordadd, 'notop fixpadding');
?>
<tr><td style="background:none;">
<ul class="tpllist">
<li>
<h4>Discuz! <?=$lang['templates_maint_language_pack']?></h4>
<ul class="tpllist2">
<?=$languages?>
</ul>
</li>
<li>
<h4>Discuz! <?=$lang['templates_maint_html']?></h4>
<ul class="tpllist2">
<?=$templates?>
</ul>
</li>
</ul>
</td></tr>
<?
showtablefooter();
} elseif($operation == 'copy') {
checkpermission('tpledit');
$srctemplate = $db->fetch_first("SELECT directory FROM {$tablepre}templates WHERE templateid='$templateid'");
if(!$srctemplate) {
cpmsg('tpl_edit_nonexistence', '', 'error');
}
$desctemplate = $db->fetch_first("SELECT directory FROM {$tablepre}templates WHERE templateid='$copyto'");
if(!$desctemplate) {
cpmsg('tpl_edit_nonexistence', '', 'error');
}
if(!file_exists(DISCUZ_ROOT.$desctemplate['directory'])) {
$directory = $desctemplate['directory'];
cpmsg('tpl_directory_invalid', '', 'error');
}
$newfilename = DISCUZ_ROOT.$desctemplate['directory']."/$fn";
if(file_exists($newfilename) && !$confirmed) {
cpmsg('tpl_desctpl_exists', "$BASESCRIPT?action=templates&operation=copy&templateid=$templateid&fn=$fn©to=$copyto", 'form');
}
if(!copy(DISCUZ_ROOT."./$srctemplate[directory]/$fn", $newfilename)) {
cpmsg('tpl_tplcopy_invalid', '', 'error');
}
cpmsg('tpl_tplcopy_succeed', "$BASESCRIPT?action=templates&operation=edit&templateid=$templateid&fn=$fn", 'succeed');
} elseif($operation == 'edit') {
$allowedittpls = checkpermission('tpledit', 0);
$template = $db->fetch_first("SELECT * FROM {$tablepre}templates WHERE templateid='$templateid'");
if(!$template) {
cpmsg('tpl_edit_nonexistence', '', 'error');
}
$directorys = '';
$query = $db->query("SELECT templateid, directory FROM {$tablepre}templates WHERE templateid!='$templateid' GROUP BY directory");
while($directory = $db->fetch_array($query)) {
$directorys .='<option value="'.$directory['templateid'].'">'.$directory['directory'].'</option>';
}
$fn = str_replace(array('..', '/', '\\'), array('', '', ''), $fn);
$filename = DISCUZ_ROOT."./$template[directory]/$fn";
if(!is_writeable($filename)) {
cpmsg('tpl_edit_invalid', '', 'error');
}
$keywordenc = rawurlencode($keyword);
if(!submitcheck('editsubmit') && $delete != 'yes' && $reset != 'yes') {
$islang = FALSE;
if(preg_match('/\.lang\.php$/i', $filename)) {
$currentlang = $lang;
$currentmsglang = $msglang;
unset($lang, $msglang);
include $filename;
$islang = TRUE;
$langinputs = '';
isset($actioncode) && $langinputs .= langedit('actioncode');
isset($language) && $langinputs .= langedit('language');
isset($lang) && $langinputs .= langedit('lang');
isset($msglang) && $langinputs .= langedit('msglang');
isset($spacelanguage) && $langinputs .= langedit('spacelanguage');
$lang = $currentlang;
$msglang = $currentmsglang;
} else {
$fp = @fopen($filename, 'rb');
$content = @fread($fp, filesize($filename));
fclose($fp);
}
$resetbutton = $onclickevent = $checkresult = '';
if($template['templateid'] != 1) {
$defaulttpl = DISCUZ_ROOT."./templates/default/$fn";
if(file_exists($defaulttpl) && md5_file($defaulttpl) != md5_file($filename)) {
$resetbutton = ' <input style="vertical-align: middle" type="button" class="btn" value="'.$lang['templates_edit_reset'].'" accesskey="r" onclick="location.href=\''.$BASESCRIPT.'?action=templates&operation=edit&templateid='.$template['templateid'].'&fn='.$fn.'&keyword='.$keywordenc.'&reset=yes\'"> '.
(strtolower(fileext($fn)) == 'htm' ? '<input style="vertical-align: middle" type="button" class="btn" value="'.$lang['templates_edit_diff'].'" onclick="location.href=\''.$BASESCRIPT.'?action=templates&operation=edit&templateid='.$template['templateid'].'&fn='.$fn.'&keyword='.$keywordenc.'&checktpl=yes\'"> ' : '');
}
$dellist = $addlist = array();
if($checktpl && strtolower(fileext($fn)) == 'htm') {
$fp = @fopen($defaulttpl, 'rb');
$defaultcontent = @fread($fp, filesize($defaulttpl));
fclose($fp);
require_once DISCUZ_ROOT.'./include/diff.class.php';
$a = new Diff($content, $defaultcontent);
$entries = $a->fetch_diff();
$result = '<br /><table class="tb tb2 nobdb" width="100%" border="0" cellpadding="0" cellspacing="0"><tr class="partition"><td>'.$lang['templates_edit_diff_current'].'</td><td> </td><td>'.$lang['templates_edit_diff_default'].'</td></tr>';
foreach ($entries as $diff_entry) {
$result .= '<tr><th width="49.5%" valign="top" class="diff-'.$diff_entry->left_class().'">'.
$diff_entry->diff_text($diff_entry->left).'</th><th width="1%"> </th>'.
'<th width="49.5%" valign="top" class="diff-'.$diff_entry->right_class().'">'.
$diff_entry->diff_text($diff_entry->right)."</th></tr>";
}
$result .= '</table><br /><table class="tb tb2 nobdb" width="100%" border="0" cellpadding="4" cellspacing="0">'.
'<tr><th class="diff-deleted" style="text-align: center">'.$lang['templates_edit_diff_deleted'].'</th><th class="diff-notext"> </th></tr>'.
'<tr><th class="diff-changed" style="text-align: center" colspan="2">'.$lang['templates_edit_diff_changed'].' </th></tr>'.
'<tr><th class="diff-notext"> </th><th class="diff-added" style="text-align: center">'.$lang['templates_edit_diff_added'].'</th></tr></table>';
$checkresult = $result;
}
} else {
$onclickevent = 'onclick="return confirm(\''.$lang['templates_edit_default_overwriteconfirm'].'\')"';
}
$content = dhtmlspecialchars($content);
$filemtime = date("$dateformat $timeformat", filemtime($filename));
?>
<script language="JavaScript">
var n = 0;
function displayHTML(obj) {
win = window.open(" ", 'popup', 'toolbar = no, status = no, scrollbars=yes');
win.document.write("" + obj.value + "");
}
function HighlightAll(obj) {
obj.focus();
obj.select();
if(document.all) {
obj.createTextRange().execCommand("Copy");
window.status = "<?=$lang['templates_edit_clickboard']?>";
setTimeout("window.status=''", 1800);
}
}
function findInPage(obj, str, noalert) {
var txt, i, found;
if(str == "") {
return false;
}
if(document.layers) {
if(!obj.find(str)) {
while(obj.find(str, false, true)) {
n++;
}
} else {
n++;
}
if(n == 0 && !noalert) {
alert("<?=$lang['templates_edit_keyword_not_found']?>");
}
}
if(document.all) {
txt = obj.createTextRange();
for(i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart('character', 1);
txt.moveEnd('textedit');
}
if(found) {
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
return true;
} else {
if(n > 0) {
n = 0;
findInPage(obj, str, noalert);
} else if(!noalert) {
alert("<?=$lang['templates_edit_keyword_not_found']?>");
}
}
}
return false;
}
<?
if($islang) {
?>
var ni = 0;
var niprev = 0;
function MultifindInPage(obj, str) {
for(var i = ni; i < obj.elements.length; i++) {
if(obj.elements[i].type == 'textarea') {
if(findInPage(obj.elements[i], str, 1)) {
ni = i;
break;
}
}
if(i == obj.elements.length - 1) ni = 0;
}
}
<?
}
?>
</script>
<?
shownav('style', 'templates_edit');
showsubmenu("$lang[templates_edit] - $template[name] $fn - $lang[lastmodified]: $filemtime");
showformheader("templates&operation=edit&templateid=$templateid&fn=$fn");
showhiddenfields(array('keyword' => $keywordenc));
?>
<div class="colorbox">
<?
if($islang) {
?>
<div style="margin-bottom:10px;width:99%;height:390px;overflow-y:scroll;overflow-x:hidden;">
<table class="tb tb2" style="border:none">
<tr><td><b><?=$lang['templates_edit_variable']?></b></td><td><b><?=$lang['templates_edit_value']?></b></td></tr>
<?=$langinputs?>
</table>
</div>
<?
} else {
?>
<textarea cols="100" rows="25" name="templatenew" style="margin-bottom:10px;width:99%;height:390px;"><?=$content?></textarea>
<?
}
?>
<input name="search" type="text" class="txt" style="width:150px;" accesskey="t" size="20" onChange="n=0;">
<?
if($islang) {
?>
<input type="button" class="btn" value="<?=$lang['search']?>" accesskey="f" onClick="MultifindInPage(this.form, this.form.search.value)">
<?
} else {
?>
<input type="button" class="btn" value="<?=$lang['search']?>" accesskey="f" onClick="findInPage(this.form.templatenew, this.form.search.value)">
<?
}
?>
<input type="button" class="btn" value="<?=$lang['return']?>" accesskey="e" onClick="location.href='<?=$BASESCRIPT?>?action=templates&operation=maint&id=<?=$templateid?>&keyword=<?=$keywordenc?>'">
<input type="button" class="btn" value="<?=$lang['preview']?>" accesskey="p" onClick="displayHTML(this.form.templatenew)">
<input type="button" class="btn" value="<?=$lang['copy']?>" accesskey="c" onClick="HighlightAll(this.form.templatenew)">
<?
if($allowedittpls) {
echo "<input type=\"submit\" class=\"btn\" name=\"editsubmit\" value=\"$lang[submit]\" $onclickevent><br />";
if($directorys) {
echo $lang['templates_edit_copyto_otherdirs']."<select id=\"copyto\">".
"$directorys</select> <input style=\"vertical-align: middle\" type=\"button\" class=\"btn\" value=\"$lang[templates_edit_start_copy]\" ".
"accesskey=\"r\" onclick=\"if(\$('copyto').value == 1 && confirm('$lang[templates_edit_default_overwriteconfirm]') || \$('copyto').value != 1) location.href='$BASESCRIPT?action=templates&operation=copy&templateid={$template['templateid']}&fn={$fn}©to='+\$('copyto').value\">";
}
echo $resetbutton;
}
echo '</div></form>'.$checkresult;
} elseif($delete == 'yes') {
checkpermission('tpledit');
if(!$confirmed) {
cpmsg('tpl_delete_confirm', "$BASESCRIPT?action=templates&operation=edit&templateid=$templateid&fn=$fn&delete=yes", 'form');
} else {
if(@unlink($filename)) {
cpmsg('tpl_delete_succeed', "$BASESCRIPT?action=templates&operation=maint&id=$templateid", 'succeed');
} else {
cpmsg('tpl_delete_fail', '', 'error');
}
}
} elseif($reset == 'yes') {
checkpermission('tpledit');
if(!$confirmed) {
cpmsg('tpl_reset_confirm', "$BASESCRIPT?action=templates&operation=edit&templateid=$templateid&fn=$fn&keyword=$keywordenc&reset=yes", 'form');
} else {
$defaultfilename = DISCUZ_ROOT.'./templates/default/'.$fn;
$filename = DISCUZ_ROOT."./$template[directory]/$fn";
if(!copy($defaultfilename, $filename)) {
cpmsg('tpl_edit_invalid', '', 'error');
}
cpmsg('tpl_reset_succeed', "$BASESCRIPT?action=templates&operation=maint&id=$templateid&keyword=$keywordenc", 'succeed');
}
} else {
checkpermission('tpledit');
if(preg_match('/\.lang\.php$/i', $filename)) {
$templatenew = '';
foreach($langnew as $key => $value) {
$templatenew .= '$'.$key." = array\n(\n";
foreach($value as $key1 => $value1) {
if(substr($value1, strlen($value1) -1 , 1) == '\\') {
$value1 .= '\\\\';
}
$templatenew .= "\t'$key1' => '".str_replace('\\\\\'', '\\\'', addcslashes(stripslashes(str_replace("\x0d\x0a", "\x0a", $value1)), "'"))."',\n";
}
$templatenew .= ");\n";
}
$templatenew = "<?php\n\n// Language Pack for Discuz! Version 1.0.0\n\n$templatenew\n?>";
} else {
$templatenew = stripslashes(str_replace("\x0d\x0a", "\x0a", $templatenew));
}
$fp = fopen($filename, 'wb');
flock($fp, 2);
fwrite($fp, $templatenew);
fclose($fp);
if(substr(basename($filename), 0, 3) == 'css') {
updatecache('styles');
}
cpmsg('tpl_edit_succeed', "$BASESCRIPT?action=templates&operation=maint&id=$templateid&keyword=$keywordenc", 'succeed');
}
} elseif($operation == 'add') {
checkpermission('tpledit');
$template = $db->fetch_first("SELECT * FROM {$tablepre}templates WHERE templateid='$id'");
if(!$template) {
cpmsg('tpl_add_invalid', '', 'error');
} elseif(!istpldir($template['directory'])) {
$directory = $template['directory'];
cpmsg('tpl_directory_invalid', '', 'error');
} elseif(file_exists(DISCUZ_ROOT."./$template[directory]/$name.htm")) {
cpmsg('tpl_add_duplicate', '', 'error');
} elseif(!@$fp = fopen(DISCUZ_ROOT."./$template[directory]/$name.htm", 'wb')) {
cpmsg('tpl_add_file_invalid', '', 'error');
}
@fclose($fp);
cpmsg('tpl_add_succeed', "$BASESCRIPT?action=templates&operation=edit&templateid=1&fn=$name.htm", 'succeed');
}
function langedit($var) {
global $$var, $currentlang;
$return = '';
foreach($$var as $key => $value) {
$return .= '<tr><td width="100" style="border:0">'.$key.'</td><td style="border:0"><textarea cols="100" rows="3" name="langnew['.$var.']['.$key.']" style="width: 95%;">'.dhtmlspecialchars($value).'</textarea></td></tr>';
}
return $return;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/templates.inc.php
|
PHP
|
asf20
| 22,297
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: login.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if($inajax) {
ajaxshowheader();
ajaxshowfooter();
exit;
}
echo <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Discuz! Administrator's Control Panel</title>
<meta http-equiv="Content-Type" content="text/html;charset=$charset" />
<link rel="stylesheet" href="images/admincp/admincp.css" type="text/css" media="all" />
<meta content="Comsenz Inc." name="Copyright" />
</head>
<body>
<script language="JavaScript">
if(self.parent.frames.length != 0) {
self.parent.location=document.location;
}
</script>
<table class="logintb">
<tr>
<td class="login">
<h1>Discuz! Administrator's Control Panel</h1>
<p>$lang[login_tips]</p>
</td>
<td>
EOT;
if($cpaccess == 0 || (!$discuz_secques && $admincp['forcesecques'])) {
echo '<p class="logintips">'.$lang[$cpaccess == 0 ? 'noaccess' : 'login_nosecques'].'</p>';
} elseif($cpaccess == 1) {
$extra = '?'.(isset($action) && empty($frames) ? 'frames=yes&' : '').$_SERVER['QUERY_STRING'];
echo <<<EOT
<form method="post" name="login" id="loginform" action="$BASESCRIPT$extra">
<input type="hidden" name="sid" value="$sid">
<input type="hidden" name="frames" value="yes">
<p class="logintitle">$lang[username]: </p>
<p class="loginform">$discuz_userss</p>
<p class="logintitle">$lang[password]:</p>
<p class="loginform"><input name="admin_password" tabindex="1" type="password" class="txt" /></p>
<p class="logintitle">$lang[security_question]:</p>
<p class="loginform">
<select id="questionid" name="admin_questionid" tabindex="2">
<option value="0">$lang[security_question_0]</option>
<option value="1">$lang[security_question_1]</option>
<option value="2">$lang[security_question_2]</option>
<option value="3">$lang[security_question_3]</option>
<option value="4">$lang[security_question_4]</option>
<option value="5">$lang[security_question_5]</option>
<option value="6">$lang[security_question_6]</option>
<option value="7">$lang[security_question_7]</option>
</select>
</p>
<p class="logintitle">$lang[security_answer]:</p>
<p class="loginform"><input name="admin_answer" tabindex="3" type="text" class="txt" /></p>
<p class="loginnofloat"><input name="submit" value="$lang[submit]" tabindex="3" type="submit" class="btn" /></p>
</form>
<script type="text/JavaScript">document.getElementById('loginform').admin_password.focus();</script>
EOT;
}
echo <<<EOT
</td>
</tr>
<tr>
<td colspan="2" class="footer">
<div class="copyright">
<p>Powered by <a href="http://www.discuz.net/" target="_blank">Discuz!</a> $version </p>
<p>© 2001-2009, <a href="http://www.comsenz.com/" target="_blank">Comsenz</a> Inc.</p>
</div>
</td>
</tr>
</table>
</body>
</html>
EOT;
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/login.inc.php
|
PHP
|
asf20
| 3,202
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: adv.inc.php 17011 2008-12-02 09:25:44Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
cpheader();
if(empty($operation)) {
if(!submitcheck('advsubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
shownav('adv', 'adv_admin');
showsubmenu('adv_admin', array(
array('config', 'adv&operation=config', 0),
array('admin', 'adv', 1),
array(array('menu' => 'add', 'submenu' => array(
array('adv_type_headerbanner', 'adv&operation=advadd&type=headerbanner'),
array('adv_type_footerbanner', 'adv&operation=advadd&type=footerbanner'),
array('adv_type_text', 'adv&operation=advadd&type=text'),
array('adv_type_thread', 'adv&operation=advadd&type=thread'),
array('adv_type_interthread', 'adv&operation=advadd&type=interthread'),
array('adv_type_float', 'adv&operation=advadd&type=float'),
array('adv_type_couplebanner', 'adv&operation=advadd&type=couplebanner'),
array('adv_type_intercat', 'adv&operation=advadd&type=intercat'),
)), '', 0)
));
showformheader('adv');
showtableheader();
showsubtitle(array('', 'display_order', 'available', 'subject', 'type', 'adv_style', 'start_time', 'end_time', 'adv_targets', ''));
$advppp = 25;
$conditions = '';
$order_by = 'displayorder, advid DESC, targets DESC';
$page = max(1, intval($page));
$start_limit = ($page - 1) * $advppp;
$conditions .= $title ? " AND title LIKE '%$title%'" : '';
$conditions .= $type ? " AND type='$type'" : '';
$conditions .= $starttime ? " AND starttime>='".($timestamp - $starttime)."'" : '';
$order_by = $orderby == 'starttime' ? 'starttime' : ($orderby == 'type' ? 'type' : ($orderby == 'displayorder' ? 'displayorder' : 'advid DESC'));
$advnum = $db->result_first("SELECT COUNT(*) FROM {$tablepre}advertisements WHERE 1 $conditions");
$query = $db->query("SELECT * FROM {$tablepre}advertisements WHERE 1 $conditions ORDER BY available DESC, $order_by LIMIT $start_limit, $advppp");
while($adv = $db->fetch_array($query)) {
$adv['type'] = $lang['adv_type_'.$adv['type']];
$adv['targets'] = showtargets($adv);
$adv['parameters'] = unserialize($adv['parameters']);
showtablerow('', array('class="td25"', 'class="td28"', 'class="td25"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$adv[advid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$adv[advid]]\" value=\"$adv[displayorder]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$adv[advid]]\" value=\"1\" ".($adv['available'] ? 'checked' : '').">",
"<input type=\"text\" class=\"txt\" size=\"15\" name=\"titlenew[$adv[advid]]\" value=\"".dhtmlspecialchars($adv['title'])."\">",
$adv[type],
$lang['adv_style_'.$adv['parameters']['style']],
$adv['starttime'] ? gmdate($dateformat, $adv['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'],
$adv['endtime'] ? gmdate($dateformat, $adv['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : $lang['unlimited'],
$adv[targets],
"<a href=\"$BASESCRIPT?action=adv&operation=advedit&advid=$adv[advid]\" class=\"act\">$lang[detail]</a>"
));
}
$multipage = multi($advnum, $advppp, $page, $BASESCRIPT.'?action=adv'.($title ? "&title=$title" : '').($type ? "&type=$type" : '').($starttime ? "&starttime=$starttime" : '').($orderby ? "&orderby=$orderby" : ''), 0, 3, TRUE, TRUE);
$starttimecheck = array($starttime => 'selected="selected"');
$typecheck = array($type => 'selected="selected"');
$orderbycheck = array($orderby => 'selected="selected"');
$title = isset($title) ? $title : $lang['adv_inputtitle'];
showsubmit('advsubmit', 'submit', 'del', '', $multipage.'
<input type="text" class="txt" name="title" value="'.$title.'" size="15" onclick="this.value=\'\'">
<select name="starttime">
<option value=""> '.lang('start_time').'</option>
<option value="0" '.$starttimecheck['0'].'> '.lang('all').'</option>
<option value="86400" '.$starttimecheck['86400'].'> '.lang('1_day').'</option>
<option value="604800" '.$starttimecheck['604800'].'> '.lang('7_day').'</option>
<option value="2592000" '.$starttimecheck['2592000'].'> '.lang('30_day').'</option>
<option value="7776000" '.$starttimecheck['7776000'].'> '.lang('90_day').'</option>
<option value="15552000" '.$starttimecheck['15552000'].'> '.lang('180_day').'</option>
<option value="31536000" '.$starttimecheck['31536000'].'> '.lang('365_day').'</option>
</select>
<select name="type">
<option value=""> '.lang('adv_type').'</option>
<option value="0" '.$typecheck['0'].'> '.lang('all').'</option>
<option value="headerbanner" '.$typecheck['headerbanner'].'> '.lang('adv_type_headerbanner').'
</option><option value="footerbanner" '.$typecheck['footerbanner'].'> '.lang('adv_type_footerbanner').'</option>
<option value="text" '.$typecheck['text'].'> '.lang('adv_type_text').'</option>
<option value="thread" '.$typecheck['thread'].'> '.lang('adv_type_thread').'</option>
<option value="interthread" '.$typecheck['interthread'].'> '.lang('adv_type_interthread').'</option>
<option value="float" '.$typecheck['float'].'> '.lang('adv_type_float').'</option>
<option value="couplebanner" '.$typecheck['couplebanner'].'> '.lang('adv_type_couplebanner').'</option>
<option value="intercat" '.$typecheck['intercat'].'> '.lang('adv_type_intercat').'</option>
</select>
<select name="orderby">
<option value=""> '.lang('adv_orderby').'</option>
<option value="starttime" '.$orderbycheck['starttime'].'> '.lang('adv_addtime').'</option>
<option value="type" '.$orderbycheck['type'].'> '.lang('adv_type').'</option>
<option value="displayorder" '.$orderbycheck['displayorder'].'> '.lang('display_order').'</option>
</select>
<input type="submit" class="btn" name="searchsubmit" value="'.lang('search').'" onclick="if(this.form.title.value==\''.lang('adv_inputtitle').'\'){this.form.title.value=\'\'}window.loacation=\''.$BASESCRIPT.'?action=adv&title=\'+this.form.title.value+\'&starttime=\'+this.form.starttime.value+\'&type=\'+this.form.type.value+\'&orderby=\'+this.form.orderby.value;">
');
showtablefooter();
showformfooter();
} else {
if($advids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}advertisements WHERE advid IN ($advids)");
}
if(is_array($titlenew)) {
foreach($titlenew as $advid => $title) {
$db->query("UPDATE {$tablepre}advertisements SET available='$availablenew[$advid]', displayorder='$displayordernew[$advid]', title='".cutstr($titlenew[$advid], 50)."' WHERE advid='$advid'", 'UNBUFFERED');
}
}
updatecache(array('settings', 'advs_archiver', 'advs_register', 'advs_index', 'advs_forumdisplay', 'advs_viewthread'));
cpmsg('adv_update_succeed', $BASESCRIPT.'?action=adv', 'succeed');
}
} elseif($operation == 'advadd' && in_array($type, array('headerbanner', 'footerbanner', 'text', 'thread', 'interthread', 'float', 'couplebanner', 'intercat')) || ($operation == 'advedit' && $advid)) {
if(!submitcheck('advsubmit')) {
require_once DISCUZ_ROOT.'./include/forum.func.php';
shownav('adv', 'adv_admin');
showsubmenu('adv_admin', array(
array('config', 'adv&operation=config', 0),
array('admin', 'adv', 0),
array(array('menu' => 'add', 'submenu' => array(
array('adv_type_headerbanner', 'adv&operation=advadd&type=headerbanner'),
array('adv_type_footerbanner', 'adv&operation=advadd&type=footerbanner'),
array('adv_type_text', 'adv&operation=advadd&type=text'),
array('adv_type_thread', 'adv&operation=advadd&type=thread'),
array('adv_type_interthread', 'adv&operation=advadd&type=interthread'),
array('adv_type_float', 'adv&operation=advadd&type=float'),
array('adv_type_couplebanner', 'adv&operation=advadd&type=couplebanner'),
array('adv_type_intercat', 'adv&operation=advadd&type=intercat'),
)), '', $operation == 'advadd' ? 1 : 0)
));
if($operation == 'advedit') {
$adv = $db->fetch_first("SELECT * FROM {$tablepre}advertisements WHERE advid='$advid'");
if(!$adv) {
cpmsg('undefined_action', '', 'error');
}
$adv['parameters'] = unserialize($adv['parameters']);
if(in_array($adv['type'], array('footerbanner', 'thread'))) {
if($adv['type'] == 'thread') {
$dispchecked = array();
foreach((isset($adv['parameters']['displayorder']) ? explode("\t", $adv['parameters']['displayorder']) : array('0')) as $postcount) {
$dispchecked[$postcount] = ' selected="selected"';
}
}
} elseif($adv['type'] == 'intercat') {
if(is_array($adv['parameters']['position'])) {
$positionchecked = array();
foreach($adv['parameters']['position'] as $position) {
$positionchecked[$position] = ' selected="selected"';
}
} else {
$positionchecked = array(0 => ' selected="selected"');
}
}
$type = $adv['type'];
} else {
$title = cutstr($title, 50);
$style = in_array($style, array('text', 'image', 'flash')) ? $style : 'code';
$adv = array('type' => $type, 'title' => $title, 'parameters' => array('style' => $style), 'starttime' => $timestamp);
$positionchecked = $type == 'intercat' ? array(0 => ' selected="selected"') : array(1 => 'checked');
$dispchecked = array(0 => ' selected="selected"');
}
$adv['targets'] = $adv['targets'] != '' && $adv['targets'] != 'forum' ? explode("\t", $adv['targets']) : array('all');
if($type == 'intercat') {
$targetsselect = '<select name="advnew[targets][]" disabled="disabled"><option value="0"> > '.$lang['home'].'</option></select>';
} else {
$targetsselect = '<select name="advnew[targets][]" size="10" multiple="multiple"><option value="all"> > '.$lang['all'].'</option>'.
'<option value=""> </option>'.
(in_array($type, array('thread', 'interthread')) ? '' : '<option value="0"> > '.$lang['home'].'</option>').
(in_array($type, array('headerbanner', 'footerbanner')) ? '</option><option value="register"> > '.$lang['adv_register'].'</option>'.
'</option><option value="redirect"> > '.$lang['adv_jump'].'</option>'.
'</option><option value="archiver"> > Archiver</option>' : '').
'</option>'.forumselect().'</select>';
foreach($adv['targets'] as $target) {
$targetsselect = preg_replace("/(\<option value=\"$target\")(\>)/", "\\1 selected=\"selected\" \\2", $targetsselect);
}
}
if($type == 'thread') {
$dispselect = '<select name="advnew[displayorder][]" size="10" multiple="multiple"><option value="0"'.$dispchecked[0].'> > '.$lang['all'].'</option><option value="0"> </option>';
for($i = 1; $i <= $ppp; $i ++) {
$dispselect .= '<option value="'.$i.'"'.$dispchecked[$i].'> > #'.$i.'</option>';
}
$dispselect .= '</select>';
} elseif($type == 'intercat') {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_forums.php';
$positionselect = '<select name="advnew[position][]" size="10" multiple="multiple"><option value="0"'.$positionchecked[0].'> > '.$lang['all'].'</option><option value=""> </option>';
foreach($_DCACHE['forums'] as $fid => $forum) {
if($forum['type'] == 'group') {
$positionselect .= '<option value="'.$fid.'"'.$positionchecked[$fid].'>'.$forum['name'].'</option>';
}
}
$positionselect .= '</select>';
}
$adv['starttime'] = $adv['starttime'] ? gmdate('Y-n-j', $adv['starttime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '';
$adv['endtime'] = $adv['endtime'] ? gmdate('Y-n-j', $adv['endtime'] + $_DCACHE['settings']['timeoffset'] * 3600) : '';
$styleselect = array($adv['parameters']['style'] => 'selected');
showtips('adv_type_'.$adv['type'].'_tips');
echo '<script type="text/javascript" src="include/js/calendar.js"></script>';
showformheader("adv&operation=$operation".($operation == 'advadd' ? '&type='.$type : '&advid='.$advid));
if($operation == 'advadd') {
$title = $lang['adv_add'].' - '.$lang['adv_type_'.$type];
} else {
$title = $lang['adv_edit'].' - '.$lang['adv_type_'.$adv['type']].' - '.$adv['title'];
}
showtableheader();
showtitle($title);
showsetting('adv_edit_title', 'advnew[title]', $adv['title'], 'text');
showsetting('adv_edit_targets', '', '', $targetsselect);
if($adv['type'] == 'thread') {
showsetting('adv_edit_position_thread', array('advnew[position]', array(
array(1, $lang['adv_thread_down']),
array(2, $lang['adv_thread_up']),
array(3, $lang['adv_thread_right'])
), TRUE), $adv['parameters']['position'], 'mradio');
showsetting('adv_edit_display_position', '', '', $dispselect);
} elseif($adv['type'] == 'footerbanner') {
showsetting('adv_edit_position_footerbanner', array('advnew[position]', array(
array(1, $lang['adv_up']),
array(2, $lang['adv_middle']),
array(3, $lang['adv_down'])
), TRUE), $adv['parameters']['position'], 'mradio');
} elseif($adv['type'] == 'intercat') {
showsetting('adv_edit_position_intercat', '', '', $positionselect);
} elseif($adv['type'] == 'float') {
showsetting('adv_edit_floath', 'advnew[floath]', ($adv['parameters']['floath'] > 0 ? $adv['parameters']['floath'] : 200), 'text');
}
showsetting('adv_edit_starttime', 'advnew[starttime]', $adv['starttime'], 'calendar');
showsetting('adv_edit_endtime', 'advnew[endtime]', $adv['endtime'], 'calendar');
showsetting('adv_edit_style', '', '', '<select name="advnew[style]" onchange="var styles, key;styles=new Array(\'code\',\'text\',\'image\',\'flash\'); for(key in styles) {var obj=$(\'style_\'+styles[key]); obj.style.display=styles[key]==this.options[this.selectedIndex].value?\'\':\'none\';}"><option value="code" '.$styleselect['code'].'> '.$lang['adv_style_code'].'</option><option value="text" '.$styleselect['text'].'> '.$lang['adv_style_text'].'</option><option value="image" '.$styleselect['image'].'> '.$lang['adv_style_image'].'</option><option value="flash" '.$styleselect['flash'].'> '.$lang['adv_style_flash'].'</option></select>');
showtagheader('tbody', 'style_code', $adv['parameters']['style'] == 'code');
showtitle('adv_edit_style_code');
showsetting('adv_edit_style_code_html', 'advnew[code][html]', in_array($type, array('float', 'couplebanner')) && $adv['parameters']['sourcecode'] ? $adv['parameters']['sourcecode'] : $adv['parameters']['html'], 'textarea');
showtagfooter('tbody');
showtagheader('tbody', 'style_text', $adv['parameters']['style'] == 'text');
showtitle('adv_edit_style_text');
showsetting('adv_edit_style_text_title', 'advnew[text][title]', $adv['parameters']['title'], 'text');
showsetting('adv_edit_style_text_link', 'advnew[text][link]', $adv['parameters']['link'], 'text');
showsetting('adv_edit_style_text_size', 'advnew[text][size]', $adv['parameters']['size'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'style_image', $adv['parameters']['style'] == 'image');
showtitle('adv_edit_style_image');
showsetting('adv_edit_style_image_url', 'advnew[image][url]', $adv['parameters']['url'], 'text');
showsetting('adv_edit_style_image_link', 'advnew[image][link]', $adv['parameters']['link'], 'text');
showsetting('adv_edit_style_image_width', 'advnew[image][width]', $adv['parameters']['width'], 'text');
showsetting('adv_edit_style_image_height', 'advnew[image][height]', $adv['parameters']['height'], 'text');
showsetting('adv_edit_style_image_alt', 'advnew[image][alt]', $adv['parameters']['alt'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'style_flash', $adv['parameters']['style'] == 'flash');
showtitle('adv_edit_style_flash');
showsetting('adv_edit_style_flash_url', 'advnew[flash][url]', $adv['parameters']['url'], 'text');
showsetting('adv_edit_style_flash_width', 'advnew[flash][width]', $adv['parameters']['width'], 'text');
showsetting('adv_edit_style_flash_height', 'advnew[flash][height]', $adv['parameters']['height'], 'text');
showtagfooter('tbody');
showsubmit('advsubmit');
showtablefooter();
showformfooter();
} else {
$advnew['starttime'] = $advnew['starttime'] ? strtotime($advnew['starttime']) : 0;
$advnew['endtime'] = $advnew['endtime'] ? strtotime($advnew['endtime']) : 0;
if(!$advnew['title']) {
cpmsg('adv_title_invalid', '', 'error');
} elseif(strlen($advnew['title']) > 50) {
cpmsg('adv_title_more', '', 'error');
} elseif($advnew['endtime'] && ($advnew['endtime'] <= $timestamp || $advnew['endtime'] <= $advnew['starttime'])) {
cpmsg('adv_endtime_invalid', '', 'error');
} elseif(($advnew['style'] == 'code' && !$advnew['code']['html'])
|| ($advnew['style'] == 'text' && (!$advnew['text']['title'] || !$advnew['text']['link']))
|| ($advnew['style'] == 'image' && (!$advnew['image']['url'] || !$advnew['image']['link']))
|| ($advnew['style'] == 'flash' && (!$advnew['flash']['url'] || !$advnew['flash']['width'] || !$advnew['flash']['height']))) {
cpmsg('adv_parameter_invalid', '', 'error');
}
if($operation == 'advadd') {
$db->query("INSERT INTO {$tablepre}advertisements (available, type)
VALUES ('1', '$type')");
$advid = $db->insert_id();
} else {
$type = $db->result_first("SELECT type FROM {$tablepre}advertisements WHERE advid='$advid'");
}
foreach($advnew[$advnew['style']] as $key => $val) {
$advnew[$advnew['style']][$key] = stripslashes($val);
}
$targetsarray = array();
if(is_array($advnew['targets'])) {
foreach($advnew['targets'] as $target) {
if($target == 'all') {
$targetsarray = in_array($type, array('thread', 'interthread')) ? array('forum') : array();
break;
} elseif(in_array($target, array('register', 'redirect', 'archiver')) || preg_match("/^\d+$/", $target) && ($target == 0 || in_array($_DCACHE['forums'][$target]['type'], array('forum', 'sub')))) {
$targetsarray[] = $target;
}
}
}
$advnew['targets'] = implode("\t", $targetsarray);
$advnew['displayorder'] = isset($advnew['displayorder']) ? implode("\t", $advnew['displayorder']) : '';
switch($advnew['style']) {
case 'code':
$advnew['code'] = $advnew['code']['html'];
break;
case 'text':
$advnew['code'] = '<a href="'.$advnew['text']['link'].'" target="_blank" '.($advnew['text']['size'] ? 'style="font-size: '.$advnew['text']['size'].'"' : '').'>'.$advnew['text']['title'].'</a>';
break;
case 'image':
$advnew['code'] = '<a href="'.$advnew['image']['link'].'" target="_blank"><img src="'.$advnew['image']['url'].'"'.($advnew['image']['height'] ? ' height="'.$advnew['image']['height'].'"' : '').($advnew['image']['width'] ? ' width="'.$advnew['image']['width'].'"' : '').($advnew['image']['alt'] ? ' alt="'.$advnew['image']['alt'].'"' : '').' border="0"></a>';
break;
case 'flash':
$advnew['code'] = '<embed width="'.$advnew['flash']['width'].'" height="'.$advnew['flash']['height'].'" src="'.$advnew['flash']['url'].'" type="application/x-shockwave-flash" wmode="transparent"></embed>';
break;
}
if($type == 'float') {
$sourcecode = $advnew['code'];
$advnew['floath'] = $advnew['floath'] >= 40 && $advnew['floath'] <= 600 ? intval($advnew['floath']) : 200;
$advnew['code'] = str_replace(array("\r\n", "\r", "\n"), '<br />', $advnew['code']);
$advnew['code'] = addslashes($advnew['code'].'<br /><img src="images/common/advclose.gif" onMouseOver="this.style.cursor=\'pointer\'" onClick="closeBanner();">');
$advnew['code'] = 'theFloaters.addItem(\'floatAdv1\',6,\'document.documentElement.clientHeight-'.$advnew['floath'].'\',\'<div style="position: absolute; left: 6px; top: 6px;">'.$advnew['code'].'</div>\');';
} elseif($type == 'couplebanner') {
$sourcecode = $advnew['code'];
$advnew['code'] = str_replace(array("\r\n", "\r", "\n"), '<br />', $advnew['code']);
$advnew['code'] = addslashes($advnew['code'].'<br /><img src="images/common/advclose.gif" onMouseOver="this.style.cursor=\'pointer\'" onClick="closeBanner();">');
$advnew['code'] = 'theFloaters.addItem(\'coupleBannerL\',6,0,\'<div style="position: absolute; left: 6px; top: 6px;">'.$advnew['code'].'</div>\');theFloaters.addItem(\'coupleBannerR\',\'document.body.clientWidth-6\',0,\'<div style="position: absolute; right: 6px; top: 6px;">'.$advnew['code'].'</div>\');';
} elseif($type == 'intercat') {
$advnew['position'] = is_array($advnew['position']) && !in_array('0', $advnew['position']) ? $advnew['position'] : '';
}
$advnew['parameters'] = addslashes(serialize(array_merge(array('style' => $advnew['style']), $advnew['style'] == 'code' ? array() : $advnew[$advnew['style']], array('html' => $advnew['code']), array('position' => $advnew['position']), array('displayorder' => $advnew['displayorder']), ($sourcecode ? array('sourcecode' => $sourcecode) : array()), ($advnew['floath'] ? array('floath' => $advnew['floath']) : array()))));
$advnew['code'] = addslashes($advnew['code']);
$query = $db->query("UPDATE {$tablepre}advertisements SET title='$advnew[title]', targets='$advnew[targets]', parameters='$advnew[parameters]', code='$advnew[code]', starttime='$advnew[starttime]', endtime='$advnew[endtime]' WHERE advid='$advid'");
if($type == 'intercat') {
updatecache('advs_index');
} elseif(in_array($type, array('thread', 'interthread'))) {
updatecache('advs_viewthread');
} elseif($type == 'text') {
updatecache(array('advs_index', 'advs_forumdisplay', 'advs_viewthread'));
} else {
updatecache(array('settings', 'advs_archiver', 'advs_register', 'advs_index', 'advs_forumdisplay', 'advs_viewthread'));
}
cpmsg('adv_succeed', $BASESCRIPT.'?action=adv', 'succeed');
}
} elseif($operation == 'config') {
if(!submitcheck('configsubmit')) {
$query = $db->query("SELECT value FROM {$tablepre}settings WHERE variable='admode'");
$admode = $db->result($query, 0);
shownav('adv', 'adv_admin');
showsubmenu('adv_admin', array(
array('config', 'adv&operation=config', 1),
array('admin', 'adv', 0),
array(array('menu' => 'add', 'submenu' => array(
array('adv_type_headerbanner', 'adv&operation=advadd&type=headerbanner'),
array('adv_type_footerbanner', 'adv&operation=advadd&type=footerbanner'),
array('adv_type_text', 'adv&operation=advadd&type=text'),
array('adv_type_thread', 'adv&operation=advadd&type=thread'),
array('adv_type_interthread', 'adv&operation=advadd&type=interthread'),
array('adv_type_float', 'adv&operation=advadd&type=float'),
array('adv_type_couplebanner', 'adv&operation=advadd&type=couplebanner'),
array('adv_type_intercat', 'adv&operation=advadd&type=intercat'),
)), '', 0)
));
showformheader('adv&operation=config');
showtableheader();
showsetting('adv_config_mode', array('admodenew', array(array(0, lang('adv_config_mode_0')), array(1, lang('adv_config_mode_1')))), $admode, 'select');
showsubmit('configsubmit');
showtablefooter();
showformfooter();
} else {
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('admode', '$admodenew')");
updatecache('settings');
cpmsg('adv_config_succeed', $BASESCRIPT.'?action=adv&operation=config', 'succeed');
}
}
function showtargets($adv) {
if($adv['targets'] == '' || $adv['targets'] == 'forum') {
return lang('all');
} else {
$targets = explode("\t", $adv['targets']);
$count = count($targets);
$max = $count > 2 ? 2 : $count;
$t = array();
for($i = 0;$i < $max;$i++) {
$t[] = showtargetlink($targets[$i]);
}
$r = implode(', ', $t);
if($count > 2) {
$r .= ' ...';
}
return $r;
}
}
function showtargetlink($target) {
global $_DCACHE;
return $target == 'register' ? '<a href="'.$regname.'" target="_blank">'.lang('adv_register').'</a>' :
($target == 'redirect' ? lang('adv_jump') :
($target == 'archiver' ? '<a href="archiver/" target="_blank">Archiver</a>' :
($target ? '<a href="forumdisplay.php?fid='.$target.'" target="_blank">'.$_DCACHE['forums'][$target]['name'].'</a>' : '<a href="'.$indexname.'" target="_blank">'.lang('home').'</a>')));
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/adv.inc.php
|
PHP
|
asf20
| 24,655
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: video.inc.php 16993 2008-12-02 00:58:13Z liuqiang $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$video = unserialize($db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='videoinfo'"));
if($operation == 'config') {
if(empty($video['authkey'])) {
cpmsg('insenz_invalidvideo');
}
$video['bbname'] = $video['bbname'] ? $video['bbname'] : $bbname;
$video['url'] = $video['url'] ? $video['url'] : $boardurl;
$videonew['sitetype'] = $video['sitetype'];
$sitetypeselect = $br = '';
if($sitetypearray = explode("\t", $video['sitetype'])) {
foreach($sitetypearray as $key => $sitetype) {
$br = ($key + 1) % 6 == 0 ? '<br />' : '';
$selected = $video['type'] == $key + 1 ? 'checked' : '';
$sitetypeselect .= '<input type="radio" class="radio" name="videonew[type]" value="'.($key + 1).'" '.$selected.'> '.$sitetype.' '.$br;
}
}
if(!submitcheck('configsubmit')) {
shownav('extended', 'nav_video');
showsubmenu('nav_video', array(
array('nav_video_config', 'video&operation=config', 1),
array('nav_video_class', 'video&operation=class', 0)
));
showtips('video_tips');
showformheader('video&operation=config');
showtableheader();
showsetting('video_open', 'videonew[open]', $video['open'], 'radio');
showsetting('video_site_name', 'videonew[bbname]', $video['bbname'], 'text');
showsetting('video_site_url', 'videonew[url]', $video['url'], 'text');
showsetting('video_site_email', 'videonew[email]', $video['email'], 'text');
showsetting('video_site_logo', 'videonew[logo]', $video['logo'], 'text');
showsetting('video_site_type', array('videonew[sitetype]', array(
array(0, $lang['video_site_type_none']),
array(1, $lang['video_site_type_1']),
array(2, $lang['video_site_type_2']),
array(3, $lang['video_site_type_3']),
array(5, $lang['video_site_type_5']),
array(6, $lang['video_site_type_6']),
array(7, $lang['video_site_type_7']),
array(8, $lang['video_site_type_8']),
array(9, $lang['video_site_type_9']),
array(10, $lang['video_site_type_10']),
array(11, $lang['video_site_type_11']),
array(12, $lang['video_site_type_12']),
array(13, $lang['video_site_type_13']),
array(14, $lang['video_site_type_14']),
array(15, $lang['video_site_type_15']),
array(16, $lang['video_site_type_16']),
array(17, $lang['video_site_type_17']),
array(18, $lang['video_site_type_18']),
array(19, $lang['video_site_type_19']),
array(20, $lang['video_site_type_20']),
array(21, $lang['video_site_type_21']),
array(22, $lang['video_site_type_22']),
array(23, $lang['video_site_type_23']),
array(24, $lang['video_site_type_24']),
array(25, $lang['video_site_type_25']),
array(26, $lang['video_site_type_26']),
array(27, $lang['video_site_type_27']),
array(28, $lang['video_site_type_28']),
array(29, $lang['video_site_type_29']),
array(30, $lang['video_site_type_30']),
array(31, $lang['video_site_type_31']),
array(32, $lang['video_site_type_32']),
array(33, $lang['video_site_type_33']),
array(34, $lang['video_site_type_34']),
array(35, $lang['video_site_type_35']),
array(36, $lang['video_site_type_36']),
array(37, $lang['video_site_type_37']),
array(38, $lang['video_site_type_38']),
array(39, $lang['video_site_type_39']),
array(40, $lang['video_site_type_40']),
array(41, $lang['video_site_type_41'])
)), $video['sitetype'], 'select');
showsubmit('configsubmit');
showtablefooter();
showformfooter();
} else {
require_once DISCUZ_ROOT.'./include/insenz.func.php';
require_once DISCUZ_ROOT.'./api/video.php';
$videoAccount = new VideoClient_SiteService($appid, $video['siteid'], $video['authkey']);
$result = $videoAccount->edit(insenz_convert($videonew['bbname']), $videonew['url'], $videonew['logo'], $videonew['sitetype']);
if ($result->isError()) {
cpmsg(insenz_convert($result->getMessage(), 0), '', 'error');
} else {
$video['open'] = intval($videonew['open']);
$video['bbname'] = $videonew['bbname'];
$video['url'] = $videonew['url'];
$video['email'] = $videonew['email'];
$video['logo'] = $videonew['logo'];
$video['sitetype'] = $videonew['sitetype'];
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('videoinfo', '".addslashes(serialize($video))."')");
updatecache('settings');
cpmsg('video_config_succeed', $BASESCRIPT.'?action=video&operation=config', 'succeed');
}
}
} elseif($operation == 'class') {
$videodefault = array(
1 => array('name' => $lang['video_video_type_1']),
5 => array('name' => $lang['video_video_type_5']),
7 => array('name' => $lang['video_video_type_7']),
8 => array('name' => $lang['video_video_type_8']),
11 => array('name' => $lang['video_video_type_11']),
12 => array('name' => $lang['video_video_type_12']),
14 => array('name' => $lang['video_video_type_14']),
15 => array('name' => $lang['video_video_type_15']),
16 => array('name' => $lang['video_video_type_16']),
18 => array('name' => $lang['video_video_type_18']),
19 => array('name' => $lang['video_video_type_19']),
21 => array('name' => $lang['video_video_type_21']),
22 => array('name' => $lang['video_video_type_22']),
23 => array('name' => $lang['video_video_type_23']),
24 => array('name' => $lang['video_video_type_24']),
25 => array('name' => $lang['video_video_type_25']),
26 => array('name' => $lang['video_video_type_26']),
27 => array('name' => $lang['video_video_type_27']),
28 => array('name' => $lang['video_video_type_28']),
29 => array('name' => $lang['video_video_type_29']),
30 => array('name' => $lang['video_video_type_30']),
31 => array('name' => $lang['video_video_type_31']),
32 => array('name' => $lang['video_video_type_32'])
);
if(!submitcheck('classsubmit')) {
$videotype = !$video['videotype'] ? $videodefault : $video['videotype'];
$videotypelist = '<ul class="dblist" onmouseover="altStyle(this);">';
foreach($videotype as $id => $type) {
$checked = $type['able'] ? ' checked="checked"' : '';
$videotypelist .= '<li><input type="checkbox" name="videotypenew['.$id.'][able]" class="radio"'.$checked.' value="1"> <input type="text" class="txt" name="videotypenew['.$id.'][name]" value="'.$type['name'].'" size="8"></li>';
}
$videotypelist .= '</ul>';
shownav('extended', 'nav_video');
showsubmenu('nav_video', array(
array('nav_video_config', 'video&operation=config', 0),
array('nav_video_class', 'video&operation=class', 1)
));
showformheader('video&operation=class');
showtableheader();
showtablerow('', 'class="td27"', lang('video_class').'('.lang('video_class_comment').')');
showtablerow('', '', $videotypelist);
showsubmit('classsubmit');
showtablefooter();
showformfooter();
} else {
$video['videotype'] = $videotypenew;
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('videoinfo', '".addslashes(serialize($video))."')");
updatecache('settings');
cpmsg('video_class_update_succeed', $BASESCRIPT.'?action=video&operation=class', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/video.inc.php
|
PHP
|
asf20
| 7,469
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: profilefields.inc.php 16698 2008-11-14 07:58:56Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
if(!submitcheck('fieldsubmit')) {
$query = $db->query("SELECT * FROM {$tablepre}profilefields");
while($field = $db->fetch_array($query)) {
$profilefields .= showtablerow('', array('class="td25"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[{$field[fieldid]}]\" value=\"$field[fieldid]\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[{$field[fieldid]}]\" value=\"$field[displayorder]\">",
"<input type=\"text\" class=\"txt\" size=\"18\" name=\"titlenew[{$field[fieldid]}]\" value=\"$field[title]\">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[{$field[fieldid]}]\" value=\"1\" ".($field['available'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"invisiblenew[{$field[fieldid]}]\" value=\"1\" ".($field['invisible'] ? 'checked' : '').">",
"<input class=\"checkbox\" type=\"checkbox\" name=\"unchangeablenew[{$field[fieldid]}]\" value=\"1\" ".($field['unchangeable'] ? 'checked' : '').">",
"<a href=\"$BASESCRIPT?action=profilefields&operation=edit&id=$field[fieldid]\" class=\"act\">$lang[detail]</a>"
), TRUE);
}
shownav('user', 'profilefields');
showsubmenu('profilefields');
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[
[1,'', 'td25'],
[1,'', 'td28'],
[6,'<input type="text" class="txt" name="newtitle[]" size="18">']
]
];
</script>
EOT;
showformheader('profilefields');
showtableheader();
showsubtitle(array('', 'display_order', 'profilefields_title', 'available', 'profilefields_invisible', 'profilefields_unchangeable', ''));
echo $profilefields;
echo '<tr><td></td><td colspan="7"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['profilefields_add'].'</a></div></td></tr>';
showsubmit('fieldsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if(is_array($titlenew)) {
foreach($titlenew as $id => $val) {
$db->query("UPDATE {$tablepre}profilefields SET title='$titlenew[$id]', available='$availablenew[$id]', invisible='$invisiblenew[$id]', displayorder='$displayordernew[$id]', unchangeable='$unchangeablenew[$id]' WHERE fieldid='$id'");
}
}
if(is_array($delete)) {
$ids = implode('\',\'', $delete);
$dropfields = implode(',DROP field_', $delete);
$db->query("DELETE FROM {$tablepre}profilefields WHERE fieldid IN ('$ids')");
$db->query("ALTER TABLE {$tablepre}memberfields DROP field_$dropfields");
}
if(is_array($newtitle)) {
foreach($newtitle as $value) {
if($value = trim($value)) {
$db->query("INSERT INTO {$tablepre}profilefields (available, invisible, title, size)
VALUES ('1', '0', '$value', '50')");
$fieldid = $db->insert_id();
$db->query("ALTER TABLE {$tablepre}memberfields ADD field_$fieldid varchar(50) NOT NULL", 'SILENT');
}
}
}
updatecache(array('fields_required', 'fields_optional', 'custominfo'));
cpmsg('fields_edit_succeed', $BASESCRIPT.'?action=profilefields', 'succeed');
}
} elseif($operation == 'edit') {
$field = $db->fetch_first("SELECT * FROM {$tablepre}profilefields WHERE fieldid='$id'");
if(!$field) {
cpmsg('undefined_action', '', 'error');
}
if(!submitcheck('editsubmit')) {
showsubmenu("$lang[profilefields_edit] - $field[title]");
showformheader("profilefields&operation=edit&id=$id");
showtableheader();
showsetting('profilefields_edit_title', 'titlenew', $field['title'], 'text');
showsetting('profilefields_edit_desc', 'descriptionnew', $field['description'], 'text');
showsetting('profilefields_edit_size', 'sizenew', $field['size'], 'text');
showsetting('profilefields_edit_invisible', 'invisiblenew', $field['invisible'], 'radio');
showsetting('profilefields_edit_required', 'requirednew', $field['required'], 'radio');
showsetting('profilefields_edit_unchangeable', 'unchangeablenew', $field['unchangeable'], 'radio');
showsetting('profilefields_edit_selective', 'selectivenew', $field['selective'], 'radio');
showsetting('profilefields_edit_choices', 'choicesnew', $field['choices'], 'textarea');
showsubmit('editsubmit');
showtablefooter();
showformfooter();
} else {
$titlenew = trim($titlenew);
$sizenew = $sizenew <= 255 ? $sizenew : 255;
if(!$titlenew || !$sizenew) {
cpmsg('fields_edit_invalid', '', 'error');
}
if($sizenew != $field['size']) {
$db->query("ALTER TABLE {$tablepre}memberfields CHANGE field_$id field_$id varchar($sizenew) NOT NULL");
}
$db->query("UPDATE {$tablepre}profilefields SET title='$titlenew', description='$descriptionnew', size='$sizenew', invisible='$invisiblenew', required='$requirednew', unchangeable='$unchangeablenew', selective='$selectivenew', choices='$choicesnew' WHERE fieldid='$id'");
updatecache(array('fields_required', 'fields_optional', 'custominfo'));
cpmsg('fields_edit_succeed', $BASESCRIPT.'?action=profilefields', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/profilefields.inc.php
|
PHP
|
asf20
| 5,370
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: settings.inc.php 17535 2009-01-20 05:12:20Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
$settings = array();
$query = $db->query("SELECT * FROM {$tablepre}settings");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
if(!$isfounder) {
unset($settings['ftp']);
}
$extbutton = '';
$operation = $operation ? $operation : 'basic';
if(!submitcheck('settingsubmit')) {
if($operation == 'ec') {
if($from == 'creditwizard') {
shownav('tools', 'nav_creditwizard', 'settings_ec');
} else {
shownav('extended', 'nav_ec', 'nav_ec_config');
}
} elseif(in_array($operation, array('seo', 'cachethread', 'serveropti'))) {
shownav('global', 'settings_optimize', 'settings_'.$operation);
} elseif($operation == 'styles') {
shownav('style', 'settings_styles');
} elseif($operation == 'editor') {
shownav('style', 'settings_editor');
} else {
shownav('global', 'settings_'.$operation);
}
if(in_array($operation, array('seo', 'cachethread', 'serveropti'))) {
$current = array($operation => 1);
showsubmenu('settings_optimize', array(
array('settings_seo', 'settings&operation=seo', $current['seo']),
array('settings_cachethread', 'settings&operation=cachethread', $current['cachethread']),
array('settings_serveropti', 'settings&operation=serveropti', $current['serveropti'])
));
} elseif($operation == 'ec') {
if($from == 'creditwizard') {
showsubmenu('nav_creditwizard', array(
array('creditwizard_step_menu_1', 'creditwizard&step=1', 0),
array('creditwizard_step_menu_2', 'creditwizard&step=2', 0),
array('creditwizard_step_menu_3', 'creditwizard&step=3', 0),
array('creditwizard_step_menu_4', 'settings&operation=ec&from=creditwizard', 1),
array('ec_alipay', 'ec&operation=alipay&from=creditwizard', 0),
));
} else {
showsubmenu('nav_ec', array(
array('nav_ec_config', 'settings&operation=ec', 1),
array('nav_ec_alipay', 'ec&operation=alipay', 0),
array('nav_ec_credit', 'ec&operation=credit', 0),
array('nav_ec_orders', 'ec&operation=orders', 0),
array('nav_ec_tradelog', 'tradelog', 0)
));
}
} elseif($operation == 'access') {
$anchor = in_array($anchor, array('register', 'access')) ? $anchor : 'register';
showsubmenuanchors('settings_access', array(
array('settings_access_register', 'register', $anchor == 'register'),
array('settings_access_access', 'access', $anchor == 'access')
));
} elseif($operation == 'mail') {
$anchor = in_array($anchor, array('settings', 'check')) ? $anchor : 'settings';
showsubmenuanchors('settings_mail', array(
array('settings_mail_settings', 'mailsettings', $anchor == 'settings'),
array('settings_mail_check', 'mailcheck', $anchor == 'check')
));
} elseif($operation == 'sec') {
$anchor = in_array($anchor, array('seclevel', 'seccode', 'secqaa')) ? $anchor : 'seclevel';
showsubmenuanchors('settings_sec', array(
array('settings_sec_seclevel', 'seclevel', $anchor == 'seclevel'),
array('settings_sec_seccode', 'seccode', $anchor == 'seccode'),
array('settings_sec_secqaa', 'secqaa', $anchor == 'secqaa')
));
} elseif($operation == 'attach') {
$anchor = in_array($anchor, array('basic', 'image', 'remote', 'antileech')) ? $anchor : 'basic';
showsubmenuanchors('settings_attach', array(
array('settings_attach_basic', 'basic', $anchor == 'basic'),
array('settings_attach_image', 'image', $anchor == 'image'),
$isfounder ? array('settings_attach_remote', 'remote', $anchor == 'remote') : '',
array('settings_attach_antileech', 'antileech', $anchor == 'antileech'),
));
} elseif($operation == 'styles') {
$anchor = in_array($anchor, array('global', 'index', 'forumdisplay', 'viewthread', 'member', 'refresh', 'sitemessage')) ? $anchor : 'global';
$current = array($anchor => 1);
showsubmenu('settings_styles', array(
array('settings_styles_global', 'settings&operation=styles&anchor=global', $current['global']),
array('settings_styles_index', 'settings&operation=styles&anchor=index', $current['index']),
array('settings_styles_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', $current['forumdisplay']),
array('settings_styles_viewthread', 'settings&operation=styles&anchor=viewthread', $current['viewthread']),
array('settings_styles_member', 'settings&operation=styles&anchor=member', $current['member']),
array('settings_styles_customnav', 'misc&operation=customnav', 0),
array(array('menu' => 'jswizard_infoside', 'submenu' => array(
array('jswizard_infoside_global', 'jswizard&operation=infoside&from=style'),
array('jswizard_infoside_2', 'jswizard&operation=infoside&sideid=2&from=style'),
array('jswizard_infoside_0', 'jswizard&operation=infoside&sideid=0&from=style'),
))),
array('settings_styles_refresh', 'settings&operation=styles&anchor=refresh', $current['refresh']),
array('settings_styles_sitemessage', 'settings&operation=styles&anchor=sitemessage', $current['sitemessage'])
));
} elseif($operation == 'functions') {
$anchor = in_array($anchor, array('stat', 'mod', 'tags', 'other')) ? $anchor : 'stat';
showsubmenuanchors('settings_functions', array(
array('settings_functions_stat', 'stat', $anchor == 'stat'),
array('settings_functions_mod', 'mod', $anchor == 'mod'),
array('settings_functions_tags', 'tags', $anchor == 'tags'),
array('settings_functions_other', 'other', $anchor == 'other'),
));
} elseif($operation == 'editor') {
showsubmenu('settings_editor', array(
array('settings_editor_global', 'settings&operation=editor', 1),
array('settings_editor_code', 'misc&operation=bbcode', 0),
));
} elseif($operation == 'msn') {
shownav('extended', 'settings_msn');
} else {
showsubmenu('settings_'.$operation);
}
showformheader('settings&edit=yes');
showhiddenfields(array('operation' => $operation));
if($operation == 'basic') {
showtableheader();
showsetting('settings_basic_bbname', 'settingsnew[bbname]', $settings['bbname'], 'text');
showsetting('settings_basic_sitename', 'settingsnew[sitename]', $settings['sitename'], 'text');
showsetting('settings_basic_siteurl', 'settingsnew[siteurl]', $settings['siteurl'], 'text');
showsetting('settings_basic_index_name', 'settingsnew[indexname]', $settings['indexname'], 'text');
showsetting('settings_basic_icp', 'settingsnew[icp]', $settings['icp'], 'text');
showsetting('settings_basic_boardlicensed', 'settingsnew[boardlicensed]', $settings['boardlicensed'], 'radio');
showsetting('settings_basic_bbclosed', 'settingsnew[bbclosed]', $settings['bbclosed'], 'radio');
showsetting('settings_basic_closedreason', 'settingsnew[closedreason]', $settings['closedreason'], 'textarea');
showsetting('settings_basic_stat', 'settingsnew[statcode]', $settings['statcode'], 'textarea');
} elseif($operation == 'access') {
$wmsgcheck = array($settings['welcomemsg'] =>'checked');
$settings['inviteconfig'] = unserialize($settings['inviteconfig']);
$settings['extcredits'] = unserialize($settings['extcredits']);
$buycredits = $rewardcredist = '';
for($i = 0; $i <= 8; $i++) {
$extcredit = 'extcredits'.$i.($settings['extcredits'][$i]['available'] ? ' ('.$settings['extcredits'][$i]['title'].')' : '');
$buycredits .= '<option value="'.$i.'" '.($i == intval($settings['inviteconfig']['invitecredit']) ? 'selected' : '').'>'.($i ? $extcredit : $lang['none']).'</option>';
$rewardcredits .= '<option value="'.$i.'" '.($i == intval($settings['inviteconfig']['inviterewardcredit']) ? 'selected' : '').'>'.($i ? $extcredit : $lang['none']).'</option>';
}
$groupselect = '';
$query = $db->query("SELECT groupid, grouptitle FROM {$tablepre}usergroups WHERE type='special'");
while($group = $db->fetch_array($query)) {
$groupselect .= "<option value=\"$group[groupid]\" ".($group['groupid'] == $settings['inviteconfig']['invitegroupid'] ? 'selected' : '').">$group[grouptitle]</option>\n";
}
$taskarray = array(array('', lang('select')));
$query = $db->query("SELECT taskid, name FROM {$tablepre}tasks WHERE available='2'");
while($task = $db->fetch_array($query)) {
$taskarray[] = array($task['taskid'], $task['name']);
}
showtableheader('', 'nobottom', 'id="register"'.($anchor != 'register' ? ' style="display: none"' : ''));
showsetting('settings_access_register_status', array('settingsnew[regstatus]', array(
array(0, $lang['settings_access_register_close'], array('showinvite' => 'none')),
array(1, $lang['settings_access_register_open'], array('showinvite' => 'none')),
array(2, $lang['settings_access_register_invite'], array('showinvite' => '')),
array(3, $lang['settings_access_register_open_invite'], array('showinvite' => ''))
)), $settings['regstatus'], 'mradio');
showtagheader('tbody', 'showinvite', $settings['regstatus'] > 1, 'sub');
showsetting('settings_access_register_invite_credit', '', '', '<select name="settingsnew[inviteconfig][inviterewardcredit]">'.$rewardcredits.'</select>');
showsetting('settings_access_register_invite_addcredit', 'settingsnew[inviteconfig][inviteaddcredit]', $settings['inviteconfig']['inviteaddcredit'], 'text');
showsetting('settings_access_register_invite_invitedcredit', 'settingsnew[inviteconfig][invitedaddcredit]', $settings['inviteconfig']['invitedaddcredit'], 'text');
showsetting('settings_access_register_invite_addfriend', 'settingsnew[inviteconfig][inviteaddbuddy]', $settings['inviteconfig']['inviteaddbuddy'], 'radio');
showsetting('settings_access_register_invite_group', '', '', '<select name="settingsnew[inviteconfig][invitegroupid]"><option value="0">'.$lang['usergroups_system_0'].'</option>'.$groupselect.'</select>');
showtagfooter('tbody');
showsetting('settings_access_register_name', 'settingsnew[regname]', $settings['regname'], 'text');
showsetting('settings_access_register_link_name', 'settingsnew[reglinkname]', $settings['reglinkname'], 'text');
showsetting('settings_access_register_censoruser', 'settingsnew[censoruser]', $settings['censoruser'], 'textarea');
showsetting('settings_access_register_verify', array('settingsnew[regverify]', array(
array(0, $lang['none']),
array(1, $lang['settings_access_register_verify_email']),
array(2, $lang['settings_access_register_verify_manual'])
)), $settings['regverify'], 'select');
showsetting('settings_access_register_ctrl', 'settingsnew[regctrl]', $settings['regctrl'], 'text');
showsetting('settings_access_register_floodctrl', 'settingsnew[regfloodctrl]', $settings['regfloodctrl'], 'text');
showsetting('settings_access_register_ipctrl', 'settingsnew[ipregctrl]', $settings['ipregctrl'], 'textarea');
showsetting('settings_access_register_welcomemsg', array('settingsnew[welcomemsg]', array(
array(0, $lang['settings_access_register_welcomemsg_nosend'], array('welcomemsgext' => 'none')),
array(1, $lang['settings_access_register_welcomemsg_pm'], array('welcomemsgext' => '')),
array(2, $lang['settings_access_register_welcomemsg_email'], array('welcomemsgext' => ''))
)), $settings['welcomemsg'], 'mradio');
showtagheader('tbody', 'welcomemsgext', $settings['welcomemsg'], 'sub');
showsetting('settings_access_register_welcomemsgtitle', 'settingsnew[welcomemsgtitle]', $settings['welcomemsgtitle'], 'text');
showsetting('settings_access_register_welcomemsgtxt', 'settingsnew[welcomemsgtxt]', $settings['welcomemsgtxt'], 'textarea');
showtagfooter('tbody');
showsetting('settings_access_register_bbrules', 'settingsnew[bbrules]', $settings['bbrules'], 'radio', '', 1);
showsetting('settings_access_register_bbrulestxt', 'settingsnew[bbrulestxt]', $settings['bbrulestxt'], 'textarea');
showtagfooter('tbody');
showtablefooter();
showtableheader('', 'nobottom', 'id="access"'.($anchor != 'access' ? ' style="display: none"' : ''));
showsetting('settings_access_access_newbiespan', 'settingsnew[newbiespan]', $settings['newbiespan'], 'text');
showsetting('settings_access_access_newbietask', array('settingsnew[newbietask]', $taskarray), $settings['newbietask'], 'select');
showsetting('settings_access_access_ipaccess', 'settingsnew[ipaccess]', $settings['ipaccess'], 'textarea');
showsetting('settings_access_access_adminipaccess', 'settingsnew[adminipaccess]', $settings['adminipaccess'], 'textarea');
showtablefooter();
showtableheader('', 'notop');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'styles') {
$showsettings = str_pad(decbin($settings['showsettings']), 3, 0, STR_PAD_LEFT);
$settings['showsignatures'] = $showsettings{0};
$settings['showavatars'] = $showsettings{1};
$settings['showimages'] = $showsettings{2};
$settings['postnocustom'] = implode("\n", (array)unserialize($settings['postnocustom']));
$settings['sitemessage'] = unserialize($settings['sitemessage']);
$settings['customauthorinfo'] = unserialize($settings['customauthorinfo']);
$settings['customauthorinfo'] = $settings['customauthorinfo'][0];
list($settings['zoomstatus'], $settings['imagemaxwidth']) = explode("\t", $settings['zoomstatus']);
$settings['imagemaxwidth'] = !empty($settings['imagemaxwidth']) ? $settings['imagemaxwidth'] : 600;
$stylelist = "<select name=\"settingsnew[styleid]\">\n";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$selected = $style['styleid'] == $settings['styleid'] ? 'selected="selected"' : NULL;
$stylelist .= "<option value=\"$style[styleid]\" $selected>$style[name]</option>\n";
}
$stylelist .= '</select>';
showtips('settings_tips', 'global_tips', $anchor == 'global');
showtips('settings_tips', 'index_tips', $anchor == 'index');
showtips('settings_tips', 'forumdisplay_tips', $anchor == 'forumdisplay');
showtableheader('', 'nobottom', 'id="global"'.($anchor != 'global' ? ' style="display: none"' : ''));
showsetting('settings_styles_global_styleid', '', '', $stylelist);
showsetting('settings_styles_global_stylejump', 'settingsnew[stylejump]', $settings['stylejump'], 'radio');
showsetting('settings_styles_global_jsmenu', 'settingsnew[forumjump]', $settings['forumjump'], 'radio');
showsetting('settings_styles_global_frameon', array('settingsnew[frameon]', array(
array(0, $lang['settings_styles_global_frameon_0'], array('frameonext' => 'none')),
array(1, $lang['settings_styles_global_frameon_1'], array('frameonext' => '')),
array(2, $lang['settings_styles_global_frameon_2'], array('frameonext' => ''))
)), $settings['frameon'], 'mradio');
showtagheader('tbody', 'frameonext', $settings['frameon'], 'sub');
showsetting('settings_styles_global_framewidth', 'settingsnew[framewidth]', $settings['framewidth'], 'text');
showtagfooter('tbody');
showsetting('settings_styles_global_allowfloatwin', 'settingsnew[allowfloatwin]', $settings['allowfloatwin'], 'radio');
showsetting('settings_styles_global_creditnotice', 'settingsnew[creditnotice]', $settings['creditnotice'], 'radio');
showtableheader('', 'nobottom', 'id="index"'.($anchor != 'index' ? ' style="display: none"' : ''));
showsetting('settings_styles_index_subforumsindex', 'settingsnew[subforumsindex]', $settings['subforumsindex'], 'radio');
showsetting('settings_styles_index_forumlinkstatus', 'settingsnew[forumlinkstatus]', $settings['forumlinkstatus'], 'radio');
showsetting('settings_styles_index_members', 'settingsnew[maxbdays]', $settings['maxbdays'], 'text');
showsetting('settings_styles_index_moddisplay', array('settingsnew[moddisplay]', array(
array('flat', $lang['settings_styles_index_moddisplay_flat']),
array('selectbox', $lang['settings_styles_index_moddisplay_selectbox'])
)), $settings['moddisplay'], 'mradio');
showsetting('settings_styles_index_whosonline', array('settingsnew[whosonlinestatus]', array(
array(0, $lang['settings_styles_index_display_none']),
array(1, $lang['settings_styles_index_whosonline_index']),
array(2, $lang['settings_styles_index_whosonline_forum']),
array(3, $lang['settings_styles_index_whosonline_both'])
)), $settings['whosonlinestatus'], 'select');
showsetting('settings_styles_index_whosonline_contract', 'settingsnew[whosonline_contract]', $settings['whosonline_contract'], 'radio');
showsetting('settings_styles_index_online_more_members', 'settingsnew[maxonlinelist]', $settings['maxonlinelist'], 'text');
showsetting('settings_styles_index_hideprivate', 'settingsnew[hideprivate]', $settings['hideprivate'], 'radio');
showtablefooter();
showtableheader('', 'nobottom', 'id="forumdisplay"'.($anchor != 'forumdisplay' ? ' style="display: none"' : ''));
showsetting('settings_styles_forumdisplay_tpp', 'settingsnew[topicperpage]', $settings['topicperpage'], 'text');
showsetting('settings_styles_forumdisplay_threadmaxpages', 'settingsnew[threadmaxpages]', $settings['threadmaxpages'], 'text');
showsetting('settings_styles_forumdisplay_hottopic', 'settingsnew[hottopic]', $settings['hottopic'], 'text');
showsetting('settings_styles_forumdisplay_globalstick', 'settingsnew[globalstick]', $settings['globalstick'], 'radio');
showsetting('settings_styles_forumdisplay_stick', 'settingsnew[threadsticky]', $settings['threadsticky'], 'text');
showsetting('settings_styles_forumdisplay_visitedforums', 'settingsnew[visitedforums]', $settings['visitedforums'], 'text');
showtablefooter();
showtagheader('div', 'viewthread', $anchor == 'viewthread');
showtableheader('nav_settings_viewthread', 'nobottom');
showsetting('settings_styles_viewthread_ppp', 'settingsnew[postperpage]', $settings['postperpage'], 'text');
showsetting('settings_styles_viewthread_starthreshold', 'settingsnew[starthreshold]', $settings['starthreshold'], 'text');
showsetting('settings_styles_viewthread_maxsigrows', 'settingsnew[maxsigrows]', $settings['maxsigrows'], 'text');
showsetting('settings_styles_viewthread_sigviewcond', 'settingsnew[sigviewcond]', $settings['sigviewcond'], 'text');
showsetting('settings_styles_viewthread_rate_number', 'settingsnew[ratelogrecord]', $settings['ratelogrecord'], 'text');
showsetting('settings_styles_viewthread_show_signature', 'settingsnew[showsignatures]', $settings['showsignatures'], 'radio');
showsetting('settings_styles_viewthread_show_face', 'settingsnew[showavatars]', $settings['showavatars'], 'radio');
showsetting('settings_styles_viewthread_show_images', 'settingsnew[showimages]', $settings['showimages'], 'radio');
showsetting('settings_styles_viewthread_imagemaxwidth', 'settingsnew[imagemaxwidth]', $settings['imagemaxwidth'], 'text');
showsetting('settings_styles_viewthread_zoomstatus', 'settingsnew[zoomstatus]', $settings['zoomstatus'], 'radio');
showsetting('settings_styles_viewthread_fastpost', 'settingsnew[fastpost]', $settings['fastpost'], 'radio');
showsetting('settings_styles_viewthread_vtonlinestatus', array('settingsnew[vtonlinestatus]', array(
array(0, $lang['settings_styles_viewthread_display_none']),
array(1, $lang['settings_styles_viewthread_online_easy']),
array(2, $lang['settings_styles_viewthread_online_exactitude'])
)), $settings['vtonlinestatus'], 'select');
showsetting('settings_styles_viewthread_userstatusby', array('settingsnew[userstatusby]', array(
array(0, $lang['settings_styles_viewthread_display_none']),
array(1, $lang['settings_styles_viewthread_userstatusby_usergroup']),
array(2, $lang['settings_styles_viewthread_userstatusby_rank'])
)), $settings['userstatusby'], 'select');
showsetting('settings_styles_viewthread_postno', 'settingsnew[postno]', $settings['postno'], 'text');
showsetting('settings_styles_viewthread_postnocustom', 'settingsnew[postnocustom]', $settings['postnocustom'], 'textarea');
showsetting('settings_styles_viewthread_maxsmilies', 'settingsnew[maxsmilies]', $settings['maxsmilies'], 'text');
showsetting('settings_styles_viewthread_author_onleft', array('settingsnew[authoronleft]', array(
array(1, lang('settings_styles_viewthread_author_onleft_yes')),
array(0, lang('settings_styles_viewthread_author_onleft_no')))), $settings['authoronleft'], 'mradio');
showtableheader('settings_styles_viewthread_customauthorinfo', 'fixpadding');
$authorinfoitems = array(
'uid' => 'UID',
'posts' => $lang['settings_styles_viewthread_userinfo_posts'],
'digest' => $lang['settings_styles_viewthread_userinfo_digest'],
'credits' => $lang['settings_styles_viewthread_userinfo_credits'],
);
if(!empty($extcredits)) {
foreach($extcredits as $key => $value) {
$authorinfoitems['extcredits'.$key] = $value['title'];
}
}
$query = $db->query("SELECT fieldid,title FROM {$tablepre}profilefields WHERE available='1' AND invisible='0' ORDER BY displayorder");
while($profilefields = $db->fetch_array($query)) {
$authorinfoitems['field_'.$profilefields['fieldid']] = $profilefields['title'];
}
$authorinfoitems = array_merge($authorinfoitems, array(
'readperm' => $lang['settings_styles_viewthread_userinfo_readperm'],
'gender' => $lang['settings_styles_viewthread_userinfo_gender'],
'location' => $lang['settings_styles_viewthread_userinfo_location'],
'oltime' => $lang['settings_styles_viewthread_userinfo_oltime'],
'regtime' => $lang['settings_styles_viewthread_userinfo_regtime'],
'lastdate' => $lang['settings_styles_viewthread_userinfo_lastdate'],
));
showsubtitle(array('', 'settings_styles_viewthread_userinfo_left', 'settings_styles_viewthread_userinfo_menu'));
$authorinfoitemsetting = '';
foreach($authorinfoitems as $key => $value) {
$authorinfoitemsetting .= '<tr><td>'.$value.
'</td><td><input name="settingsnew[customauthorinfo]['.$key.'][left]" type="checkbox" class="checkbox" value="1" '.($settings['customauthorinfo'][$key]['left'] ? 'checked' : '').'>'.
'</td><td><input name="settingsnew[customauthorinfo]['.$key.'][menu]" type="checkbox" class="checkbox" value="1" '.($settings['customauthorinfo'][$key]['menu'] ? 'checked' : '').'>'.
'</td></tr>';
}
echo $authorinfoitemsetting;
showtablefooter();
showtagfooter('div');
showtableheader('', 'nobottom', 'id="member"'.($anchor != 'member' ? ' style="display: none"' : ''));
showsetting('settings_styles_member_mpp', 'settingsnew[memberperpage]', $settings['memberperpage'], 'text');
showsetting('settings_styles_member_maxpages', 'settingsnew[membermaxpages]', $settings['membermaxpages'], 'text');
$settings['msgforward'] = !empty($settings['msgforward']) ? unserialize($settings['msgforward']) : array();
$settings['msgforward']['messages'] = !empty($settings['msgforward']['messages']) ? implode("\n", $settings['msgforward']['messages']) : '';
showtablefooter();
showtableheader('', 'nobottom', 'id="refresh"'.($anchor != 'refresh' ? ' style="display: none"' : ''));
showsetting('settings_styles_refresh_refreshtime', 'settingsnew[msgforward][refreshtime]', $settings['msgforward']['refreshtime'], 'text');
showsetting('settings_styles_refresh_quick', 'settingsnew[msgforward][quick]', $settings['msgforward']['quick'], 'radio', '', 1);
showsetting('settings_styles_refresh_messages', 'settingsnew[msgforward][messages]', $settings['msgforward']['messages'], 'textarea');
showtagfooter('tbody');
showtablefooter();
showtableheader('', 'nobottom', 'id="sitemessage"'.($anchor != 'sitemessage' ? ' style="display: none"' : ''));
showsetting('settings_styles_sitemessage_time', 'settingsnew[sitemessage][time]', $settings['sitemessage']['time'], 'text');
showsetting('settings_styles_sitemessage_register', 'settingsnew[sitemessage][register]', $settings['sitemessage']['register'], 'textarea');
showsetting('settings_styles_sitemessage_login', 'settingsnew[sitemessage][login]', $settings['sitemessage']['login'], 'textarea');
showsetting('settings_styles_sitemessage_newthread', 'settingsnew[sitemessage][newthread]', $settings['sitemessage']['newthread'], 'textarea');
showsetting('settings_styles_sitemessage_reply', 'settingsnew[sitemessage][reply]', $settings['sitemessage']['reply'], 'textarea');
showtagfooter('tbody');
showtablefooter();
showtableheader('', 'notop');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'seo') {
showtips('settings_tips');
showtableheader();
showtitle('settings_seo');
showsetting('settings_seo_archiverstatus', array('settingsnew[archiverstatus]', array(
array(0, $lang['settings_seo_archiverstatus_none']),
array(1, $lang['settings_seo_archiverstatus_full']),
array(2, $lang['settings_seo_archiverstatus_searchengine']),
array(3, $lang['settings_seo_archiverstatus_browser']))), $settings['archiverstatus'], 'mradio');
showsetting('settings_seo_rewritestatus', array('settingsnew[rewritestatus]', array(
$lang['settings_seo_rewritestatus_forumdisplay'],
$lang['settings_seo_rewritestatus_viewthread'],
$lang['settings_seo_rewritestatus_space'],
$lang['settings_seo_rewritestatus_tag'],
$lang['settings_seo_rewritestatus_archiver'])), $settings['rewritestatus'], 'binmcheckbox');
showsetting('settings_seo_rewritecompatible', 'settingsnew[rewritecompatible]', $settings['rewritecompatible'], 'radio');
showsetting('settings_seo_seotitle', 'settingsnew[seotitle]', $settings['seotitle'], 'text');
showsetting('settings_seo_seokeywords', 'settingsnew[seokeywords]', $settings['seokeywords'], 'text');
showsetting('settings_seo_seodescription', 'settingsnew[seodescription]', $settings['seodescription'], 'text');
showsetting('settings_seo_seohead', 'settingsnew[seohead]', $settings['seohead'], 'textarea');
showtitle('nav_settings_sitemap');
showsetting('settings_seo_sitemap_baidu_open', 'settingsnew[baidusitemap]', $settings['baidusitemap'], 'radio', '', 1);
showsetting('settings_seo_sitemap_baidu_expire', 'settingsnew[baidusitemap_life]', $settings['baidusitemap_life'], 'text');
showtagfooter('tbody');
} elseif($operation == 'cachethread') {
include_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect = '<select name="fids[]" multiple="multiple" size="10"><option value="all">'.$lang['all'].'</option><option value=""> </option>'.forumselect().'</select>';
showtableheader();
showtitle('settings_cachethread');
showsetting('settings_cachethread_indexlife', 'settingsnew[cacheindexlife]', $settings['cacheindexlife'], 'text');
showsetting('settings_cachethread_life', 'settingsnew[cachethreadlife]', $settings['cachethreadlife'], 'text');
showsetting('settings_cachethread_dir', 'settingsnew[cachethreaddir]', $settings['cachethreaddir'], 'text');
showtitle('settings_cachethread_coefficient_set');
showsetting('settings_cachethread_coefficient', 'settingsnew[threadcaches]', '', "<input type=\"text\" class=\"txt\" size=\"30\" name=\"settingsnew[threadcaches]\" value=\"\">");
showsetting('settings_cachethread_coefficient_forum', '', '', $forumselect);
} elseif($operation == 'serveropti') {
$checkgzipfunc = !function_exists('ob_gzhandler') ? 1 : 0;
showtips('settings_tips');
showtableheader();
showtitle('settings_serveropti');
showsetting('settings_serveropti_gzipcompress', 'settingsnew[gzipcompress]', $settings['gzipcompress'], 'radio', $checkgzipfunc);
showsetting('settings_serveropti_delayviewcount', array('settingsnew[delayviewcount]', array(
array(0, lang('none')),
array(1, lang('settings_serveropti_delayviewcount_thread')),
array(2, lang('settings_serveropti_delayviewcount_attach')),
array(3, lang('settings_serveropti_delayviewcount_thread_attach'))
)), $settings['delayviewcount'], 'select');
showsetting('settings_serveropti_nocacheheaders', 'settingsnew[nocacheheaders]', $settings['nocacheheaders'], 'radio');
showsetting('settings_serveropti_transsidstatus', 'settingsnew[transsidstatus]', $settings['transsidstatus'], 'radio');
showsetting('settings_serveropti_maxonlines', 'settingsnew[maxonlines]', $settings['maxonlines'], 'text');
showsetting('settings_serveropti_onlinehold', 'settingsnew[onlinehold]', $settings['onlinehold'], 'text');
showsetting('settings_serveropti_loadctrl', 'settingsnew[loadctrl]', $settings['loadctrl'], 'text');
showsetting('settings_serveropti_floodctrl', 'settingsnew[floodctrl]', $settings['floodctrl'], 'text');
showtitle('nav_settings_search');
showsetting('settings_serveropti_searchctrl', 'settingsnew[searchctrl]', $settings['searchctrl'], 'text');
showsetting('settings_serveropti_maxspm', 'settingsnew[maxspm]', $settings['maxspm'], 'text');
showsetting('settings_serveropti_maxsearchresults', 'settingsnew[maxsearchresults]', $settings['maxsearchresults'], 'text');
} elseif($operation == 'editor') {
$editoroptions = str_pad(decbin($settings['editoroptions']), 2, 0, STR_PAD_LEFT);
$settings['defaulteditormode'] = $editoroptions{0};
$settings['allowswitcheditor'] = $editoroptions{1};
showtableheader();
showsetting('settings_editor_mode_default', array('settingsnew[defaulteditormode]', array(
array(0, $lang['settings_editor_mode_discuzcode']),
array(1, $lang['settings_editor_mode_wysiwyg']))), $settings['defaulteditormode'], 'mradio');
showsetting('settings_editor_swtich_enable', 'settingsnew[allowswitcheditor]', $settings['allowswitcheditor'], 'radio');
showsetting('settings_editor_smthumb', 'settingsnew[smthumb]', $settings['smthumb'], 'text');
showsetting('settings_editor_smcols', 'settingsnew[smcols]', $settings['smcols'], 'text');
showsetting('settings_editor_smrows', 'settingsnew[smrows]', $settings['smrows'], 'text');
showtablefooter();
} elseif($operation == 'functions') {
showtips('settings_tips', 'stat_tips', $anchor == 'stat');
showtips('settings_tips', 'mod_tips', $anchor == 'mod');
showtips('settings_tips', 'other_tips', $anchor == 'other');
showtableheader('', 'nobottom', 'id="stat"'.($anchor != 'stat' ? ' style="display: none"' : ''));
showsetting('settings_functions_stat_status', 'settingsnew[statstatus]', $settings['statstatus'], 'radio');
showsetting('settings_functions_stat_cachelife', 'settingsnew[statscachelife]', $settings['statscachelife'], 'text');
showsetting('settings_functions_stat_pvfrequence', 'settingsnew[pvfrequence]', $settings['pvfrequence'], 'text');
showsetting('settings_functions_stat_oltimespan', 'settingsnew[oltimespan]', $settings['oltimespan'], 'text');
showtablefooter();
showtableheader('', 'nobottom', 'id="mod"'.($anchor != 'mod' ? ' style="display: none"' : ''));
showsetting('settings_functions_mod_status', 'settingsnew[modworkstatus]', $settings['modworkstatus'], 'radio');
showsetting('settings_functions_mod_maxmodworksmonths', 'settingsnew[maxmodworksmonths]', $settings['maxmodworksmonths'], 'text');
showsetting('settings_functions_mod_myfunction_savetime', 'settingsnew[myrecorddays]', $settings['myrecorddays'], 'text');
showsetting('settings_functions_mod_losslessdel', 'settingsnew[losslessdel]', $settings['losslessdel'], 'text');
showsetting('settings_functions_mod_reasons', 'settingsnew[modreasons]', $settings['modreasons'], 'textarea');
showsetting('settings_functions_mod_bannedmessages', array('settingsnew[bannedmessages]', array(
$lang['settings_functions_mod_bannedmessages_thread'],
$lang['settings_functions_mod_bannedmessages_avatar'],
$lang['settings_functions_mod_bannedmessages_signature'])), $settings['bannedmessages'], 'binmcheckbox');
showsetting('settings_functions_mod_warninglimit', 'settingsnew[warninglimit]', $settings['warninglimit'], 'text');
showsetting('settings_functions_mod_warningexpiration', 'settingsnew[warningexpiration]', $settings['warningexpiration'], 'text');
showtableheader('', 'nobottom', 'id="tags"'.($anchor != 'tags' ? ' style="display: none"' : ''));
showsetting('settings_functions_tags_status', array('settingsnew[tagstatus]', array(
array(0, $lang['settings_functions_tags_status_none'], array('tagext' => 'none')),
array(1, $lang['settings_functions_tags_status_use'], array('tagext' => '')),
array(2, $lang['settings_functions_tags_status_quired'], array('tagext' => ''))
)), $settings['tagstatus'], 'mradio');
showtagheader('tbody', 'tagext', $settings['tagstatus'], 'sub');
showsetting('settings_functions_tags_viewthtrad_hottags', 'settingsnew[viewthreadtags]', $settings['viewthreadtags'], 'text');
showtagfooter('tbody');
showtablefooter();
showtableheader('', 'nobottom', 'id="other"'.($anchor != 'other' ? ' style="display: none"' : ''));
showsetting('settings_functions_other_pwdsafety', 'settingsnew[pwdsafety]', $settings['pwdsafety'], 'radio');
showsetting('settings_functions_other_rssstatus', 'settingsnew[rssstatus]', $settings['rssstatus'], 'radio');
showsetting('settings_functions_other_rssttl', 'settingsnew[rssttl]', $settings['rssttl'], 'text');
showsetting('settings_functions_other_send_birthday', 'settingsnew[bdaystatus]', $settings['bdaystatus'], 'radio');
showsetting('settings_functions_other_debug', 'settingsnew[debug]', $settings['debug'], 'radio');
showsetting('settings_functions_other_activity_type', 'settingsnew[activitytype]', $settings['activitytype'], 'textarea');
showtablefooter();
showtableheader('', 'notop');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'permissions') {
showtableheader();
showsetting('settings_permissions_memliststatus', 'settingsnew[memliststatus]', $settings['memliststatus'], 'radio');
showsetting('settings_permissions_reportpost', 'settingsnew[reportpost]', $settings['reportpost'], 'radio');
showsetting('settings_permissions_minpostsize', 'settingsnew[minpostsize]', $settings['minpostsize'], 'text');
showsetting('settings_permissions_maxpostsize', 'settingsnew[maxpostsize]', $settings['maxpostsize'], 'text');
showsetting('settings_permissions_favorite_storage', 'settingsnew[maxfavorites]', $settings['maxfavorites'], 'text');
showsetting('settings_permissions_subscriptions', 'settingsnew[maxsubscriptions]', $settings['maxsubscriptions'], 'text');
showsetting('settings_permissions_maxpolloptions', 'settingsnew[maxpolloptions]', $settings['maxpolloptions'], 'text');
showsetting('settings_permissions_edittimelimit', 'settingsnew[edittimelimit]', $settings['edittimelimit'], 'text');
showsetting('settings_permissions_editby', 'settingsnew[editedby]', $settings['editedby'], 'radio');
showtitle('nav_settings_rate');
showsetting('settings_permissions_karmaratelimit', 'settingsnew[karmaratelimit]', $settings['karmaratelimit'], 'text');
showsetting('settings_permissions_modratelimit', 'settingsnew[modratelimit]', $settings['modratelimit'], 'radio');
showsetting('settings_permissions_dupkarmarate', 'settingsnew[dupkarmarate]', $settings['dupkarmarate'], 'radio');
} elseif($operation == 'credits') {
showtips('settings_credits_tips');
if(!empty($projectid)) {
$settings = @array_merge($settings, unserialize($db->result_first("SELECT value FROM {$tablepre}projects WHERE id='$projectid'")));
}
$projectselect = "<select name=\"projectid\" onchange=\"window.location='$BASESCRIPT?action=settings&operation=credits&projectid='+this.options[this.options.selectedIndex].value\"><option value=\"0\" selected=\"selected\">".$lang['none']."</option>";
$query = $db->query("SELECT id, name FROM {$tablepre}projects WHERE type='extcredit'");
while($project = $db->fetch_array($query)) {
$projectselect .= "<option value=\"$project[id]\" ".($project['id'] == $projectid ? 'selected="selected"' : NULL).">$project[name]</option>\n";
}
$projectselect .= '</select>';
showtableheader('settings_credits_scheme_title', 'nobottom');
showsetting('settings_credits_scheme', '', '', $projectselect);
showtablefooter();
echo <<<EOT
<script type="text/JavaScript">
function switchpolicy(obj, col) {
var status = !obj.checked;
$("policy" + col).disabled = status;
var policytable = $("policytable");
for(var row=2; row<14; row++) {
if(is_opera) {
policytable.rows[row].cells[col].firstChild.disabled = true;
} else {
policytable.rows[row].cells[col].disabled = status;
}
}
}
</script>
EOT;
showtableheader('settings_credits_extended', 'fixpadding');
showsubtitle(array('settings_credits_available', 'credits_id', 'credits_img', 'credits_title', 'credits_unit', 'settings_credits_ratio', 'settings_credits_init', 'credits_inport', 'credits_import'), '');
$settings['extcredits'] = unserialize($settings['extcredits']);
$settings['initcredits'] = explode(',', $settings['initcredits']);
for($i = 1; $i <= 8; $i++) {
showtablerow('', array('width="40"', 'class="td22"', 'class="td22"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"settingsnew[extcredits][$i][available]\" value=\"1\" ".($settings['extcredits'][$i]['available'] ? 'checked' : '')." onclick=\"switchpolicy(this, $i)\">",
'extcredits'.$i,
"<input type=\"text\" class=\"txt\" size=\"8\" name=\"settingsnew[extcredits][$i][img]\" value=\"{$settings['extcredits'][$i]['img']}\">",
"<input type=\"text\" class=\"txt\" size=\"8\" name=\"settingsnew[extcredits][$i][title]\" value=\"{$settings['extcredits'][$i]['title']}\">",
"<input type=\"text\" class=\"txt\" size=\"5\" name=\"settingsnew[extcredits][$i][unit]\" value=\"{$settings['extcredits'][$i]['unit']}\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"settingsnew[extcredits][$i][ratio]\" value=\"".(float)$settings['extcredits'][$i]['ratio']."\" onkeyup=\"if(this.value != '0' && \$('allowexchangeout$i').checked == false && \$('allowexchangein$i').checked == false) {\$('allowexchangeout$i').checked = true;\$('allowexchangein$i').checked = true;} else if(this.value == '0') {\$('allowexchangeout$i').checked = false;\$('allowexchangein$i').checked = false;}\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"settingsnew[initcredits][$i]\" value=\"".intval($settings['initcredits'][$i])."\">",
"<input class=\"checkbox\" type=\"checkbox\" size=\"3\" name=\"settingsnew[extcredits][$i][allowexchangeout]\" value=\"1\" ".($settings['extcredits'][$i]['allowexchangeout'] ? 'checked' : '')." id=\"allowexchangeout$i\">",
"<input class=\"checkbox\" type=\"checkbox\" size=\"3\" name=\"settingsnew[extcredits][$i][allowexchangein]\" value=\"1\" ".($settings['extcredits'][$i]['allowexchangein'] ? 'checked' : '')." id=\"allowexchangein$i\">"
));
}
showtablerow('', 'colspan="10" class="lineheight"', $lang['settings_credits_extended_comment']);
showtablefooter();
showtableheader('settings_credits_policy', 'fixpadding', 'id="policytable"');
echo '<tr><th valign="top">'.$lang['credits_id'].'</th>';
$settings['creditspolicy'] = unserialize($settings['creditspolicy']);
for($i = 1; $i <= 8; $i++) {
echo "<th id=\"policy$i\" ".($settings['extcredits'][$i]['available'] ? '' : 'disabled')." valign=\"top\"> extcredits$i<br />".($settings['extcredits'][$i]['title'] ? '('.$settings['extcredits'][$i]['title'].')' : '')."</th>";
}
echo '</tr>';
foreach(array('post', 'reply', 'digest', 'postattach', 'getattach', 'sendpm', 'search', 'promotion_visit', 'promotion_register', 'tradefinished', 'votepoll', 'lowerlimit') as $policy) {
showtablerow('title="'.$lang['settings_credits_policy_'.$policy.'_comment'].'"', array('class="td22"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"', 'class="td28"'), creditsrow($policy));
}
showtablerow('', 'class="lineheight" colspan="9"', $lang['settings_credits_policy_comment']);
showtablefooter();
showtableheader('settings_credits', 'fixpadding');
showsetting('settings_credits_formula', 'settingsnew[creditsformula]', $settings['creditsformula'], 'textarea');
$settings['creditstrans'] = explode(',', $settings['creditstrans']);
$creditstrans = array();
for($si = 0; $si < 5; $si++) {
$creditstrans[$si] = '';
for($i = 0; $i <= 8; $i++) {
$creditstrans[$si] .= '<option value="'.$i.'" '.($i == $settings['creditstrans'][$si] ? 'selected' : '').'>'.($i ? 'extcredits'.$i.($settings['extcredits'][$i]['title'] ? '('.$settings['extcredits'][$i]['title'].')' : '') : ($si > 0 ? $lang['settings_credits_trans_used'] : $lang['none'])).'</option>';
}
}
showsetting('settings_credits_trans', '', '', '<select onchange="if(this.value > 0) {$(\'creditstransextra\').style.display = \'\';} else {$(\'creditstransextra\').style.display = \'none\';}" name="settingsnew[creditstrans][0]">'.$creditstrans[0].'</select>');
showtagheader('tbody', 'creditstransextra', $settings['creditstrans'][0], 'sub');
showsetting('settings_credits_trans1', '', '' ,'<select name="settingsnew[creditstrans][1]">'.$creditstrans[1].'</select>');
showsetting('settings_credits_trans2', '', '' ,'<select name="settingsnew[creditstrans][2]">'.$creditstrans[2].'</select>');
showsetting('settings_credits_trans3', '', '' ,'<select name="settingsnew[creditstrans][3]">'.$creditstrans[3].'</select>');
showsetting('settings_credits_trans4', '', '' ,'<select name="settingsnew[creditstrans][4]">'.$creditstrans[4].'</select>');
showtagfooter('tbody');
showsetting('settings_credits_tax', 'settingsnew[creditstax]', $settings['creditstax'], 'text');
showsetting('settings_credits_mintransfer', 'settingsnew[transfermincredits]', $settings['transfermincredits'], 'text');
showsetting('settings_credits_minexchange', 'settingsnew[exchangemincredits]', $settings['exchangemincredits'], 'text');
showsetting('settings_credits_maxincperthread', 'settingsnew[maxincperthread]', $settings['maxincperthread'], 'text');
showsetting('settings_credits_maxchargespan', 'settingsnew[maxchargespan]', $settings['maxchargespan'], 'text');
$extbutton = ' <input name="projectsave" type="hidden" value="0"><input type="button" class="btn" onclick="$(\'cpform\').projectsave.value=1;$(\'cpform\').settingsubmit.click()" value="'.$lang['saveconf'].'">';
} elseif($operation == 'mail' && $isfounder) {
$settings['mail'] = unserialize($settings['mail']);
//showtableheader();
showtableheader('', '', 'id="mailsettings"'.($anchor != 'settings' ? ' style="display: none"' : ''));
showsetting('settings_mail_settings_send', array('settingsnew[mail][mailsend]', array(
array(1, $lang['settings_mail_settings_send_1'], array('hidden1' => 'none', 'hidden2' => 'none')),
array(2, $lang['settings_mail_settings_send_2'], array('hidden1' => '', 'hidden2' => '')),
array(3, $lang['settings_mail_settings_send_3'], array('hidden1' => '', 'hidden2' => 'none'))
)), $settings['mail']['mailsend'], 'mradio');
showtagheader('tbody', 'hidden1', $settings['mail']['mailsend'] != 1, 'sub');
showsetting('settings_mail_settings_server', 'settingsnew[mail][server]', $settings['mail']['server'], 'text');
showsetting('settings_mail_settings_port', 'settingsnew[mail][port]', $settings['mail']['port'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'hidden2', $settings['mail']['mailsend'] == 2, 'sub');
showsetting('settings_mail_settings_auth', 'settingsnew[mail][auth]', $settings['mail']['auth'], 'radio');
showsetting('settings_mail_settings_from', 'settingsnew[mail][from]', $settings['mail']['from'], 'text');
showsetting('settings_mail_settings_username', 'settingsnew[mail][auth_username]', $settings['mail']['auth_username'], 'text');
showsetting('settings_mail_settings_password', 'settingsnew[mail][auth_password]', $settings['mail']['auth_password'], 'text');
showtagfooter('tbody');
showsetting('settings_mail_settings_delimiter', array('settingsnew[mail][maildelimiter]', array(
array(1, $lang['settings_mail_settings_delimiter_crlf']),
array(0, $lang['settings_mail_settings_delimiter_lf']),
array(2, $lang['settings_mail_settings_delimiter_cr']))), $settings['mail']['maildelimiter'], 'mradio');
showsetting('settings_mail_settings_includeuser', 'settingsnew[mail][mailusername]', $settings['mail']['mailusername'], 'radio');
showsetting('settings_mail_settings_silent', 'settingsnew[mail][sendmail_silent]', $settings['mail']['sendmail_silent'], 'radio');
showsubmit('settingsubmit');
showtablefooter();
showtableheader('', '', 'id="mailcheck"'.($anchor != 'check' ? ' style="display: none"' : ''));
showsetting('settings_mail_check_test_from', 'test_from', '', 'text');
showsetting('settings_mail_check_test_to', 'test_to', '', 'textarea');
showsubmit('', '', '<input type="submit" class="btn" name="mailcheck" value="'.lang('settings_mail_check_submit').'" onclick="this.form.action=\''.$BASESCRIPT.'?action=checktools&operation=mailcheck&frame=no\';this.form.target=\'mailcheckiframe\'">', '<iframe name="mailcheckiframe" style="display: none"></iframe>');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'sec') {
echo '<script type="text/JavaScript">
function updateseccode(op) {
if(isUndefined(op)) {
ajaxget(\'ajax.php?action=updateseccode\', \'seccodeimage\', \'seccodeimage\');
} else {
window.document.seccodeplayer.SetVariable("isPlay", "1");
}
}
</script>';
$checksc = array();
$settings['seccodedata'] = unserialize($settings['seccodedata']);
$seccodetypearray = array(
array(0, lang('settings_sec_seccode_type_image'), array('seccodeimageext' => '', 'seccodeimagewh' => '')),
array(1, lang('settings_sec_seccode_type_chnfont'), array('seccodeimageext' => '', 'seccodeimagewh' => '')),
array(2, lang('settings_sec_seccode_type_flash'), array('seccodeimageext' => 'none', 'seccodeimagewh' => '')),
array(3, lang('settings_sec_seccode_type_wav'), array('seccodeimageext' => 'none', 'seccodeimagewh' => 'none')),
);
showtips('settings_sec_code_tips', 'seccode_tips', $anchor == 'seccode');
showtips('settings_sec_qaa_tips', 'secqaa_tips', $anchor == 'secqaa');
showtableheader('', '', 'id="seclevel"'.($anchor != 'seclevel' ? ' style="display: none"' : ''));
showsetting('settings_sec_seclevel', array('settingsnew[seclevel]', array(
array(0, $lang['settings_sec_seclevel_lower']),
array(1, $lang['settings_sec_seclevel_higher'])
)), $settings['seclevel'], 'mradio');
showsubmit('settingsubmit');
showtablefooter();
showtableheader('', '', 'id="seccode"'.($anchor != 'seccode' ? ' style="display: none"' : ''));
showsetting('settings_sec_seccode_status', array('settingsnew[seccodestatus]', array(
lang('settings_sec_seccode_status_register'),
lang('settings_sec_seccode_status_login'),
lang('settings_sec_seccode_status_post'),
lang('settings_sec_seccode_status_profile')
)), $settings['seccodestatus'], 'binmcheckbox');
showsetting('settings_sec_seccode_minposts', 'settingsnew[seccodedata][minposts]', $settings['seccodedata']['minposts'], 'text');
showsetting('settings_sec_seccode_loginfailedcount', 'settingsnew[seccodedata][loginfailedcount]', $settings['seccodedata']['loginfailedcount'], 'radio');
showsetting('settings_sec_seccode_type', array('settingsnew[seccodedata][type]', $seccodetypearray), $settings['seccodedata']['type'], 'mradio');
showtagheader('tbody', 'seccodeimagewh', $settings['seccodedata']['type'] != 3, 'sub');
showsetting('settings_sec_seccode_width', 'settingsnew[seccodedata][width]', $settings['seccodedata']['width'], 'text');
showsetting('settings_sec_seccode_height', 'settingsnew[seccodedata][height]', $settings['seccodedata']['height'], 'text');
showtagfooter('tbody');
showtagheader('tbody', 'seccodeimageext', $settings['seccodedata']['type'] != 2 && $settings['seccodedata']['type'] != 3, 'sub');
showsetting('settings_sec_seccode_background', 'settingsnew[seccodedata][background]', $settings['seccodedata']['background'], 'radio');
showsetting('settings_sec_seccode_adulterate', 'settingsnew[seccodedata][adulterate]', $settings['seccodedata']['adulterate'], 'radio');
showsetting('settings_sec_seccode_ttf', 'settingsnew[seccodedata][ttf]', $settings['seccodedata']['ttf'], 'radio', !function_exists('imagettftext'));
showsetting('settings_sec_seccode_angle', 'settingsnew[seccodedata][angle]', $settings['seccodedata']['angle'], 'radio');
showsetting('settings_sec_seccode_color', 'settingsnew[seccodedata][color]', $settings['seccodedata']['color'], 'radio');
showsetting('settings_sec_seccode_size', 'settingsnew[seccodedata][size]', $settings['seccodedata']['size'], 'radio');
showsetting('settings_sec_seccode_shadow', 'settingsnew[seccodedata][shadow]', $settings['seccodedata']['shadow'], 'radio');
showsetting('settings_sec_seccode_animator', 'settingsnew[seccodedata][animator]', $settings['seccodedata']['animator'], 'radio', !function_exists('imagegif'));
showtagfooter('tbody');
showsubmit('settingsubmit');
showtablefooter();
echo '<script language="JavaScript">updateseccode()</script>';
$settings['secqaa'] = unserialize($settings['secqaa']);
$page = max(1, intval($page));
$start_limit = ($page - 1) * 10;
$secqaanums = $db->result_first("SELECT COUNT(*) FROM {$tablepre}itempool");
$multipage = multi($secqaanums, 10, $page, $BASESCRIPT.'?action=settings&operation=sec&anchor=secqaa');
$query = $db->query("SELECT * FROM {$tablepre}itempool LIMIT $start_limit, 10");
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1,''], [1,'<input name="newquestion[]" type="text" class="txt">','td26'], [1, '<input name="newanswer[]" type="text" class="txt">']],
];
</script>
EOT;
showtagheader('div', 'secqaa', $anchor == 'secqaa');
showtableheader('settings_sec_secqaa', 'nobottom');
showsetting('settings_sec_secqaa_status', array('settingsnew[secqaa][status]', array(
lang('settings_sec_seccode_status_register'),
lang('settings_sec_seccode_status_post')
)), $settings['secqaa']['status'], 'binmcheckbox');
showsetting('settings_sec_secqaa_minposts', 'settingsnew[secqaa][minposts]', $settings['secqaa']['minposts'], 'text');
showtablefooter();
showtableheader('settings_sec_secqaa_qaa', 'noborder fixpadding');
showsubtitle(array('', 'settings_sec_secqaa_question', 'settings_sec_secqaa_answer'));
while($item = $db->fetch_array($query)) {
showtablerow('', array('', 'class="td26"'), array(
'<input class="checkbox" type="checkbox" name="delete[]" value="'.$item['id'].'">',
'<input type="text" class="txt" name="question['.$item['id'].']" value="'.dhtmlspecialchars($item['question']).'" class="txtnobd" onblur="this.className=\'txtnobd\'" onfocus="this.className=\'txt\'">',
'<input type="text" class="txt" name="answer['.$item['id'].']" value="'.$item['answer'].'" class="txtnobd" onblur="this.className=\'txtnobd\'" onfocus="this.className=\'txt\'">'
));
}
echo '<tr><td></td><td class="td26"><div><a href="###" onclick="addrow(this, 0)" class="addtr">'.$lang['settings_sec_secqaa_add'].'</a></div></td><td></td></tr>';
showsubmit('settingsubmit', 'submit', 'del', '', $multipage);
showtablefooter();
showtagfooter('div');
showformfooter();
cpfooter();
exit;
} elseif($operation == 'datetime') {
$checktimeformat = array($settings['timeformat'] == 'H:i' ? 24 : 12 => 'checked');
$settings['userdateformat'] = dateformat($settings['userdateformat']);
$settings['dateformat'] = dateformat($settings['dateformat']);
showtableheader();
showtitle('settings_datetime_format');
showsetting('settings_datetime_dateformat', 'settingsnew[dateformat]', $settings['dateformat'], 'text');
showsetting('settings_datetime_timeformat', '', '', '<input class="radio" type="radio" name="settingsnew[timeformat]" value="24" '.$checktimeformat[24].'> 24 '.$lang['hour'].' <input class="radio" type="radio" name="settingsnew[timeformat]" value="12" '.$checktimeformat[12].'> 12 '.$lang['hour'].'');
showsetting('settings_datetime_dateconvert', 'settingsnew[dateconvert]', $settings['dateconvert'], 'radio');
showsetting('settings_datetime_timeoffset', 'settingsnew[timeoffset]', $settings['timeoffset'], 'text');
showsetting('settings_datetime_customformat', 'settingsnew[userdateformat]', $settings['userdateformat'], 'textarea');
showtitle('settings_datetime_periods');
showsetting('settings_datetime_visitbanperiods', 'settingsnew[visitbanperiods]', $settings['visitbanperiods'], 'textarea');
showsetting('settings_datetime_postbanperiods', 'settingsnew[postbanperiods]', $settings['postbanperiods'], 'textarea');
showsetting('settings_datetime_postmodperiods', 'settingsnew[postmodperiods]', $settings['postmodperiods'], 'textarea');
showsetting('settings_datetime_ban_downtime', 'settingsnew[attachbanperiods]', $settings['attachbanperiods'], 'textarea');
showsetting('settings_datetime_searchbanperiods', 'settingsnew[searchbanperiods]', $settings['searchbanperiods'], 'textarea');
} elseif($operation == 'attach') {
$checkwm = array($settings['watermarkstatus'] => 'checked');
$checkmkdirfunc = !function_exists('mkdir') ? 'disabled' : '';
$settings['watermarktext'] = unserialize($settings['watermarktext']);
$settings['watermarktext']['fontpath'] = str_replace(array('ch/', 'en/'), '', $settings['watermarktext']['fontpath']);
$fontlist = '<select name="settingsnew[watermarktext][fontpath]">';
$dir = opendir(DISCUZ_ROOT.'./images/fonts/en');
while($entry = readdir($dir)) {
if(in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
$fontlist .= '<option value="'.$entry.'"'.($entry == $settings['watermarktext']['fontpath'] ? ' selected>' : '>').$entry.'</option>';
}
}
$dir = opendir(DISCUZ_ROOT.'./images/fonts/ch');
while($entry = readdir($dir)) {
if(in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
$fontlist .= '<option value="'.$entry.'"'.($entry == $settings['watermarktext']['fontpath'] ? ' selected>' : '>').$entry.'</option>';
}
}
$fontlist .= '</select>';
showtableheader('', '', 'id="basic"'.($anchor != 'basic' ? ' style="display: none"' : ''));
showsetting('settings_attach_basic_dir', 'settingsnew[attachdir]', $settings['attachdir'], 'text');
showsetting('settings_attach_basic_url', 'settingsnew[attachurl]', $settings['attachurl'], 'text');
showsetting('settings_attach_basic_imgpost', 'settingsnew[attachimgpost]', $settings['attachimgpost'], 'radio');
showsetting('settings_attach_basic_save', array('settingsnew[attachsave]', array(
array(0, $lang['settings_attach_basic_save_default']),
array(1, $lang['settings_attach_basic_save_forum']),
array(2, $lang['settings_attach_basic_save_type']),
array(3, $lang['settings_attach_basic_save_month']),
array(4, $lang['settings_attach_basic_save_day'])
)), $settings['attachsave'], 'select', $checkmkdirfunc);
showsetting('settings_attach_basic_swfupload', 'settingsnew[swfupload]', $settings['swfupload'], 'radio');
showsubmit('settingsubmit');
showtablefooter();
showtableheader('', '', 'id="image"'.($anchor != 'image' ? ' style="display: none"' : ''));
showsetting('settings_attach_image_lib', array('settingsnew[imagelib]', array(
array(0, $lang['settings_attach_image_watermarktype_GD'], array('imagelibext' => 'none')),
array(1, $lang['settings_attach_image_watermarktype_IM'], array('imagelibext' => ''))
)), $settings['imagelib'], 'mradio');
showtagheader('tbody', 'imagelibext', $settings['imagelib'], 'sub');
showsetting('settings_attach_image_impath', 'settingsnew[imageimpath]', $settings['imageimpath'], 'text');
showtagfooter('tbody');
showsetting('settings_attach_image_thumbstatus', array('settingsnew[thumbstatus]', array(
array(0, $lang['settings_attach_image_thumbstatus_none'], array('thumbext' => 'none')),
array(1, $lang['settings_attach_image_thumbstatus_add'], array('thumbext' => '')),
array(3, $lang['settings_attach_image_thumbstatus_addfix'], array('thumbext' => '')),
array(2, $lang['settings_attach_image_thumbstatus_replace'], array('thumbext' => ''))
)), $settings['thumbstatus'], 'mradio');
showtagheader('tbody', 'thumbext', $settings['thumbstatus'], 'sub');
showsetting('settings_attach_image_thumbquality', 'settingsnew[thumbquality]', $settings['thumbquality'], 'text');
showsetting('settings_attach_image_thumbwidthheight', array('settingsnew[thumbwidth]', 'settingsnew[thumbheight]'), array(intval($settings['thumbwidth']), intval($settings['thumbheight'])), 'multiply');
showtagfooter('tbody');
showsetting('settings_attach_image_watermarkstatus', '', '', '<table cellspacing="'.INNERBORDERWIDTH.'" cellpadding="'.TABLESPACE.'" style="margin-bottom: 3px; margin-top:3px;"><tr><td colspan="3"><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="0" '.$checkwm[0].'>'.$lang['settings_attach_image_watermarkstatus_none'].'</td></tr><tr><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="1" '.$checkwm[1].'> #1</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="2" '.$checkwm[2].'> #2</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="3" '.$checkwm[3].'> #3</td></tr><tr><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="4" '.$checkwm[4].'> #4</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="5" '.$checkwm[5].'> #5</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="6" '.$checkwm[6].'> #6</td></tr><tr><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="7" '.$checkwm[7].'> #7</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="8" '.$checkwm[8].'> #8</td><td><input class="radio" type="radio" name="settingsnew[watermarkstatus]" value="9" '.$checkwm[9].'> #9</td></tr></table>');
showsetting('settings_attach_image_watermarkminwidthheight', array('settingsnew[watermarkminwidth]', 'settingsnew[watermarkminheight]'), array(intval($settings['watermarkminwidth']), intval($settings['watermarkminheight'])), 'multiply');
showsetting('settings_attach_image_watermarktype', array('settingsnew[watermarktype]', array(
array(0, $lang['settings_attach_image_watermarktype_gif'], array('watermarktypeext' => 'none')),
array(1, $lang['settings_attach_image_watermarktype_png'], array('watermarktypeext' => 'none')),
array(2, $lang['settings_attach_image_watermarktype_text'], array('watermarktypeext' => ''))
)), $settings['watermarktype'], 'mradio');
showsetting('settings_attach_image_watermarktrans', 'settingsnew[watermarktrans]', $settings['watermarktrans'], 'text');
showsetting('settings_attach_image_watermarkquality', 'settingsnew[watermarkquality]', $settings['watermarkquality'], 'text');
showtagheader('tbody', 'watermarktypeext', $settings['watermarktype'] == 2, 'sub');
showsetting('settings_attach_image_watermarktext_text', 'settingsnew[watermarktext][text]', $settings['watermarktext']['text'], 'textarea');
showsetting('settings_attach_image_watermarktext_fontpath', '', '', $fontlist);
showsetting('settings_attach_image_watermarktext_size', 'settingsnew[watermarktext][size]', $settings['watermarktext']['size'], 'text');
showsetting('settings_attach_image_watermarktext_angle', 'settingsnew[watermarktext][angle]', $settings['watermarktext']['angle'], 'text');
showsetting('settings_attach_image_watermarktext_color', 'settingsnew[watermarktext][color]', $settings['watermarktext']['color'], 'color');
showsetting('settings_attach_image_watermarktext_shadowx', 'settingsnew[watermarktext][shadowx]', $settings['watermarktext']['shadowx'], 'text');
showsetting('settings_attach_image_watermarktext_shadowy', 'settingsnew[watermarktext][shadowy]', $settings['watermarktext']['shadowy'], 'text');
showsetting('settings_attach_image_watermarktext_shadowcolor', 'settingsnew[watermarktext][shadowcolor]', $settings['watermarktext']['shadowcolor'], 'color');
showsetting('settings_attach_image_watermarktext_imtranslatex', 'settingsnew[watermarktext][translatex]', $settings['watermarktext']['translatex'], 'text');
showsetting('settings_attach_image_watermarktext_imtranslatey', 'settingsnew[watermarktext][translatey]', $settings['watermarktext']['translatey'], 'text');
showsetting('settings_attach_image_watermarktext_imskewx', 'settingsnew[watermarktext][skewx]', $settings['watermarktext']['skewx'], 'text');
showsetting('settings_attach_image_watermarktext_imskewy', 'settingsnew[watermarktext][skewy]', $settings['watermarktext']['skewy'], 'text');
showtagfooter('tbody');
showsubmit('settingsubmit');
showtablefooter();
if($isfounder) {
$settings['ftp'] = unserialize($settings['ftp']);
$settings['ftp'] = is_array($settings['ftp']) ? $settings['ftp'] : array();
$settings['ftp']['password'] = authcode($settings['ftp']['password'], 'DECODE', md5($authkey));
$settings['ftp']['password'] = $settings['ftp']['password'] ? $settings['ftp']['password']{0}.'********'.$settings['ftp']['password']{strlen($settings['ftp']['password']) - 1} : '';
showtableheader('', '', 'id="remote"'.($anchor != 'remote' ? ' style="display: none"' : ''));
showsetting('settings_attach_remote_enabled', array('settingsnew[ftp][on]', array(
array(1, $lang['yes'], array('ftpext' => '', 'ftpcheckbutton' => '')),
array(0, $lang['no'], array('ftpext' => 'none', 'ftpcheckbutton' => 'none'))
), TRUE), $settings['ftp']['on'], 'mradio');
showtagheader('tbody', 'ftpext', $settings['ftp']['on'], 'sub');
showsetting('settings_attach_remote_enabled_ssl', 'settingsnew[ftp][ssl]', $settings['ftp']['ssl'], 'radio');
showsetting('settings_attach_remote_ftp_host', 'settingsnew[ftp][host]', $settings['ftp']['host'], 'text');
showsetting('settings_attach_remote_ftp_port', 'settingsnew[ftp][port]', $settings['ftp']['port'], 'text');
showsetting('settings_attach_remote_ftp_user', 'settingsnew[ftp][username]', $settings['ftp']['username'], 'text');
showsetting('settings_attach_remote_ftp_pass', 'settingsnew[ftp][password]', $settings['ftp']['password'], 'text');
showsetting('settings_attach_remote_ftp_pasv', 'settingsnew[ftp][pasv]', $settings['ftp']['pasv'], 'radio');
showsetting('settings_attach_remote_dir', 'settingsnew[ftp][attachdir]', $settings['ftp']['attachdir'], 'text');
showsetting('settings_attach_remote_url', 'settingsnew[ftp][attachurl]', $settings['ftp']['attachurl'], 'text');
showsetting('settings_attach_remote_timeout', 'settingsnew[ftp][timeout]', $settings['ftp']['timeout'], 'text');
showsetting('settings_attach_remote_mirror', array('settingsnew[ftp][mirror]', array(
array(1, lang('settings_attach_remote_mirror_1')),
//array(2, lang('settings_attach_remote_mirror_2')),
array(0, lang('settings_attach_remote_mirror_0'))
)), intval($settings['ftp']['mirror']), 'mradio');
showsetting('settings_attach_remote_allowedexts', 'settingsnew[ftp][allowedexts]', $settings['ftp']['allowedexts'], 'textarea');
showsetting('settings_attach_remote_disallowedexts', 'settingsnew[ftp][disallowedexts]', $settings['ftp']['disallowedexts'], 'textarea');
showsetting('settings_attach_remote_minsize', 'settingsnew[ftp][minsize]', $settings['ftp']['minsize'], 'text');
showtagfooter('tbody');
showsubmit('settingsubmit', 'submit', '', '<span id="ftpcheckbutton" style="display: '.($settings['ftp']['on'] ? '' : 'none').'"><input type="submit" class="btn" name="ftpcheck" value="'.$lang['settings_attach_remote_ftpcheck'].'" onclick="this.form.action=\''.$BASESCRIPT.'?action=checktools&operation=ftpcheck&frame=no\';this.form.target=\'ftpcheckiframe\';"></span><iframe name="ftpcheckiframe" style="display: none"></iframe>');
showtablefooter();
}
showtableheader('', '', 'id="antileech"'.($anchor != 'antileech' ? ' style="display: none"' : ''));
showsetting('settings_attach_antileech_expire', 'settingsnew[attachexpire]', $settings['attachexpire'], 'text');
showsetting('settings_attach_antileech_refcheck', 'settingsnew[attachrefcheck]', $settings['attachrefcheck'], 'radio');
showsetting('settings_attach_antileech_remote_hide_dir', 'settingsnew[ftp][hideurl]', $settings['ftp']['hideurl'], 'radio');
showsubmit('settingsubmit');
showtablefooter();
showformfooter();
cpfooter();
exit;
} elseif($operation == 'wap') {
$settings['wapdateformat'] = dateformat($settings['wapdateformat']);
showtableheader();
showsetting('settings_wap_status', 'settingsnew[wapstatus]', $settings['wapstatus'], 'radio', '', 1);
showsetting('settings_wap_register', 'settingsnew[wapregister]', $settings['wapregister'], 'radio');
showsetting('settings_wap_charset', array('settingsnew[wapcharset]', array(
array(1, 'UTF-8'),
array(2, 'UNICODE'))), $settings['wapcharset'], 'mradio');
showsetting('settings_wap_tpp', 'settingsnew[waptpp]', $settings['waptpp'], 'text');
showsetting('settings_wap_ppp', 'settingsnew[wapppp]', $settings['wapppp'], 'text');
showsetting('settings_wap_dateformat', 'settingsnew[wapdateformat]', $settings['wapdateformat'], 'text');
showsetting('settings_wap_mps', 'settingsnew[wapmps]', $settings['wapmps'], 'text');
showtagfooter('tbody');
} elseif($operation == 'uc' && $isfounder) {
$disable = !is_writeable('./config.inc.php');
showtips('settings_uc_tips');
showtableheader();
showsetting('settings_uc_appid', 'settingsnew[uc][appid]', UC_APPID, 'text', $disable);
showsetting('settings_uc_key', 'settingsnew[uc][key]', UC_KEY, 'text', $disable);
showsetting('settings_uc_api', 'settingsnew[uc][api]', UC_API, 'text', $disable);
showsetting('settings_uc_ip', 'settingsnew[uc][ip]', UC_IP, 'text', $disable);
showsetting('settings_uc_connect', array('settingsnew[uc][connect]', array(
array('mysql', $lang['settings_uc_connect_mysql'], array('ucmysql' => '')),
array('', $lang['settings_uc_connect_api'], array('ucmysql' => 'none')))), UC_CONNECT, 'mradio', $disable);
list($ucdbname, $uctablepre) = explode('.', str_replace('`', '', UC_DBTABLEPRE));
showtagheader('tbody', 'ucmysql', UC_CONNECT, 'sub');
showsetting('settings_uc_dbhost', 'settingsnew[uc][dbhost]', UC_DBHOST, 'text', $disable);
showsetting('settings_uc_dbuser', 'settingsnew[uc][dbuser]', UC_DBUSER, 'text', $disable);
showsetting('settings_uc_dbpass', 'settingsnew[uc][dbpass]', '********', 'text', $disable);
showsetting('settings_uc_dbname', 'settingsnew[uc][dbname]', $ucdbname, 'text', $disable);
showsetting('settings_uc_dbtablepre', 'settingsnew[uc][dbtablepre]', $uctablepre, 'text', $disable);
showtagfooter('tbody');
showsetting('settings_uc_activation', 'settingsnew[ucactivation]', $settings['ucactivation'], 'radio');
showsetting('settings_uc_avatarmethod', array('settingsnew[avatarmethod]', array(
array(0, $lang['settings_uc_avatarmethod_0']),
array(1, $lang['settings_uc_avatarmethod_1']),
)), $settings['avatarmethod'], 'mradio');
} elseif($operation == 'uchome') {
require_once DISCUZ_ROOT.'./uc_client/client.php';
$ucapparray = uc_app_ls();
$uchomeopen = FALSE;
$apparraylist = array();
foreach($ucapparray as $apparray) {
if($apparray['appid'] != UC_APPID) {
$apparraylist[] = $apparray;
}
if($apparray['type'] == 'UCHOME') {
$uchomeopen = TRUE;
}
}
if($uchomeopen) {
showtips('settings_uc_home_tips');
showtableheader();
$settings['uchome'] = unserialize($settings['uchome']);
foreach($apparraylist as $apparray) {
$checked = $settings['uchome']['navlist'][$apparray['appid']] ? 'checked="checked"': '';
$applist .= "<input type=\"checkbox\" class=\"checkbox\" name=\"appnew[navlist][$apparray[appid]]\" value=\"$apparray[name]\" $checked>$apparray[name] ";
}
showtitle('settings_uchome');
showsetting('settings_uc_feed', array('settingsnew[uchome][addfeed]', array(
$lang['settings_uc_feed_thread'],
$lang['settings_uc_feed_sepcialthread'],
$lang['settings_uc_feed_reply'])), $settings['uchome']['addfeed'], 'binmcheckbox');
showsetting('settings_uc_home_show', array('settingsnew[uchome][homeshow]', array(
$lang['settings_uc_home_avatarshow'],
$lang['settings_uc_home_viewproshow'],
$lang['settings_uc_home_adshow'],
$lang['settings_uc_home_side'])), $settings['uchome']['homeshow'], 'binmcheckbox');
} else {
cpmsg(lang('settings_uc_home_nonexistence'), '', '', '', FALSE);
exit();
}
} elseif($operation == 'ec') {
$settings['tradetypes'] = unserialize($settings['tradetypes']);
$query = $db->query("SELECT * FROM {$tablepre}threadtypes WHERE special='1' ORDER BY displayorder");
$tradetypeselect = '<select name="settingsnew[tradetypes][]" size="10" multiple="multiple">';
while($type = $db->fetch_array($query)) {
$checked = @in_array($type['typeid'], $settings['tradetypes']);
$tradetypeselect .= '<option value="'.$type['typeid'].'"'.($checked ? ' selected="selected"' : '').'>'.$type['name'].'</option>';
}
$tradetypeselect .= '</select>';
showtableheader();
showtitle('settings_ec_credittrade');
showsetting('settings_ec_ratio', 'settingsnew[ec_ratio]', $settings['ec_ratio'], 'text');
showsetting('settings_ec_mincredits', 'settingsnew[ec_mincredits]', $settings['ec_mincredits'], 'text');
showsetting('settings_ec_maxcredits', 'settingsnew[ec_maxcredits]', $settings['ec_maxcredits'], 'text');
showsetting('settings_ec_maxcreditspermonth', 'settingsnew[ec_maxcreditspermonth]', $settings['ec_maxcreditspermonth'], 'text');
showtitle('settings_ec_goodstrade');
showsetting('settings_ec_type', '', '', $tradetypeselect);
} elseif($operation == 'msn') {
$settings['msn'] = unserialize($settings['msn']);
showtips('settings_msn_tips');
showtableheader();
showtitle('settings_msn_basic');
showsetting('settings_msn_on', 'settingsnew[msn][on]', $settings['msn']['on'], 'radio');
showsetting('settings_msn_domain', 'msndomain', $settings['msn']['domain'], 'text');
showsubmit('settingsubmit', 'submit', '', '<input type="button" class="btn" name="msncheck" value="'.$lang['settings_msn_domain_check'].'" onclick="window.open(\'https://domains.live.com/members/signup.aspx?domain=\'+this.form.msndomain.value)" />');
showtablefooter();
exit;
} else {
cpmsg('undefined_action');
}
showtablerow('', 'colspan="2"', '<input type="submit" class="btn" name="settingsubmit" value="'.lang('submit').'" />'.$extbutton.(!empty($from) ? '<input type="hidden" name="from" value="'.$from.'">' : ''));
showtablefooter();
showformfooter();
} else {
if($operation == 'credits') {
$extcredits_exists = 0;
foreach($settingsnew['extcredits'] as $val) {
if(isset($val['available']) && $val['available'] == 1) {
$extcredits_exists = 1;
break;
}
}
if(!$extcredits_exists) {
cpmsg('settings_extcredits_must_available');
}
}
if($operation == 'uc' && is_writeable('./config.inc.php') && $isfounder) {
$ucdbpassnew = $settingsnew['uc']['dbpass'] == '********' ? UC_DBPW : $settingsnew['uc']['dbpass'];
if($settingsnew['uc']['connect']) {
$uc_dblink = @mysql_connect($settingsnew['uc']['dbhost'], $settingsnew['uc']['dbuser'], $ucdbpassnew, 1);
if(!$uc_dblink) {
cpmsg('uc_database_connect_error', '', 'error');
} else {
mysql_close($uc_dblink);
}
}
$fp = fopen('./config.inc.php', 'r');
$configfile = fread($fp, filesize('./config.inc.php'));
$configfile = trim($configfile);
$configfile = substr($configfile, -2) == '?>' ? substr($configfile, 0, -2) : $configfile;
fclose($fp);
$connect = '';
if($settingsnew['uc']['connect']) {
require './config.inc.php';
$connect = 'mysql';
$samelink = ($dbhost == $settingsnew['uc']['dbhost'] && $dbuser == $settingsnew['uc']['dbuser'] && $dbpw == $ucdbpassnew);
$samecharset = !($dbcharset == 'gbk' && UC_DBCHARSET == 'latin1' || $dbcharset == 'latin1' && UC_DBCHARSET == 'gbk');
$configfile = insertconfig($configfile, "/define\('UC_DBHOST',\s*'.*?'\);/i", "define('UC_DBHOST', '".$settingsnew['uc']['dbhost']."');");
$configfile = insertconfig($configfile, "/define\('UC_DBUSER',\s*'.*?'\);/i", "define('UC_DBUSER', '".$settingsnew['uc']['dbuser']."');");
$configfile = insertconfig($configfile, "/define\('UC_DBPW',\s*'.*?'\);/i", "define('UC_DBPW', '".$ucdbpassnew."');");
$configfile = insertconfig($configfile, "/define\('UC_DBNAME',\s*'.*?'\);/i", "define('UC_DBNAME', '".$settingsnew['uc']['dbname']."');");
$configfile = insertconfig($configfile, "/define\('UC_DBTABLEPRE',\s*'.*?'\);/i", "define('UC_DBTABLEPRE', '`".$settingsnew['uc']['dbname'].'`.'.$settingsnew['uc']['dbtablepre']."');");
//$configfile = insertconfig($configfile, "/define\('UC_LINK',\s*'?.*?'?\);/i", "define('UC_LINK', ".($samelink && $samecharset ? 'TRUE' : 'FALSE').");");
}
$configfile = insertconfig($configfile, "/define\('UC_CONNECT',\s*'.*?'\);/i", "define('UC_CONNECT', '$connect');");
$configfile = insertconfig($configfile, "/define\('UC_KEY',\s*'.*?'\);/i", "define('UC_KEY', '".$settingsnew['uc']['key']."');");
$configfile = insertconfig($configfile, "/define\('UC_API',\s*'.*?'\);/i", "define('UC_API', '".$settingsnew['uc']['api']."');");
$configfile = insertconfig($configfile, "/define\('UC_IP',\s*'.*?'\);/i", "define('UC_IP', '".$settingsnew['uc']['ip']."');");
$configfile = insertconfig($configfile, "/define\('UC_APPID',\s*'?.*?'?\);/i", "define('UC_APPID', '".$settingsnew['uc']['appid']."');");
$fp = fopen('./config.inc.php', 'w');
if(!($fp = @fopen('./config.inc.php', 'w'))) {
cpmsg('uc_config_write_error', '', 'error');
}
@fwrite($fp, trim($configfile));
@fclose($fp);
}
if($operation == 'uchome') {
$settingsnew['uchome']['addfeed'] = bindec(intval($settingsnew['uchome']['addfeed'][3]).intval($settingsnew['uchome']['addfeed'][2]).intval($settingsnew['uchome']['addfeed'][1]));
$settingsnew['uchome']['homeshow'] = bindec(intval($settingsnew['uchome']['homeshow'][4]).intval($settingsnew['uchome']['homeshow'][3]).intval($settingsnew['uchome']['homeshow'][2]).intval($settingsnew['uchome']['homeshow'][1]));
$settingsnew['uchome'] = addslashes(serialize($settingsnew['uchome']));
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('uchome', '$settingsnew[uchome]')");
}
$nohtmlarray = array('bbname', 'regname', 'reglinkname', 'icp', 'sitemessage');
foreach($nohtmlarray as $k) {
if(isset($settingsnew[$k])) {
$settingsnew[$k] = dhtmlspecialchars($settingsnew[$k]);
}
}
if(isset($settingsnew['censoruser'])) {
$settingsnew['censoruser'] = trim(preg_replace("/\s*(\r\n|\n\r|\n|\r)\s*/", "\r\n", $settingsnew['censoruser']));
}
if(isset($settingsnew['ipregctrl'])) {
$settingsnew['ipregctrl'] = trim(preg_replace("/\s*(\r\n|\n\r|\n|\r)\s*/", "\r\n", $settingsnew['ipregctrl']));
}
if(isset($settingsnew['ipaccess'])) {
if($settingsnew['ipaccess'] = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $settingsnew['ipaccess']))) {
if(!ipaccess($onlineip, $settingsnew['ipaccess'])) {
cpmsg('settings_ipaccess_invalid', '', 'error');
}
}
}
if(isset($settingsnew['adminipaccess'])) {
if($settingsnew['adminipaccess'] = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $settingsnew['adminipaccess']))) {
if(!ipaccess($onlineip, $settingsnew['adminipaccess'])) {
cpmsg('settings_adminipaccess_invalid', '', 'error');
}
}
}
if(isset($settingsnew['welcomemsgtitle'])) {
$settingsnew['welcomemsgtitle'] = cutstr(trim(dhtmlspecialchars($settingsnew['welcomemsgtitle'])), 75);
}
if(isset($settingsnew['showsignatures']) && isset($settingsnew['showavatars']) && isset($settingsnew['showimages'])) {
$settingsnew['showsettings'] = bindec($settingsnew['showsignatures'].$settingsnew['showavatars'].$settingsnew['showimages']);
}
if(!empty($settingsnew['globalstick'])) {
updatecache('globalstick');
}
if(isset($settingsnew['inviteconfig'])) {
$settingsnew['inviteconfig'] = addslashes(serialize($settingsnew['inviteconfig']));
}
if(isset($settingsnew['sitemessage'])) {
$settingsnew['sitemessage'] = addslashes(serialize($settingsnew['sitemessage']));
}
if(isset($settingsnew['smthumb'])) {
$settingsnew['smthumb'] = intval($settingsnew['smthumb']) >= 20 && intval($settingsnew['smthumb']) <= 40 ? intval($settingsnew['smthumb']) : 20;
}
if(isset($settingsnew['defaulteditormode']) && isset($settingsnew['allowswitcheditor'])) {
$settingsnew['editoroptions'] = bindec($settingsnew['defaulteditormode'].$settingsnew['allowswitcheditor']);
}
if(isset($settingsnew['myrecorddays'])) {
$settingsnew['myrecorddays'] = intval($settingsnew['myrecorddays']) > 0 ? intval($settingsnew['myrecorddays']) : 30;
}
if(!empty($settingsnew['thumbstatus']) && !function_exists('imagejpeg')) {
$settingsnew['thumbstatus'] = 0;
}
if(isset($settingsnew['creditsformula']) && isset($settingsnew['extcredits']) && isset($settingsnew['creditspolicy']) && isset($settingsnew['initcredits']) && isset($settingsnew['creditstrans']) && isset($settingsnew['creditstax'])) {
if(!preg_match("/^([\+\-\*\/\.\d\(\)]|((extcredits[1-8]|digestposts|posts|pageviews|oltime)([\+\-\*\/\(\)]|$)+))+$/", $settingsnew['creditsformula']) || !is_null(@eval(preg_replace("/(digestposts|posts|pageviews|oltime|extcredits[1-8])/", "\$\\1", $settingsnew['creditsformula']).';'))) {
cpmsg('settings_creditsformula_invalid', '', 'error');
}
$extcreditsarray = array();
if(is_array($settingsnew['extcredits'])) {
foreach($settingsnew['extcredits'] as $key => $value) {
if($value['available'] && !$value['title']) {
cpmsg('settings_credits_title_invalid', '', 'error');
}
$extcreditsarray[$key] = array
(
'img' => dhtmlspecialchars(stripslashes($value['img'])),
'title' => dhtmlspecialchars(stripslashes($value['title'])),
'unit' => dhtmlspecialchars(stripslashes($value['unit'])),
'ratio' => ($value['ratio'] > 0 ? (float)$value['ratio'] : 0),
'available' => $value['available'],
'lowerlimit' => intval($settingsnew['creditspolicy']['lowerlimit'][$key]),
'showinthread' => $value['showinthread'],
'allowexchangein' => $value['allowexchangein'],
'allowexchangeout' => $value['allowexchangeout']
);
$settingsnew['initcredits'][$key] = intval($settingsnew['initcredits'][$key]);
}
}
if(is_array($settingsnew['creditspolicy'])) {
foreach($settingsnew['creditspolicy'] as $key => $value) {
for($i = 1; $i <= 8; $i++) {
if(empty($value[$i])) {
unset($settingsnew['creditspolicy'][$key][$i]);
} else {
$value[$i] = $value[$i] > 99 ? 99 : ($value[$i] < -99 ? -99 : $value[$i]);
$settingsnew['creditspolicy'][$key][$i] = intval($value[$i]);
}
}
}
} else {
$settingsnew['creditspolicy'] = array();
}
for($si = 0; $si < 5; $si++) {
$creditstransi = $si > 0 && !$settingsnew['creditstrans'][$si] ? $settingsnew['creditstrans'][0] : $settingsnew['creditstrans'][$si];
if($creditstransi && empty($settingsnew['extcredits'][$creditstransi]['available'])) {
cpmsg('settings_creditstrans_invalid', '', 'error');
}
}
$settingsnew['creditspolicy'] = addslashes(serialize($settingsnew['creditspolicy']));
$settingsnew['creditsformulaexp'] = $settingsnew['creditsformula'];
foreach(array('digestposts', 'posts', 'oltime', 'pageviews', 'extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8') as $var) {
if($extcreditsarray[$creditsid = preg_replace("/^extcredits(\d{1})$/", "\\1", $var)]['available']) {
$replacement = $extcreditsarray[$creditsid]['title'];
} else {
$replacement = $lang['settings_credits_formula_'.$var];
}
$settingsnew['creditsformulaexp'] = str_replace($var, '<u>'.$replacement.'</u>', $settingsnew['creditsformulaexp']);
}
$settingsnew['creditsformulaexp'] = addslashes('<u>'.$lang['settings_credits_formula_credits'].'</u>='.$settingsnew['creditsformulaexp']);
$initformula = str_replace('posts', '0', $settingsnew['creditsformula']);
for($i = 1; $i <= 8; $i++) {
$initformula = str_replace('extcredits'.$i, $settingsnew['initcredits'][$i], $initformula);
}
eval("\$initcredits = round($initformula);");
$settingsnew['extcredits'] = addslashes(serialize($extcreditsarray));
$settingsnew['initcredits'] = $initcredits.','.implode(',', $settingsnew['initcredits']);
if($settingsnew['creditstax'] < 0 || $settingsnew['creditstax'] >= 1) {
$settingsnew['creditstax'] = 0;
}
$settingsnew['creditstrans'] = implode(',', $settingsnew['creditstrans']);
}
if(isset($settingsnew['gzipcompress'])) {
if(!function_exists('ob_gzhandler') && $settingsnew['gzipcompress']) {
cpmsg('settings_gzip_invalid', '', 'error');
}
}
if(isset($settingsnew['maxonlines'])) {
if($settingsnew['maxonlines'] > 65535 || !is_numeric($settingsnew['maxonlines'])) {
cpmsg('settings_maxonlines_invalid', '', 'error');
}
$db->query("ALTER TABLE {$tablepre}sessions MAX_ROWS=$settingsnew[maxonlines]");
if($settingsnew['maxonlines'] < $settings['maxonlines']) {
$db->query("DELETE FROM {$tablepre}sessions");
}
}
if(isset($settingsnew['seccodedata'])) {
$settingsnew['seccodedata']['width'] = intval($settingsnew['seccodedata']['width']);
$settingsnew['seccodedata']['height'] = intval($settingsnew['seccodedata']['height']);
if($settingsnew['seccodedata']['type'] != 3) {
$settingsnew['seccodedata']['width'] = $settingsnew['seccodedata']['width'] < 100 ? 100 : ($settingsnew['seccodedata']['width'] > 200 ? 200 : $settingsnew['seccodedata']['width']);
$settingsnew['seccodedata']['height'] = $settingsnew['seccodedata']['height'] < 50 ? 50 : ($settingsnew['seccodedata']['height'] > 80 ? 80 : $settingsnew['seccodedata']['height']);
} else {
$settingsnew['seccodedata']['width'] = 85;
$settingsnew['seccodedata']['height'] = 25;
}
$settingsnew['seccodedata']['loginfailedcount'] = !empty($settingsnew['seccodedata']['loginfailedcount']) ? 3 : 0;
$settingsnew['seccodedata'] = addslashes(serialize($settingsnew['seccodedata']));
}
if($operation == 'sec') {
$settingsnew['seccodestatus'] = bindec(intval($settingsnew['seccodestatus'][5]).intval($settingsnew['seccodestatus'][4]).intval($settingsnew['seccodestatus'][3]).intval($settingsnew['seccodestatus'][2]).intval($settingsnew['seccodestatus'][1]));
if(is_array($delete)) {
$db->query("DELETE FROM {$tablepre}itempool WHERE id IN (".implodeids($delete).")");
}
if(is_array($question)) {
foreach($question as $key => $q) {
$q = trim($q);
$a = cutstr(dhtmlspecialchars(trim($answer[$key])), 50);
if($q && $a) {
$db->query("UPDATE {$tablepre}itempool SET question='$q', answer='$a' WHERE id='$key'");
}
}
}
if(is_array($newquestion) && is_array($newanswer)) {
foreach($newquestion as $key => $q) {
$q = trim($q);
$a = cutstr(dhtmlspecialchars(trim($newanswer[$key])), 50);
if($q && $a) {
$db->query("INSERT INTO {$tablepre}itempool (question, answer) VALUES ('$q', '$a')");
}
}
}
updatecache('secqaa');
$settingsnew['secqaa']['status'] = bindec(intval($settingsnew['secqaa']['status'][3]).intval($settingsnew['secqaa']['status'][2]).intval($settingsnew['secqaa']['status'][1]));
$settingsnew['secqaa'] = serialize($settingsnew['secqaa']);
}
if($operation == 'seo') {
$settingsnew['rewritestatus'] = bindec(intval($settingsnew['rewritestatus'][5]).intval($settingsnew['rewritestatus'][4]).intval($settingsnew['rewritestatus'][3]).intval($settingsnew['rewritestatus'][2]).intval($settingsnew['rewritestatus'][1]));
$settingsnew['baidusitemap_life'] = max(1, min(24, intval($settingsnew['baidusitemap_life'])));
}
if($operation == 'functions') {
$settingsnew['bannedmessages'] = bindec(intval($settingsnew['bannedmessages'][3]).intval($settingsnew['bannedmessages'][2]).intval($settingsnew['bannedmessages'][1]));
}
if($operation == 'ec') {
if($settingsnew['ec_ratio']) {
if($settingsnew['ec_ratio'] < 0) {
cpmsg('alipay_ratio_invalid', '', 'error');
}
} else {
$settingsnew['ec_mincredits'] = $settingsnew['ec_maxcredits'] = 0;
}
foreach(array('ec_ratio', 'ec_mincredits', 'ec_maxcredits', 'ec_maxcreditspermonth', 'tradeimagewidth', 'tradeimageheight') as $key) {
$settingsnew[$key] = intval($settingsnew[$key]);
}
$settingsnew['tradetypes'] = addslashes(serialize($settingsnew['tradetypes']));
}
if(isset($settingsnew['visitbanperiods']) && isset($settingsnew['postbanperiods']) && isset($settingsnew['postmodperiods']) && isset($settingsnew['searchbanperiods'])) {
foreach(array('visitbanperiods', 'postbanperiods', 'postmodperiods', 'searchbanperiods') as $periods) {
$periodarray = array();
foreach(explode("\n", $settingsnew[$periods]) as $period) {
if(preg_match("/^\d{1,2}\:\d{2}\-\d{1,2}\:\d{2}$/", $period = trim($period))) {
$periodarray[] = $period;
}
}
$settingsnew[$periods] = implode("\r\n", $periodarray);
}
}
if(isset($settingsnew['infosidestatus'])) {
$settingsnew['infosidestatus'] = addslashes(serialize($settingsnew['infosidestatus']));
}
if(isset($settingsnew['timeformat'])) {
$settingsnew['timeformat'] = $settingsnew['timeformat'] == '24' ? 'H:i' : 'h:i A';
}
if(isset($settingsnew['dateformat'])) {
$settingsnew['dateformat'] = dateformat($settingsnew['dateformat'], 'format');
}
if(isset($settingsnew['userdateformat'])) {
$settingsnew['userdateformat'] = dateformat($settingsnew['userdateformat'], 'format');
}
if($isfounder && isset($settingsnew['ftp'])) {
$settings['ftp'] = unserialize($settings['ftp']);
$settings['ftp']['password'] = authcode($settings['ftp']['password'], 'DECODE', md5($authkey));
if(!empty($settingsnew['ftp']['password'])) {
$pwlen = strlen($settingsnew['ftp']['password']);
if($pwlen < 3) {
cpmsg('ftp_password_short', '', 'error');
}
if($settingsnew['ftp']['password']{0} == $settings['ftp']['password']{0} && $settingsnew['ftp']['password']{$pwlen - 1} == $settings['ftp']['password']{strlen($settings['ftp']['password']) - 1} && substr($settingsnew['ftp']['password'], 1, $pwlen - 2) == '********') {
$settingsnew['ftp']['password'] = $settings['ftp']['password'];
}
$settingsnew['ftp']['password'] = authcode($settingsnew['ftp']['password'], 'ENCODE', md5($authkey));
}
$settingsnew['ftp'] = serialize($settingsnew['ftp']);
}
if($isfounder && isset($settingsnew['mail'])) {
$settingsnew['mail'] = serialize($settingsnew['mail']);
}
if(isset($settingsnew['jsrefdomains'])) {
$settingsnew['jsrefdomains'] = trim(preg_replace("/(\s*(\r\n|\n\r|\n|\r)\s*)/", "\r\n", $settingsnew['jsrefdomains']));
}
if(isset($settingsnew['jsdateformat'])) {
$settingsnew['jsdateformat'] = dateformat($settingsnew['jsdateformat'], 'format');
}
if(isset($settingsnew['wapdateformat'])) {
$settingsnew['wapdateformat'] = dateformat($settingsnew['wapdateformat'], 'format');
}
if(isset($settingsnew['cachethreaddir']) && isset($settingsnew['threadcaches'])) {
if($settingsnew['cachethreaddir'] && !is_writable(DISCUZ_ROOT.'./'.$settingsnew['cachethreaddir'])) {
cpmsg('cachethread_dir_noexists', '', 'error');
}
if(!empty($fids)) {
$sqladd = in_array('all', $fids) ? '' : " WHERE fid IN ('".implode("', '", $fids)."')";
$db->query("UPDATE {$tablepre}forums SET threadcaches='$settingsnew[threadcaches]'$sqladd");
}
}
if($operation == 'attach') {
$settingsnew['thumbwidth'] = intval($settingsnew['thumbwidth']) > 0 ? intval($settingsnew['thumbwidth']) : 200;
$settingsnew['thumbheight'] = intval($settingsnew['thumbheight']) > 0 ? intval($settingsnew['thumbheight']) : 300;
}
if(isset($settingsnew['watermarktext'])) {
$settingsnew['watermarktext']['size'] = intval($settingsnew['watermarktext']['size']);
$settingsnew['watermarktext']['angle'] = intval($settingsnew['watermarktext']['angle']);
$settingsnew['watermarktext']['shadowx'] = intval($settingsnew['watermarktext']['shadowx']);
$settingsnew['watermarktext']['shadowy'] = intval($settingsnew['watermarktext']['shadowy']);
$settingsnew['watermarktext']['fontpath'] = str_replace(array('\\', '/'), '', $settingsnew['watermarktext']['fontpath']);
if($settingsnew['watermarktype'] == 2 && $settingsnew['watermarktext']['fontpath']) {
$fontpath = $settingsnew['watermarktext']['fontpath'];
$fontpathnew = 'ch/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
if(!$settingsnew['watermarktext']['fontpath']) {
$fontpathnew = 'en/'.$fontpath;
$settingsnew['watermarktext']['fontpath'] = file_exists('images/fonts/'.$fontpathnew) ? $fontpathnew : '';
}
if(!$settingsnew['watermarktext']['fontpath']) {
cpmsg('watermarkpreview_fontpath_error', '', 'error');
}
}
$settingsnew['watermarktext'] = addslashes(serialize($settingsnew['watermarktext']));
}
if(isset($settingsnew['msgforward'])) {
if(!empty($settingsnew['msgforward']['messages'])) {
$tempmsg = explode("\n", $settingsnew['msgforward']['messages']);
$settingsnew['msgforward']['messages'] = array();
foreach($tempmsg as $msg) {
if($msg = strip_tags(trim($msg))) {
$settingsnew['msgforward']['messages'][] = $msg;
}
}
} else {
$settingsnew['msgforward']['messages'] = array();
}
$tmparray = array(
'refreshtime' => intval($settingsnew['msgforward']['refreshtime']),
'quick' => $settingsnew['msgforward']['quick'] ? 1 : 0,
'messages' => $settingsnew['msgforward']['messages']
);
$settingsnew['msgforward'] = addslashes(serialize($tmparray));
}
if(isset($settingsnew['onlinehold'])) {
$settingsnew['onlinehold'] = intval($settingsnew['onlinehold']) > 0 ? intval($settingsnew['onlinehold']) : 15;
}
if(isset($settingsnew['postno'])) {
$settingsnew['postno'] = trim($settingsnew['postno']);
}
if(isset($settingsnew['postnocustom'])) {
$settingsnew['postnocustom'] = addslashes(serialize(explode("\n", $settingsnew['postnocustom'])));
}
$updatestyles = FALSE;
if($operation == 'styles') {
$settingsnew['customauthorinfo'] = addslashes(serialize(array($settingsnew['customauthorinfo'])));
list(, $imagemaxwidth) = explode("\t", $settings['zoomstatus']);
if($imagemaxwidth != $settingsnew['imagemaxwidth']) {
$updatestyles = TRUE;
}
$settingsnew['zoomstatus'] = $settingsnew['zoomstatus']."\t".$settingsnew['imagemaxwidth'];
}
if(isset($settingsnew['smcols'])) {
$settingsnew['smcols'] = $settingsnew['smcols'] >= 8 && $settingsnew['smcols'] <= 12 ? $settingsnew['smcols'] : 8;
}
if(isset($settingsnew['msn'])) {
$settingsnew['msn']['domain'] = $msndomain;
$settingsnew['msn'] = addslashes(serialize($settingsnew['msn']));
}
$updatecache = FALSE;
foreach($settingsnew as $key => $val) {
if(isset($settings[$key]) && $settings[$key] != $val) {
$$key = $val;
$updatecache = TRUE;
if(in_array($key, array('newbiespan', 'topicperpage', 'postperpage', 'memberperpage', 'hottopic', 'starthreshold', 'delayviewcount', 'attachexpire',
'visitedforums', 'maxsigrows', 'timeoffset', 'statscachelife', 'pvfrequence', 'oltimespan', 'seccodestatus',
'maxprice', 'rssttl', 'rewritestatus', 'bdaystatus', 'maxonlines', 'loadctrl', 'floodctrl', 'regctrl', 'regfloodctrl',
'searchctrl', 'extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6',
'extcredits7', 'extcredits8', 'transfermincredits', 'exchangemincredits', 'maxincperthread', 'maxchargespan',
'maxspm', 'maxsearchresults', 'maxsmilies', 'threadmaxpages', 'membermaxpages', 'maxpostsize', 'minpostsize',
'maxpolloptions', 'karmaratelimit', 'losslessdel', 'edittimelimit', 'smcols',
'watermarktrans', 'watermarkquality', 'jscachelife', 'waptpp', 'wapppp', 'wapmps', 'maxmodworksmonths', 'frameon', 'maxonlinelist'))) {
$val = (float)$val;
}
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$key', '$val')");
}
}
if($updatecache) {
updatecache('settings');
if(isset($settingsnew['forumlinkstatus']) && $settingsnew['forumlinkstatus'] != $settings['forumlinkstatus']) {
updatecache('forumlinks');
}
if(isset($settingsnew['userstatusby']) && $settingsnew['userstatusby'] != $settings['userstatusby']) {
updatecache('usergroups');
updatecache('ranks');
}
if((isset($settingsnew['tagstatus']) && $settingsnew['tagstatus'] != $settings['tagstatus']) || (isset($settingsnew['viewthreadtags']) && $settingsnew['viewthreadtags'] != $settings['viewthreadtags'])) {
updatecache(array('tags_index', 'tags_viewthread'));
}
if((isset($settingsnew['smthumb']) && $settingsnew['smthumb'] != $settings['smthumb']) || (isset($settingsnew['smcols']) && $settingsnew['smcols'] != $settings['smcols']) || (isset($settingsnew['smrows']) && $settingsnew['smrows'] != $settings['smrows'])) {
updatecache('smilies_js');
}
if(isset($settingsnew['customauthorinfo']) && $settingsnew['customauthorinfo'] != $settings['customauthorinfo']) {
updatecache('custominfo');
}
if($operation == 'credits') {
updatecache('custominfo');
}
if($updatestyles) {
updatecache('styles');
}
}
if($operation == 'credits' && $projectsave) {
$projectid = intval($projectid);
dheader("Location: $boardurl$BASESCRIPT?action=project&operation=add&type=extcredit&projectid=$projectid");
}
cpmsg('settings_update_succeed', $BASESCRIPT.'?action=settings&operation='.$operation.(!empty($anchor) ? '&anchor='.$anchor : '').(!empty($from) ? '&from='.$from : ''), 'succeed');
}
function creditsrow($policy) {
global $settings;
$policyarray = array(lang('settings_credits_policy_'.$policy));
for($i = 1; $i <= 8; $i++) {
$policyarray[] = "<input type=\"text\" class=\"txt\" size=\"2\" name=\"settingsnew[creditspolicy][$policy][$i]\" ".($settings['extcredits'][$i]['available'] ? '' : 'readonly')." value=\"".intval($settings['creditspolicy'][$policy][$i])."\">";
}
return $policyarray;
}
function dateformat($string, $operation = 'formalise') {
$string = htmlspecialchars(trim($string));
$replace = $operation == 'formalise' ? array(array('n', 'j', 'y', 'Y'), array('mm', 'dd', 'yy', 'yyyy')) : array(array('mm', 'dd', 'yyyy', 'yy'), array('n', 'j', 'Y', 'y'));
return str_replace($replace[0], $replace[1], $string);
}
function insertconfig($s, $find, $replace) {
if(preg_match($find, $s)) {
$s = preg_replace($find, $replace, $s);
} else {
$s .= "\r\n".$replace;
}
return $s;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/settings.inc.php
|
PHP
|
asf20
| 96,215
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: styles.inc.php 17229 2008-12-11 01:13:46Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
$operation = empty($operation) ? 'admin' : $operation;
if($operation == 'export' && $id) {
$stylearray = $db->fetch_first("SELECT s.name, s.templateid, t.name AS tplname, t.directory, t.copyright FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON t.templateid=s.templateid WHERE styleid='$id'");
if(!$stylearray) {
cpheader();
cpmsg('styles_export_invalid', '', 'error');
}
$stylearray['version'] = strip_tags($version);
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
$query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='$id'");
while($style = $db->fetch_array($query)) {
$stylearray['style'][$style['variable']] = $style['substitute'];
}
$style_export = "# Discuz! Style Dump\n".
"# Version: Discuz! $version\n".
"# Time: $time\n".
"# From: $bbname ($boardurl)\n".
"#\n".
"# This file was BASE64 encoded\n".
"#\n".
"# Discuz! Community: http://www.Discuz.net\n".
"# Please visit our website for latest news about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
wordwrap(base64_encode(serialize($stylearray)), 50, "\n", 1);
ob_end_clean();
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
dheader('Cache-Control: no-cache, must-revalidate');
dheader('Pragma: no-cache');
dheader('Content-Encoding: none');
dheader('Content-Length: '.strlen($style_export));
dheader('Content-Disposition: attachment; filename=discuz_style_'.$stylearray['name'].'.txt');
dheader('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
echo $style_export;
dexit();
}
cpheader();
$predefinedvars = array('available' => array(), 'boardimg' => array(), 'imgdir' => array(), 'styleimgdir' => array(), 'stypeid' => array(),
'headerbgcolor' => array(0, $lang['styles_edit_type_bg']),
'bgcolor' => array(0),
'sidebgcolor' => array(0, '', '#FFF sidebg.gif repeat-y 100% 0'),
'headerborder' => array(1, $lang['styles_edit_type_header'], '1px'),
'headerbordercolor' => array(0),
'headertext' => array(0),
'footertext' => array(0),
'font' => array(1, $lang['styles_edit_type_font']),
'fontsize' => array(1),
'smfont' => array(1),
'smfontsize' => array(1),
'tabletext' => array(0),
'midtext' => array(0),
'lighttext' => array(0),
'link' => array(0, $lang['styles_edit_type_url']),
'highlightlink' => array(0),
'wrapwidth' => array(1, $lang['styles_edit_type_wrap'], '98%'),
'wrapbg' => array(0),
'wrapborder' => array(1, '', '0'),
'wrapbordercolor' => array(0),
'msgfontsize' => array(1, $lang['styles_edit_type_post'], '14px'),
'msgbigsize' => array(1, '', '16px'),
'contentwidth' => array(1),
'contentseparate' => array(0),
'menuborder' => array(0, $lang['styles_edit_type_menu']),
'menubgcolor' => array(0),
'menutext' => array(0),
'menuhover' => array(0),
'menuhovertext' => array(0),
'inputborder' => array(0, $lang['styles_edit_type_input']),
'inputborderdarkcolor' => array(0),
'inputbg' => array(0, '', '#FFF'),
'dropmenuborder' => array(0, $lang['styles_edit_type_dropmenu']),
'dropmenubgcolor' => array(0),
'floatbgcolor' => array(0, $lang['styles_edit_type_float']),
'floatmaskbgcolor' => array(0),
'commonborder' => array(0, $lang['styles_edit_type_other']),
'commonbg' => array(0),
'specialborder' => array(0),
'specialbg' => array(0),
'interleavecolor' => array(0),
'noticetext' => array(0),
);
if($operation == 'admin') {
$query = $db->query("SELECT s.styleid, s.available, s.name, t.name AS tplname, t.directory, t.copyright FROM {$tablepre}styles s LEFT JOIN {$tablepre}templates t ON t.templateid=s.templateid ORDER BY s.available desc, s.styleid");
$sarray = $tpldirs = array();
while($row = $db->fetch_array($query)) {
$sarray[$row['styleid']] = $row;
$tpldirs[] = realpath($row['directory']);
}
$defaultid = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='styleid'");
if(!submitcheck('stylesubmit')) {
$narray = array();
$dir = DISCUZ_ROOT.'./templates';
$templatedir = dir($dir);$i = -1;
while($entry = $templatedir->read()) {
$tpldir = realpath($dir.'/'.$entry);
if(!in_array($entry, array('.', '..')) && !in_array($tpldir, $tpldirs) && is_dir($tpldir)) {
$styleexist = 0;
$searchdir = dir($tpldir);
while($searchentry = $searchdir->read()) {
if(substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'txt') {
$styleexist++;
}
}
if($styleexist) {
$narray[$i] = array(
'styleid' => '',
'available' => '',
'name' => $entry,
'directory' => './templates/'.$entry,
'name' => $entry,
'tplname' => $entry,
'filemtime' => @filemtime($dir.'/'.$entry),
'stylecount' => $styleexist
);
$i--;
}
}
}
uasort($narray, 'filemtimesort');
$sarray += $narray;
$stylelist = '';
$i = 0;
foreach($sarray as $id => $style) {
$style['name'] = dhtmlspecialchars($style['name']);
$isdefault = $id == $defaultid ? 'checked' : '';
$available = $style['available'] ? 'checked' : NULL;
$preview = file_exists($style['directory'].'/preview.jpg') ? $style['directory'].'/preview.jpg' : './images/admincp/stylepreview.gif';
$stylelist .= ($i == 0 ? '<tr>' : '').
'<td width="33%" '.($available ? 'style="background: #F2F9FD"' : '').'><table cellspacing="0" cellpadding="0" style="margin-left: 10px; width: 200px;"><tr><td style="width: 120px; text-align: center; border-top: none;">'.
($id > 0 ? "<p style=\"margin-bottom: 2px;\"> </p>".
($available ? "<a href=\"{$boardurl}$indexname?styleid=$id\" target=\"_blank\">" : '' )."<img src=\"$preview\" alt=\"$lang[preview]\"/></a>
<p style=\"margin: 2px 0\"><span style=\"float: left; dispaly: inline; margin-left: 4px; width: 20px; height: 20px; background: ".($styleicons[$id] ? $styleicons[$id] : 'url(./images/admincp/transparent.gif)')."\"> </span><input type=\"text\" class=\"txt\" name=\"namenew[$id]\" value=\"$style[name]\" size=\"30\" style=\"margin-right:0; width: 80px;\"></p>
<p class=\"lightfont\">($style[tplname])</p></td><td style=\"padding-top: 17px; width: 80px; border-top: none; vertical-align: top;\">
<p style=\"margin: 2px 0\">$lang[available] <input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[$id]\" value=\"1\" $available></p>
<p style=\"margin: 2px 0\">$lang[default] <input type=\"radio\" class=\"radio\" name=\"defaultnew\" value=\"$id\" $isdefault></p>
<p style=\"margin: 2px 0\">$lang[styles_uninstall] ".($isdefault ? '<input class="checkbox" type="checkbox" disabled="disabled" />' : '<input class="checkbox" type="checkbox" name="delete[]" value="'.$id.'" />')."</p>
<p style=\"margin: 8px 0 2px\"><a href=\"$BASESCRIPT?action=styles&operation=edit&id=$id\">$lang[edit]</a></p>
<p style=\"margin: 2px 0\"><a href=\"$BASESCRIPT?action=styles&operation=export&id=$id\">$lang[export]</a></p>
<p style=\"margin: 2px 0\"><a href=\"$BASESCRIPT?action=styles&operation=copy&id=$id\">$lang[copy]</a></p>" :
"<p style=\"margin-bottom: 2px;\"> </p>
<img src=\"$preview\" />
<p style=\"margin: 13px 0\" class=\"lightfont\">($style[tplname])</p></td><td style=\"padding-top: 17px; width: 80px; border-top: none; vertical-align: top;\">
<p style=\"margin: 2px 0\"><a href=\"$BASESCRIPT?action=styles&operation=import&dir=$style[name]\">$lang[styles_install]</a></p>
<p style=\"margin: 2px p\">$lang[styles_stylecount]$style[stylecount]</p>".
($style['filemtime'] > $timestamp - 86400 ? '<p style=\"margin-bottom: 2px;\"><font color="red">New!</font></p>' : '')).
"</td></tr></table></td>\n".($i == 3 ? '</tr>' : '');
$i++;
if($i == 3) {
$i = 0;
}
}
if($i > 0) {
$stylelist .= str_repeat('<td></td>', 3 - $i);
}
shownav('style', 'styles_admin');
showsubmenu('styles_admin', array(
array('admin', 'styles', '1'),
array('import', 'styles&operation=import', '0')
));
showtips('styles_admin_tips');
showformheader('styles');
showhiddenfields(array('updatecsscache' => 0));
showtableheader('', 'tdhover');
echo $stylelist;
showtablefooter();
showtableheader();
echo '<tr><td>'.$lang['add_new'].'</td><td><input type="text" class="txt" name="newname" size="18"></td><td colspan="5"> </td></tr>';
showsubmit('stylesubmit', 'submit', 'del', '<input onclick="this.form.updatecsscache.value=1" type="submit" class="btn" name="stylesubmit" value="'.lang('styles_csscache_update').'">');
showtablefooter();
showformfooter();
} else {
if($updatecsscache) {
updatecache('styles');
cpmsg('csscache_update', $BASESCRIPT.'?action=styles', 'succeed');
} else {
if(is_numeric($defaultnew) && $defaultid != $defaultnew && isset($sarray[$defaultnew])) {
$defaultid = $defaultnew;
$db->query("UPDATE {$tablepre}settings SET value='$defaultid' WHERE variable='styleid'");
}
$availablenew[$defaultid] = 1;
foreach($sarray as $id => $old) {
$namenew[$id] = trim($namenew[$id]);
$availablenew[$id] = $availablenew[$id] ? 1 : 0;
if($namenew[$id] != $old['name'] || $availablenew[$id] != $old['available']) {
$db->query("UPDATE {$tablepre}styles SET name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
}
}
if(!empty($delete) && is_array($delete)) {
$did = array();
foreach($delete as $id) {
$id = intval($id);
if($id == $defaultid) {
cpmsg('styles_delete_invalid', '', 'error');
} elseif($id != 1){
$did[] = intval($id);
}
}
if($did && ($ids = implodeids($did))) {
$query = $db->query("SELECT templateid FROM {$tablepre}styles");
$tplids = array();
while($style = $db->fetch_array($query)) {
$tplids[$style['templateid']] = $style['templateid'];
}
$db->query("DELETE FROM {$tablepre}styles WHERE styleid IN ($ids)");
$db->query("DELETE FROM {$tablepre}stylevars WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}members SET styleid='0' WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}forums SET styleid='0' WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}sessions SET styleid='$defaultid' WHERE styleid IN ($ids)");
$query = $db->query("SELECT templateid FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
unset($tplids[$style['templateid']]);
}
if($tplids) {
$db->query("DELETE FROM {$tablepre}templates WHERE templateid IN (".implodeids($tplids).")");
}
}
}
if($newname) {
$db->query("INSERT INTO {$tablepre}styles (name, templateid) VALUES ('$newname', '1')");
$styleidnew = $db->insert_id();
foreach(array_keys($predefinedvars) as $variable) {
$substitute = isset($predefinedvars[$variable][2]) ? $predefinedvars[$variable][2] : '';;
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$variable', '$substitute')");
}
}
updatecache('settings');
updatecache('styles');
cpmsg('styles_edit_succeed', $BASESCRIPT.'?action=styles', 'succeed');
}
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit') && !isset($dir)) {
shownav('style', 'styles_admin');
showsubmenu('styles_admin', array(
array('admin', 'styles', '0'),
array('import', 'styles&operation=import', '1')
));
showformheader('styles&operation=import', 'enctype');
showtableheader('styles_import');
showimportdata();
showtablerow('', '', '<input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> '.lang('styles_import_ignore_version').'</label>');
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
if(!isset($dir)) {
$stylearrays = array(getimportdata());
} else {
$dir = str_replace(array('/', '\\'), '', $dir);
$templatedir = DISCUZ_ROOT.'./templates/'.$dir;
$searchdir = dir($templatedir);
$stylearrays = array();
while($searchentry = $searchdir->read()) {
if(substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'txt') {
$importfile = $templatedir.'/'.$searchentry;
$styledata = preg_replace("/(#.*\s+)*/", '', @implode('', file($importfile)));
$style = daddslashes(unserialize(base64_decode($styledata)), 1);
if(!is_array($style)) {
cpmsg('import_data_invalid', '', 'error');
}
$stylearrays[] = $style;
}
}
}
foreach($stylearrays as $stylearray) {
if(empty($ignoreversion) && strip_tags($stylearray['version']) != strip_tags($version)) {
cpmsg('styles_import_version_invalid', '', 'error');
}
$renamed = 0;
if($stylearray['templateid'] != 1) {
$templatedir = DISCUZ_ROOT.'./'.$stylearray['directory'];
if(!is_dir($templatedir)) {
if(!@mkdir($templatedir, 0777)) {
$basedir = dirname($stylearray['directory']);
cpmsg('styles_import_directory_invalid', '', 'error');
}
}
if(!($templateid = $db->result_first("SELECT templateid FROM {$tablepre}templates WHERE name='$stylearray[tplname]'"))) {
$db->query("INSERT INTO {$tablepre}templates (name, directory, copyright)
VALUES ('$stylearray[tplname]', '$stylearray[directory]', '$stylearray[copyright]')");
$templateid = $db->insert_id();
}
} else {
$templateid = 1;
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}styles WHERE name='$stylearray[name]'")) {
$stylearray['name'] .= '_'.random(4);
$renamed = 1;
}
$db->query("INSERT INTO {$tablepre}styles (name, templateid)
VALUES ('$stylearray[name]', '$templateid')");
$styleidnew = $db->insert_id();
foreach($stylearray['style'] as $variable => $substitute) {
$substitute = @htmlspecialchars($substitute);
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$variable', '$substitute')");
}
}
updatecache('styles');
updatecache('settings');
cpmsg(!empty($dir) ? 'styles_install_succeed' : ($renamed ? 'styles_import_succeed_renamed' : 'styles_import_succeed'), $BASESCRIPT.'?action=styles', 'succeed');
}
} elseif($operation == 'copy') {
$style = $db->fetch_first("SELECT * FROM {$tablepre}styles WHERE styleid='$id'");
$style['name'] .= '_'.random(4);
$db->query("INSERT INTO {$tablepre}styles (name, available, templateid)
VALUES ('$style[name]', '$style[available]', '$style[templateid]')");
$styleidnew = $db->insert_id();
$query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='$id'");
while($stylevar = $db->fetch_array($query)) {
$stylevar['substitute'] = addslashes($stylevar['substitute']);
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$stylevar[variable]', '$stylevar[substitute]')");
}
updatecache('styles');
updatecache('settings');
cpmsg('styles_copy_succeed', $BASESCRIPT.'?action=styles', 'succeed');
} elseif($operation == 'edit') {
if(!submitcheck('editsubmit')) {
if(empty($id)) {
$stylelist = "<select name=\"id\" style=\"width: 150px\">\n";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$stylelist .= "<option value=\"$style[styleid]\">$style[name]</option>\n";
}
$stylelist .= '</select>';
cpmsg('styles_nonexistence', $BASESCRIPT.'?action=styles&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $stylelist);
}
$style = $db->fetch_first("SELECT name, templateid FROM {$tablepre}styles WHERE styleid='$id'");
if(!$style) {
cpmsg('undefined_action', '', 'error');
}
$stylecustom = '';
$stylestuff = $existvars = array();
$query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='$id'");
while($stylevar = $db->fetch_array($query)) {
if(array_key_exists($stylevar['variable'], $predefinedvars)) {
$stylestuff[$stylevar['variable']] = array('id' => $stylevar['stylevarid'], 'subst' => $stylevar['substitute']);
$existvars[] = $stylevar['variable'];
} else {
$stylecustom .= showtablerow('', array('class="td25"', 'class="td24 bold"', 'class="td26"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$stylevar[stylevarid]\">",
'{'.strtoupper($stylevar['variable']).'}',
"<textarea name=\"stylevar[$stylevar[stylevarid]]\" style=\"height: 45px\" cols=\"50\" rows=\"2\">$stylevar[substitute]</textarea>",
), TRUE);
}
}
if($diffvars = array_diff(array_keys($predefinedvars), $existvars)) {
foreach($diffvars as $variable) {
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$id', '$variable', '')");
$stylestuff[$variable] = array('id' => $db->insert_id(), 'subst' => '');
}
}
$tplselect = array();
$query = $db->query("SELECT templateid, name FROM {$tablepre}templates");
while($template = $db->fetch_array($query)) {
$tplselect[] = array($template['templateid'], $template['name']);
}
$smileytypes = array();
$query = $db->query("SELECT typeid, name FROM {$tablepre}imagetypes WHERE available='1'");
while($type = $db->fetch_array($query)) {
$smileytypes[] = array($type['typeid'], $type['name']);
}
$adv = !empty($adv) ? 1 : 0;
shownav('style', 'styles_edit');
showsubmenu('styles_admin', array(
array('admin', 'styles', '0'),
array('import', 'styles&operation=import', '0'),
array(array('menu' => 'edit' , 'submenu' => array(
array('styles_edit_simple', 'styles&operation=edit&id='.$id, !$adv),
array('styles_edit_adv', 'styles&operation=edit&id='.$id.'&adv=1', $adv),
)), '', 1)
));
if($adv) {
?>
<script type="text/JavaScript">
function imgpre_onload(obj) {
if(!obj.complete) {
setTimeout(function() {imgpre_resize(obj)}, 100);
}
imgpre_resize(obj);
}
function imgpre_resize(obj) {
if(obj.width > 350) {
obj.style.width = '350px';
}
}
function imgpre_update(id, obj) {
url = obj.value;
if(url) {
re = /^http:\/\//i;
var matches = re.exec(url);
if(matches == null) {
url = ($('styleimgdir').value ? $('styleimgdir').value : ($('imgdir').value ? $('imgdir').value : 'images/default')) + '/' + url;
}
$('bgpre_' + id).style.backgroundImage = 'url(' + url + ')';
} else {
$('bgpre_' + id).style.backgroundImage = 'url(images/common/none.gif)';
}
}
function imgpre_switch(id) {
if($('bgpre_' + id).innerHTML == '') {
url = $('bgpre_' + id).style.backgroundImage.substring(4, $('bgpre_' + id).style.backgroundImage.length - 1);
$('bgpre_' + id).innerHTML = '<img onload="imgpre_onload(this)" src="' + url + '" />';
$('bgpre_' + id).backgroundImage = $('bgpre_' + id).style.backgroundImage;
$('bgpre_' + id).style.backgroundImage = '';
} else {
$('bgpre_' + id).style.backgroundImage = $('bgpre_' + id).backgroundImage;
$('bgpre_' + id).innerHTML = '';
}
}
</script>
<?
showformheader("styles&operation=edit&id=$id&adv=1");
showtableheader($lang['styles_edit'].' - '.$style['name'], 'nobottom');
showsetting('styles_edit_name', 'namenew', $style['name'], 'text');
showsetting('styles_edit_tpl', array('templateidnew', $tplselect), $style['templateid'], 'select');
showsetting('styles_edit_smileytype', array("stylevar[{$stylestuff[stypeid][id]}]", $smileytypes), $stylestuff['stypeid']['subst'], 'select');
showsetting('styles_edit_imgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['imgdir']['id'].']" id="imgdir" value="'.$stylestuff['imgdir']['subst'].'" />');
showsetting('styles_edit_styleimgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['styleimgdir']['id'].']" id="styleimgdir" value="'.$stylestuff['styleimgdir']['subst'].'" />');
showsetting('styles_edit_logo', "stylevar[{$stylestuff[boardimg][id]}]", $stylestuff['boardimg']['subst'], 'text');
foreach($predefinedvars as $predefinedvar => $v) {
if($v !== array()) {
if(!empty($v[1])) {
showtitle($v[1]);
}
$type = $v[0] == 1 ? 'text' : 'color';
$extra = '';
$comment = ($type == 'text' ? $lang['styles_edit_'.$predefinedvar.'_comment'] : $lang['styles_edit_hexcolor']).$lang['styles_edit_'.$predefinedvar.'_comment'];
if(substr($predefinedvar, -7, 7) == 'bgcolor') {
$stylestuff[$predefinedvar]['subst'] = explode(' ', $stylestuff[$predefinedvar]['subst']);
$bgimg = $stylestuff[$predefinedvar]['subst'][1];
$bgextra = implode(' ', array_slice($stylestuff[$predefinedvar]['subst'], 2));
$stylestuff[$predefinedvar]['subst'] = $stylestuff[$predefinedvar]['subst'][0];
$bgimgpre = $bgimg ? (preg_match('/^http:\/\//i', $bgimg) ? $bgimg : ($stylestuff['styleimgdir']['subst'] ? $stylestuff['styleimgdir']['subst'] : ($stylestuff['imgdir']['subst'] ? $stylestuff['imgdir']['subst'] : 'images/default')).'/'.$bgimg) : 'images/common/none.gif';
$comment .= '<div id="bgpre_'.$stylestuff[$predefinedvar]['id'].'" onclick="imgpre_switch('.$stylestuff[$predefinedvar]['id'].')" style="background-image:url('.$bgimgpre.');cursor:pointer;float:right;width:350px;height:40px;overflow:hidden;border: 1px solid #ccc"></div>'.$lang['styles_edit_'.$predefinedvar.'_comment'].$lang['styles_edit_bg'];
$extra = '<br /><input name="stylevarbgimg['.$stylestuff[$predefinedvar]['id'].']" value="'.$bgimg.'" onchange="imgpre_update('.$stylestuff[$predefinedvar]['id'].', this)" type="text" class="txt" style="margin:5px 0;" />'.
'<br /><input name="stylevarbgextra['.$stylestuff[$predefinedvar]['id'].']" value="'.$bgextra.'" type="text" class="txt" />';
$varcomment = ' {'.strtoupper($predefinedvar).'},{'.strtoupper(substr($predefinedvar, 0, -7)).'BGCODE}:';
} else {
$varcomment = ' {'.strtoupper($predefinedvar).'}:';
}
showsetting(lang('styles_edit_'.$predefinedvar).$varcomment, 'stylevar['.$stylestuff[$predefinedvar]['id'].']', $stylestuff[$predefinedvar]['subst'], $type, '', 0, $comment, $extra);
}
}
showtablefooter();
showtableheader('styles_edit_customvariable', 'notop');
showsubtitle(array('', 'styles_edit_variable', 'styles_edit_subst'));
echo $stylecustom;
showtablerow('', array('class="td25"', 'class="td24 bold"', 'class="td26"'), array(
lang('add_new'),
'<input type="text" class="txt" name="newcvar">',
'<textarea name="newcsubst" class="tarea" style="height: 45px" cols="50" rows="2"></textarea>'
));
showsubmit('editsubmit', 'submit', 'del', '<input type="button" class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=styles&operation=edit&id='.$id.'\'" value="'.$lang['styles_edit_simple_switch'].'">');
showtablefooter();
showformfooter();
} else {
showformheader("styles&operation=edit&id=$id&adv=1");
showtableheader($lang['styles_edit'].' - '.$style['name'], 'nobottom');
showsetting('styles_edit_name', 'namenew', $style['name'], 'text');
showsetting('styles_edit_tpl', array('templateidnew', $tplselect), $style['templateid'], 'select');
showsetting('styles_edit_smileytype', array("stylevar[{$stylestuff[stypeid][id]}]", $smileytypes), $stylestuff['stypeid']['subst'], 'select');
showsetting('styles_edit_imgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['imgdir']['id'].']" id="imgdir" value="'.$stylestuff['imgdir']['subst'].'" onchange="imgdirurl_update()" />');
showsetting('styles_edit_styleimgdir', '', '', '<input type="text" class="txt" name="stylevar['.$stylestuff['styleimgdir']['id'].']" id="styleimgdir" value="'.$stylestuff['styleimgdir']['subst'].'" onchange="imgdirurl_update()" />');
showtitle('styles_edit_visual');
?>
<tr><td colspan="2">
<table cellpadding="0" cellspacing="0" width="100%" id="previewbody"><tr><td valign="top" width="560" style="border: none;">
<style>
#style_preview p, #style_preview ul, #style_preview li { margin: 0; padding: 0; list-style: none; }
#sp_menu li { float: left; margin-left: 5px; padding: 0 10px; height: 25px; border-style: solid; border-width: 1px 1px 0; line-height: 25px; }
#sp_wrap th, #sp_wrap td { border: 0; }
#previewbody .colorwd { float: none; width: 21px; margin-left: 3px; }
#previewbody div.color { float:left; width: 120px;}
</style>
<div id="style_preview" style="width: 550px; border: 1px solid #333; background: #0D2345 url(images/default/bodybg.gif) repeat-x scroll 0 90px; font-size: 12px; color: #444;">
<div id="sp_header" style="position: relative; padding: 20px 10px 20px 10px; border-bottom: 1px solid #00B2E8; background: #00A2D2 url(images/default/header.gif) repeat-x scroll 0 100%;">
<img id="sp_logo" src="images/default/logo.gif" />
<div id="sp_umenu" style="position: absolute; right: 10px; top: 10px; color: #97F2FF;"><?=$discuz_userss?> | <?=$lang['styles_edit_visual_exit']?></div>
<ul id="sp_menu" style="position: absolute; right: 10px; bottom: -1px; color: #666;">
<li id="sp_menucurrent" style="border-color: #00B2E8; background: #1E4B7E; color: #FFF;"><?=$lang['styles_edit_visual_menu_current']?></li>
<li id="sp_menuitem" style="border-color: #00B2E8; background: #EBF4FD url(images/default/mtabbg.gif) repeat-x scroll 0 100%;"><?=$lang['styles_edit_visual_menu']?></li>
</ul>
</div>
<div id="sp_wrap" style="margin: 10px 10px 5px; border: 0px solid #000; background: #FFF url(images/default/sidebg.gif) repeat-y scroll 100% 0;">
<div id="sp_content" style="padding: 10px; width: 350px; w\idth: 330px;">
<div id="sp_backcolor" style="background: #F7F7F7;"><?=$lang['styles_edit_visual_text']?></div>
<div id="sp_line" style="margin: 5px 0 0 0; height: 2px; background: #E6E7E1; line-height: 2px; overflow: hidden;"></div>
<p id="sp_smalltext" style="padding: 5px 0 20px 0; text-align: right; color: #999; font-size: 0.83em;">---- Comsenz.Com</p>
<table cellpadding="0" cellspacing="0">
<?
function getcolor($colorid, $id) {
return "<input id=\"c$colorid\" onclick=\"c{$colorid}_frame.location='images/admincp/getcolor.htm?c{$colorid}|{$id}';showMenu('c$colorid')\" type=\"button\" class=\"colorwd\" value=\"\" style=\"background: $background\"><span id=\"c{$colorid}_menu\" style=\"display: none\"><iframe name=\"c{$colorid}_frame\" src=\"\" frameborder=\"0\" width=\"166\" height=\"186\" scrolling=\"no\"></iframe></span>";
}
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_commonborder'].'</td><td><input id="commonborder" name="stylevar['.$stylestuff['commonborder']['id'].']" value="'.$stylestuff['commonborder']['subst'].'" size="10" onchange="$(\'sp_line\').style.backgroundColor = this.value;updatecolorpreview(\'c18\', \'commonborder\')" onclick="setfocus(this)" />'.getcolor(18, 'commonborder').'</td></tr>';
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_commonbg'].'</td><td><input id="commonbg" name="stylevar['.$stylestuff['commonbg']['id'].']" value="'.$stylestuff['commonbg']['subst'].'" size="10" onchange="$(\'sp_backcolor\').style.backgroundColor = this.value;updatecolorpreview(\'c19\', \'commonbg\')" onclick="setfocus(this)" />'.getcolor(19, 'commonbg').'</td></tr>';
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_font'].'</td><td><input name="stylevar['.$stylestuff['font']['id'].']" value="'.$stylestuff['font']['subst'].'" size="15" onchange="$(\'sp_tabletext\').style.fontFamily = this.value" />'.
' <input name="stylevar['.$stylestuff['fontsize']['id'].']" value="'.$stylestuff['fontsize']['subst'].'" size="5" onchange="$(\'sp_tabletext\').style.fontSize = this.value" /></td></tr>';
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_smfont'].'</td><td><input name="stylevar['.$stylestuff['smfont']['id'].']" value="'.$stylestuff['smfont']['subst'].'" size="15" onchange="$(\'sp_smalltext\').style.fontFamily = this.value" />'.
' <input name="stylevar['.$stylestuff['smfontsize']['id'].']" value="'.$stylestuff['smfontsize']['subst'].'" size="5" onchange="$(\'sp_smalltext\').style.fontSize = this.value" /></td></tr>';
echo '<tr><td width="100" id="spt_tabletext">'.$lang['styles_edit_visual_setting_tabletext'].'</td><td><input id="tabletext" name="stylevar['.$stylestuff['tabletext']['id'].']" value="'.$stylestuff['tabletext']['subst'].'" size="10" onchange="$(\'spt_tabletext\').style.color = $(\'sp_tabletext\').style.color = this.value;updatecolorpreview(\'c20\', \'tabletext\')" onclick="setfocus(this)" />'.getcolor(20, 'tabletext').'</td></tr>';
echo '<tr><td width="100" id="spt_midtext">'.$lang['styles_edit_visual_setting_midtext'].'</td><td><input id="midtext" name="stylevar['.$stylestuff['midtext']['id'].']" value="'.$stylestuff['midtext']['subst'].'" size="10" onchange="$(\'spt_midtext\').style.color = $(\'sp_midtext\').style.color = this.value;updatecolorpreview(\'c21\', \'midtext\')" onclick="setfocus(this)" />'.getcolor(21, 'midtext').'</td></tr>';
echo '<tr><td width="100" id="spt_lighttext">'.$lang['styles_edit_visual_setting_lighttext'].'</td><td><input id="lighttext" name="stylevar['.$stylestuff['lighttext']['id'].']" value="'.$stylestuff['lighttext']['subst'].'" size="10" onchange="$(\'spt_lighttext\').style.color = $(\'sp_smalltext\').style.color = this.value;updatecolorpreview(\'c22\', \'lighttext\')" onclick="setfocus(this)" />'.getcolor(22, 'lighttext').'</td></tr>';
echo '<tr><td width="100" id="spt_link">'.$lang['styles_edit_visual_setting_link'].'</td><td><input id="link" name="stylevar['.$stylestuff['link']['id'].']" value="'.$stylestuff['link']['subst'].'" size="10" onchange="$(\'spt_link\').style.color = $(\'sp_link\').style.color = this.value;updatecolorpreview(\'c23\', \'link\')" onclick="setfocus(this)" />'.getcolor(23, 'link').'</td></tr>';
echo '<tr><td width="100" id="spt_highlightlink">'.$lang['styles_edit_visual_setting_highlightlink'].'</td><td><input id="highlightlink" name="stylevar['.$stylestuff['highlightlink']['id'].']" value="'.$stylestuff['highlightlink']['subst'].'" size="10" onchange="$(\'spt_highlightlink\').style.color = $(\'sp_link\').style.color = this.value;updatecolorpreview(\'c24\', \'highlightlink\')" onclick="setfocus(this)" />'.getcolor(24, 'highlightlink').'</td></tr>';
echo '<tr><td width="100" id="spt_noticetext">'.$lang['styles_edit_visual_setting_noticetext'].'</td><td><input id="noticetext" name="stylevar['.$stylestuff['noticetext']['id'].']" value="'.$stylestuff['noticetext']['subst'].'" size="10" onchange="$(\'spt_noticetext\').style.color = $(\'sp_notice\').style.color = this.value;updatecolorpreview(\'c25\', \'noticetext\')" onclick="setfocus(this)" />'.getcolor(25, 'noticetext').'</td></tr>';
?>
</table>
</div>
</div>
<div id="sp_footer" style="margin: 0 auto 20px; color: #8691A2; text-align: center;">
<?=$lang['styles_edit_visual_footer']?>
</div>
</div>
</td><td valign="top" style="border: none;">
<script type="text/JavaScript">
var imgdirurl = '<? echo $imgdirurl = $stylestuff['styleimgdir']['subst'] ? $stylestuff['styleimgdir']['subst'] : ($stylestuff['imgdir']['subst'] ? $stylestuff['imgdir']['subst'] : 'images/default');?>/';
function imgdirurl_update() {
imgdirurl = ($('styleimgdir').value ? $('styleimgdir').value : ($('imgdir').value ? $('imgdir').value : 'images/default')) + '/';
}
function updatecolorpreview(obj, objv) {
$(obj).style.background = $(objv).value;
}
var colorfocus;
function setfocus(obj) {
colorfocus = obj;
}
function setgcolor(color) {
if(!colorfocus) {
alert('<?=$lang['styles_edit_visual_selectcolorbox']?>');
return;
}
colorfocus.value = color;
var change = colorfocus.onchange.toString();
if(change) {
var start = change.indexOf('{');
var end = change.lastIndexOf('}');
s = change.substring(start + 1, end);
s = s.replace(/this\.value/ig, "'" + colorfocus.value + "'");
eval(s)
}
}
</script>
<table cellpadding="0" cellspacing="0" width="100%" style="table-layout:fixed">
<?
$copystyle = array(
'wrapbg' => array('inputbg','dropmenubgcolor'),
'commonborder' => array('specialborder', 'dropmenuborder', 'floatmaskbgcolor', 'inputborder', 'inputborderdarkcolor', 'contentseparate'),
'commonbg' => array('specialbg', 'interleavecolor', 'floatbgcolor')
);
foreach($copystyle as $copysrc => $copydescs) {
foreach($copydescs as $copydesc) {
if($stylestuff[$copysrc]['subst'] == $stylestuff[$copydesc]['subst']) {
echo '<input type="hidden" name="copyids['.$stylestuff[$copysrc]['id'].'][]" value="'.$stylestuff[$copydesc]['id'].'" />';
}
}
}
echo '<tr><td width="100">'.$lang['styles_edit_visual_setting_boardimg'].'</td><td><input name="stylevar['.$stylestuff['boardimg']['id'].']" value="'.$stylestuff['boardimg']['subst'].'" size="10" onchange="$(\'sp_logo\').src = this.value ? imgdirurl + this.value : \'images/common/none.gif\'" /></td></tr>';
$stylestuff['headerbgcolor']['subst'] = explode(' ', $stylestuff['headerbgcolor']['subst']);
$headerbgcolor = $stylestuff['headerbgcolor']['subst'][0];
$headerbgimg = $stylestuff['headerbgcolor']['subst'][1];
$headerbgextra = implode(' ', array_slice($stylestuff['headerbgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_headerbgcolor'].'</td><td><div class="color"><input id="headerbgcolor" name="stylevar['.$stylestuff['headerbgcolor']['id'].']" value="'.$headerbgcolor.'" size="10" onchange="$(\'sp_header\').style.background = this.value + \' url(\' + imgdirurl + $(\'headerbgcolorimg\').value + \') \' + $(\'headerbgcolorextra\').value;updatecolorpreview(\'c1\', \'headerbgcolor\')" onclick="setfocus(this)" />'.getcolor(1, 'headerbgcolor').'</div>'.
' <input id="headerbgcolorimg" name="stylevarbgimg['.$stylestuff['headerbgcolor']['id'].']" value="'.$headerbgimg.'" size="10" onchange="$(\'sp_header\').style.background = $(\'headerbgcolor\').value + \' url(\' + imgdirurl + this.value + \') \' + $(\'headerbgcolorextra\').value" />'.
' <input id="headerbgcolorextra" name="stylevarbgextra['.$stylestuff['headerbgcolor']['id'].']" value="'.$headerbgextra.'" size="10" onchange="$(\'sp_header\').style.background = $(\'headerbgcolor\').value + \' url(\' + imgdirurl + $(\'headerbgcolorimg\').value + \') \' + this.value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_headerborder'].'</td><td><div class="color"><input id="headerbordercolor" name="stylevar['.$stylestuff['headerbordercolor']['id'].']" value="'.$stylestuff['headerbordercolor']['subst'].'" size="10" onchange="$(\'sp_menucurrent\').style.borderColor = this.value;$(\'sp_header\').style.borderBottom = $(\'headerborder\').value + \' solid \' + this.value;updatecolorpreview(\'c2\', \'headerbordercolor\')" onclick="setfocus(this)" />'.getcolor(2, 'headerbordercolor').'</div>'.
' <input id="headerborder" name="stylevar['.$stylestuff['headerborder']['id'].']" value="'.$stylestuff['headerborder']['subst'].'" size="10" onchange="$(\'sp_header\').style.borderBottom = this.value + \' solid \' + $(\'headerbordercolor\').value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_headertext'].'</td><td><div class="color"><input id="headertext" name="stylevar['.$stylestuff['headertext']['id'].']" value="'.$stylestuff['headertext']['subst'].'" size="10" onchange="$(\'sp_umenu\').style.color = this.value;updatecolorpreview(\'c3\', \'headertext\')" onclick="setfocus(this)" />'.getcolor(3, 'headertext').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menuborder'].'</td><td><div class="color"><input id="menuborder" name="stylevar['.$stylestuff['menuborder']['id'].']" value="'.$stylestuff['menuborder']['subst'].'" size="10" onchange="$(\'sp_menuitem\').style.borderColor = this.value;updatecolorpreview(\'c4\', \'menuborder\')" onclick="setfocus(this)" />'.getcolor(4, 'menuborder').'</div></td></tr>';
$stylestuff['menubgcolor']['subst'] = explode(' ', $stylestuff['menubgcolor']['subst']);
$menubgcolor = $stylestuff['menubgcolor']['subst'][0];
$menubgimg = $stylestuff['menubgcolor']['subst'][1];
$menubgextra = implode(' ', array_slice($stylestuff['menubgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_menubgcolor'].'</td><td><div class="color"><input id="menubgcolor" name="stylevar['.$stylestuff['menubgcolor']['id'].']" value="'.$menubgcolor.'" size="10" onchange="$(\'sp_menuitem\').style.background = this.value + \' url(\' + imgdirurl + $(\'menubgcolorimg\').value + \') \' + $(\'menubgcolorextra\').value;updatecolorpreview(\'c5\', \'menubgcolor\')" onclick="setfocus(this)" />'.getcolor(5, 'menubgcolor').'</div>'.
' <input id="menubgcolorimg" name="stylevarbgimg['.$stylestuff['menubgcolor']['id'].']" value="'.$menubgimg.'" size="10" onchange="$(\'sp_menuitem\').style.background = $(\'menubgcolor\').value + \' url(\' + imgdirurl + this.value + \') \' + $(\'menubgcolorextra\').value;" />'.
' <input id="menubgcolorextra" name="stylevarbgextra['.$stylestuff['menubgcolor']['id'].']" value="'.$menubgextra.'" size="10" onchange="$(\'sp_menuitem\').style.background = $(\'menubgcolor\').value + \' url(\' + imgdirurl + $(\'menubgcolorimg\').value + \') \' + this.value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menutext'].'</td><td><div class="color"><input id="menutext" name="stylevar['.$stylestuff['menutext']['id'].']" value="'.$stylestuff['menutext']['subst'].'" size="10" onchange="$(\'sp_menu\').style.color = this.value;updatecolorpreview(\'c6\', \'menutext\')" onclick="setfocus(this)" />'.getcolor(6, 'menutext').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menuhover'].'</td><td><div class="color"><input id="menuhover" name="stylevar['.$stylestuff['menuhover']['id'].']" value="'.$stylestuff['menuhover']['subst'].'" size="10" onchange="$(\'sp_menucurrent\').style.backgroundColor = this.value;updatecolorpreview(\'c7\', \'menuhover\')" onclick="setfocus(this)" />'.getcolor(7, 'menuhover').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_menuhovertext'].'</td><td><div class="color"><input id="menuhovertext" name="stylevar['.$stylestuff['menuhovertext']['id'].']" value="'.$stylestuff['menuhovertext']['subst'].'" size="10" onchange="$(\'sp_menucurrent\').style.color = this.value;updatecolorpreview(\'c8\', \'menuhovertext\')" onclick="setfocus(this)" />'.getcolor(8, 'menuhovertext').'</div></td></tr>';
$stylestuff['bgcolor']['subst'] = explode(' ', $stylestuff['bgcolor']['subst']);
$bgcolor = $stylestuff['bgcolor']['subst'][0];
$bgcolorimg = $stylestuff['bgcolor']['subst'][1];
$bgcolorextra = implode(' ', array_slice($stylestuff['bgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_bgcolor'].'</td><td><div class="color"><input id="bgcolor" name="stylevar['.$stylestuff['bgcolor']['id'].']" value="'.$bgcolor.'" size="10" onchange="$(\'style_preview\').style.background = this.value + \' url(\' + imgdirurl + $(\'bgcolorimg\').value + \') \' + $(\'bgcolorextra\').value;updatecolorpreview(\'c9\', \'bgcolor\')" onclick="setfocus(this)" />'.getcolor(9, 'bgcolor').'</div>'.
' <input id="bgcolorimg" name="stylevarbgimg['.$stylestuff['bgcolor']['id'].']" value="'.$bgcolorimg.'" size="10" onchange="$(\'style_preview\').style.background = $(\'bgcolor\').value + \' url(\' + imgdirurl + this.value + \') \' + $(\'bgcolorextra\').value" />'.
' <input id="bgcolorextra" name="stylevarbgextra['.$stylestuff['bgcolor']['id'].']" value="'.$bgcolorextra.'" size="10" onchange="$(\'style_preview\').style.background = $(\'bgcolor\').value + \' url(\' + imgdirurl + $(\'bgcolorimg\').value + \') \' + this.value" /></td></tr>';
$stylestuff['sidebgcolor']['subst'] = explode(' ', $stylestuff['sidebgcolor']['subst']);
$sidebgcolor = $stylestuff['sidebgcolor']['subst'][0];
$sidebgcolorimg = $stylestuff['sidebgcolor']['subst'][1];
$sidebgcolorextra = implode(' ', array_slice($stylestuff['sidebgcolor']['subst'], 2));
echo '<tr><td>'.$lang['styles_edit_visual_setting_sidebgcolor'].'</td><td><input id="sidebgcolorimg" name="stylevarbgimg['.$stylestuff['sidebgcolor']['id'].']" value="'.$sidebgcolorimg.'" size="10" onchange="$(\'sp_wrap\').style.backgroundImage = \'url(\' + imgdirurl + this.value + \')\'" /><input name="stylevar['.$stylestuff['sidebgcolor']['id'].']" type="hidden" value="'.$sidebgcolor.'"><input name="stylevarbgextra['.$stylestuff['sidebgcolor']['id'].']" type="hidden" value="'.$sidebgcolorextra.'"></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_wrapwidth'].'</td><td><input name="stylevar['.$stylestuff['wrapwidth']['id'].']" value="'.$stylestuff['wrapwidth']['subst'].'" size="10" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_wrapbg'].'</td><td><div class="color"><input id="wrapbg" name="stylevar['.$stylestuff['wrapbg']['id'].']" value="'.$stylestuff['wrapbg']['subst'].'" size="10" onchange="$(\'sp_wrap\').style.backgroundColor = this.value;updatecolorpreview(\'c10\', \'wrapbg\')" onclick="setfocus(this)" />'.getcolor(10, 'wrapbg').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_wrapborder'].'</td><td><div class="color"><input id="wrapbordercolor" name="stylevar['.$stylestuff['wrapbordercolor']['id'].']" value="'.$stylestuff['headerbordercolor']['subst'].'" size="10" onchange="$(\'sp_wrap\').style.border = $(\'wrapborder\').value + \' solid \' + this.value;updatecolorpreview(\'c11\', \'wrapbordercolor\')" onclick="setfocus(this)" />'.getcolor(11, 'wrapbordercolor').'</div>'.
' <input id="wrapborder" name="stylevar['.$stylestuff['wrapborder']['id'].']" value="'.$stylestuff['wrapborder']['subst'].'" size="10" onchange="$(\'sp_wrap\').style.border = this.value + \' solid \' + $(\'wrapbordercolor\').value" /></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_setting_footertext'].'</td><td><div class="color"><input id="footertext" name="stylevar['.$stylestuff['footertext']['id'].']" value="'.$stylestuff['footertext']['subst'].'" size="10" onchange="$(\'sp_footer\').style.color = this.value;updatecolorpreview(\'c12\', \'footertext\')" onclick="setfocus(this)" />'.getcolor(12, 'footertext').'</div></td></tr>';
echo '<tr><td>'.$lang['styles_edit_visual_getcolorfromimg'].'</td><td><input id="imgurl" size="10"> <a href="javascript:;" onclick="ajaxget(\''.$BASESCRIPT.'?action=styles&operation=getcolor&file=\' + $(\'imgurl\').value, \'colorlist\')">'.$lang['styles_edit_visual_getcolor'].'</a></td></tr>';
echo '<tr><td></td><td><div id="colorlist"></div></td></tr>';
?>
</td><tr></table>
</td><tr></table>
<script>
var inps = $('previewbody').getElementsByTagName('INPUT');
for(i = 0;i < inps.length;i++) {
if(inps[i].onchange) {
var change = inps[i].onchange.toString();
if(change) {
var start = change.indexOf('{');
var end = change.lastIndexOf('}');
s = change.substring(start + 1, end);
s = s.replace(/this\.value/ig, "'" + inps[i].value + "'");
eval(s)
}
}
}
</script>
</td></tr>
<?
showsubmit('editsubmit', 'submit', '', '<input type="button" class="btn" onclick="location.href=\''.$BASESCRIPT.'?action=styles&operation=edit&id='.$id.'&adv=1\'" value="'.$lang['styles_edit_adv_switch'].'">');
showtablefooter();
showformfooter();
}
} else {
if($newcvar && $newcsubst) {
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}stylevars WHERE variable='$newcvar' AND styleid='$id'")) {
cpmsg('styles_edit_variable_duplicate', '', 'error');
} elseif(!preg_match("/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/", $newcvar)) {
cpmsg('styles_edit_variable_illegal', '', 'error');
}
$newcvar = strtolower($newcvar);
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$id', '$newcvar', '$newcsubst')");
}
$db->query("UPDATE {$tablepre}styles SET name='$namenew', templateid='$templateidnew' WHERE styleid='$id'");
foreach($stylevar as $varid => $substitute) {
if(!empty($stylevarbgimg[$varid])) {
$substitute .= ' '.$stylevarbgimg[$varid];
if(!empty($stylevarbgextra[$varid])) {
$substitute .= ' '.$stylevarbgextra[$varid];
}
}
$substitute = @htmlspecialchars($substitute);
$stylevarids = "'$varid'";
if(!empty($copyids[$varid])) {
$stylevarids .= ','.implodeids($copyids[$varid]);
}
$db->query("UPDATE {$tablepre}stylevars SET substitute='$substitute' WHERE stylevarid IN ($stylevarids) AND styleid='$id'");
}
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}stylevars WHERE stylevarid IN ($ids) AND styleid='$id'");
}
updatecache('styles');
cpmsg('styles_edit_succeed', $BASESCRIPT.'?action=styles'.($newcvar && $newcsubst ? '&operation=edit&id='.$id : ''), 'succeed');
}
} elseif($operation == 'getcolor') {
$imginfo = @getimagesize($file);
if(!$imginfo) {
$inajax = 1;showmessage($lang['styles_edit_visual_getcolor_fileerror']);
}
$im = '';
switch($imginfo['mime']) {
case 'image/jpeg':
$im = function_exists('imagecreatefromjpeg') ? imagecreatefromjpeg($file) : '';
break;
case 'image/gif':
$im = function_exists('imagecreatefromgif') ? imagecreatefromgif($file) : '';
break;
case 'image/png':
$im = function_exists('imagecreatefrompng') ? imagecreatefrompng($file) : '';
break;
}
if(!$im || !function_exists('imageistruecolor') ||
!function_exists('imagetruecolortopalette') ||
!function_exists('imagecreatetruecolor') ||
!function_exists('imagecopy') ||
!function_exists('imagecolorstotal') ||
!function_exists('imagecolorsforindex')) {
$inajax = 1;showmessage($lang['styles_edit_visual_getcolor_nosupport']);
}
if(!imageistruecolor($im)) {
$imt = imagecreatetruecolor($imginfo[0], $imginfo[1]);
imagecopy($imt, $im, 0, 0, 0, 0, $imginfo[0], $imginfo[1]);
$im = $imt;
}
imagetruecolortopalette($im, 1, 64);
$colorn = imagecolorstotal($im);
$colors = array();
for($i = 0;$i < $colorn;$i++) {
$rgb = imagecolorsforindex($im, $i);
$color = sprintf('%02s', dechex($rgb['red'])).sprintf('%02s', dechex($rgb['green'])).sprintf('%02s', dechex($rgb['blue']));
if($color != 'ffffff') {
$colors[] = $color;
}
}
$colors = array_unique($colors);
sort($colors);
include template('header_ajax');
for($i = 0;$i < count($colors);$i++) {
echo '<p onclick="setgcolor(\'#'.$colors[$i].'\')" style="float:left;width:20px;height:20px;cursor:pointer;background-color: #'.$colors[$i].'"> </p>';
}
include template('footer_ajax');
exit;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/styles.inc.php
|
PHP
|
asf20
| 47,625
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: faq.inc.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!isfounder()) cpmsg('noaccess_isfounder', '', 'error');
$operation = $operation ? $operation : 'list';
if($operation == 'list') {
if(!submitcheck('faqsubmit')) {
shownav('extended', 'faq');
showsubmenu('faq');
showformheader('faq&operation=list');
showtableheader();
echo '<tr><th class="td25"></th><th>'.$lang['display_order'].'</th><th style="width:350px">'.$lang['faq_thread'].'</th><th class="td24">'.$lang['faq_sortup'].'</th><th></th></tr>';
$faqparent = $faqsub = array();
$faqlists = $faqselect = '';
$query = $db->query("SELECT * FROM {$tablepre}faqs ORDER BY displayorder");
while($faq = $db->fetch_array($query)) {
if(empty($faq['fpid'])) {
$faqparent[$faq['id']] = $faq;
$faqselect .= "<option value=\"$faq[id]\">$faq[title]</option>";
} else {
$faqsub[$faq['fpid']][] = $faq;
}
}
foreach($faqparent as $parent) {
$disabled = !empty($faqsub[$parent['id']]) ? 'disabled' : '';
showtablerow('', array('', 'class="td23 td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$parent[id]\" $disabled>",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$parent[id]]\" value=\"$parent[displayorder]\">",
"<div class=\"parentnode\"><input type=\"text\" class=\"txt\" size=\"30\" name=\"title[$parent[id]]\" value=\"".dhtmlspecialchars($parent['title'])."\"></div>",
$lang[none],
"<a href=\"$BASESCRIPT?action=faq&operation=detail&id=$parent[id]\" class=\"act\">".$lang['detail']."</a>"
));
if(!empty($faqsub[$parent['id']])) {
foreach($faqsub[$parent['id']] as $sub) {
showtablerow('', array('', 'class="td23 td28"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$sub[id]\">",
"<input type=\"text\" class=\"txt\" size=\"3\" name=\"displayorder[$sub[id]]\" value=\"$sub[displayorder]\">",
"<div class=\"node\"><input type=\"text\" class=\"txt\" size=\"30\" name=\"title[$sub[id]]\" value=\"".dhtmlspecialchars($sub['title'])."\"></div>",
$faqparent[$sub['fpid']][title],
"<a href=\"$BASESCRIPT?action=faq&operation=detail&id=$sub[id]\" class=\"act\">".$lang['detail']."</a>"
));
}
}
echo '<tr><td></td><td></td><td colspan="3"><div class="lastnode"><a href="###" onclick="addrow(this, 1, '.$parent['id'].')" class="addtr">'.lang('faq_additem').'</a></div></td></tr>';
}
echo '<tr><td></td><td></td><td colspan="3"><div><a href="###" onclick="addrow(this, 0, 0)" class="addtr">'.lang('faq_addcat').'</a></div></td></tr>';
echo <<<EOT
<script type="text/JavaScript">
var rowtypedata = [
[[1,''], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td25'], [1, '<input name="newtitle[]" value="" size="30" type="text" class="txt">'], [2, '<input type="hidden" name="newfpid[]" value="0" />']],
[[1,''], [1,'<input name="newdisplayorder[]" value="" size="3" type="text" class="txt">', 'td25'], [1, '<div class=\"node\"><input name="newtitle[]" value="" size="30" type="text" class="txt"></div>'], [2, '<input type="hidden" name="newfpid[]" value="{1}" />']]
];
</script>
EOT;
showsubmit('faqsubmit', 'submit', 'del');
showtablefooter();
showformfooter();
} else {
if($ids = implodeids($delete)) {
$db->query("DELETE FROM {$tablepre}faqs WHERE id IN ($ids)");
}
if(is_array($title)) {
foreach($title as $id => $val) {
$db->query("UPDATE {$tablepre}faqs SET displayorder='$displayorder[$id]', title='$title[$id]' WHERE id='$id'");
}
}
if(is_array($newtitle)) {
foreach($newtitle as $k => $v) {
$v = trim($v);
if($v) {
$db->query("INSERT INTO {$tablepre}faqs (fpid, displayorder, title)
VALUES ('".intval($newfpid[$k])."', '".intval($newdisplayorder[$k])."', '$v')");
}
}
}
cpmsg('faq_list_update', $BASESCRIPT.'?action=faq&operation=list', 'succeed');
}
} elseif($operation == 'detail') {
if(!submitcheck('detailsubmit')) {
$faq = $db->fetch_first("SELECT * FROM {$tablepre}faqs WHERE id='$id'");
if(!$faq) {
cpmsg('undefined_action', '', 'error');
}
$query = $db->query("SELECT * FROM {$tablepre}faqs WHERE fpid='0' ORDER BY displayorder, fpid ");
while($parent = $db->fetch_array($query)) {
$faqselect .= "<option value=\"$parent[id]\" ".($faq['fpid'] == $parent['id'] ? 'selected' : '').">$parent[title]</option>";
}
shownav('extended', 'faq');
showsubmenu('faq');
showformheader("faq&operation=detail&id=$id");
showtableheader();
showtitle('faq_edit');
showsetting('faq_title', 'titlenew', $faq['title'], 'text');
if(!empty($faq['fpid'])) {
showsetting('faq_sortup', '', '', '<select name="fpidnew"><option value=\"\">'.$lang['none'].'</option>'.$faqselect.'</select>');
showsetting('faq_identifier', 'identifiernew', $faq['identifier'], 'text');
showsetting('faq_keywords', 'keywordnew', $faq['keyword'], 'text');
showsetting('faq_content', 'messagenew', $faq['message'], 'textarea');
}
showsubmit('detailsubmit');
showtablefooter();
showformfooter();
} else {
if(!$titlenew) {
cpmsg('faq_no_title', '', 'error');
}
if(!empty($identifiernew)) {
$query = $db->query("SELECT id FROM {$tablepre}faqs WHERE identifier='$identifiernew' AND id!='$id'");
if($db->num_rows($query)) {
cpmsg('faq_identifier_invalid', '', 'error');
}
}
if(strlen($keywordnew) > 50) {
cpmsg('faq_keyword_toolong', '', 'error');
}
$fpidnew = $fpidnew ? intval($fpidnew) : 0;
$titlenew = trim($titlenew);
$messagenew = trim($messagenew);
$identifiernew = trim($identifiernew);
$keywordnew = trim($keywordnew);
$db->query("UPDATE {$tablepre}faqs SET fpid='$fpidnew', identifier='$identifiernew', keyword='$keywordnew', title='$titlenew', message='$messagenew' WHERE id='$id'");
updatecache('faqs');
cpmsg('faq_list_update', $BASESCRIPT.'?action=faq&operation=list', 'succeed');
}
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/faq.inc.php
|
PHP
|
asf20
| 6,333
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: jswizard.inc.php 17524 2009-01-12 04:46:51Z monkey $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
if(!empty($previewurl)) {
include_once DISCUZ_ROOT.'./forumdata/cache/cache_request.php';
require_once DISCUZ_ROOT.'./include/request.func.php';
parse_str($jsurl.'&nocache=yes', $requestdata);
if($requestdata['function'] == 'side') {
$tags = '<div id="wrap" class="wrap with_side s_clear" style="width:90%;height:auto;min-height:50px !important"><div class="main"><div class="content"></div></div><div id="sidebar" class="side"><div>';
} else {
$tags = '<div id="wrap" class="wrap s_clear" style="width:90%;height:auto;min-height:50px !important"><div class="main"><div class="content">';
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" /><head><script type="text/javascript" src="include/js/common.js"></script></head><link rel="stylesheet" type="text/css" href="forumdata/cache/style_'.STYLEID.'_common.css" />';
echo "\n\n<body><div id=\"append_parent\"></div><div id=\"ajaxwaitid\"></div>$tags\n\n".parse_request($requestdata, '', 0)."\n\n</div></div></div></body>\n\n</html>";
exit;
}
cpheader();
$jstypes = array(0 => 'threads', 1 => 'forums', 2 => 'memberrank', 3 => 'stats', 4 => 'images', 5 => 'module', -2 => 'side', -1 => 'custom');
$from = $action == 'jswizard' && $operation != 'infoside' ? 'jswizard' : $from;
$infosidemenu = array(array('menu' => 'nav_infoside', 'submenu' => array(
array('jswizard_infoside_global', 'jswizard&operation=infoside&from='.$from),
array('jswizard_infoside_2', 'jswizard&operation=infoside&sideid=2&from='.$from),
array('jswizard_infoside_0', 'jswizard&operation=infoside&sideid=0&from='.$from),
)), '', $operation == 'infoside' ? 1 : 0);
$addmenu = array();
foreach($jstypes as $k => $v) {
if($k != 5) {
$addmenu[] = array('jswizard_'.$v, 'jswizard&type='.$v);
}
}
if(!$operation) {
shownav('tools', 'nav_javascript');
$jswizard = array();
$query = $db->query("SELECT * FROM {$tablepre}request WHERE variable LIKE '".($jssetting != '' ? $jssetting : ($jskey != '' ? $jskey : '%'))."'");
while($settings = $db->fetch_array($query)) {
$jswizard[$settings['variable']] = unserialize($settings['value']);
$jswizard[$settings['variable']]['type'] = $settings['type'];
}
$type = !empty($function) ? $function : (isset($type) ? $type : '');
$edit = isset($edit) ? $edit : NULL;
$jskeyempty = 0;
$editext = ($jssetting || $edit) ? '<input type="hidden" name="edit" value="'.dhtmlspecialchars($jssetting ? $jssetting : $edit).'">' : '';
ksort($jswizard);
if(!empty($type)) {
list($keypre, $keyp) = explode('_', $jssetting);
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard'.($keyp ? '&openkeypre='.$keypre : ''), 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', $type != 'module' ? 1 : 0),
array('jswizard_module', 'jswizard&type=module', $type != 'module' ? 0 : 1),
array('import', 'jswizard&operation=import', 0),
));
if(empty($jskey)) {
$jskey = $lang['jswizard_'.$type].'_'.random(3);
$jskeyempty = 1;
}
$jspreview = '';
$comment = !empty($comment) ? $comment : $jswizard[$jssetting]['comment'];
if(!empty($function) && !empty($jssetting) && isset($jswizard[$jssetting]['url'])) {
$parameter = $jswizard[$jssetting]['parameter'];
$jskey = $jssetting;
$jssetting = $jswizard[$jssetting]['url'];
$preview = $jssubmit = TRUE;
$jskeyempty = 0;
} else {
$jssetting = '';
}
}
$jskey = stripslashes(trim($jskey));
if(empty($type)) {
list($keypre, $keyp) = explode('_', $jssetting);
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard', 1),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 0)
));
if(!submitcheck('jsdelsubmit') && !submitcheck('jsexportsubmit')) {
showformheader('jswizard');
showtableheader();
showsubtitle(array('', 'jswizard_key', 'jswizard_desc', 'jswizard_cache', 'type', ''));
$lastpre = '';
$openkeypre = isset($openkeypre) ? $openkeypre : '';
echo '<tbody>';
foreach($jswizard as $key => $jssetting) {
list($keypre, $keyp) = explode('_', $key);
if($keyp) {
if($keypre != $lastpre) {
echo '</tbody>';
showtablerow('', array('class="td25"', '', 'width="40%"', 'width="10%"', 'width="20%"'), array(
'',
'<a href="javascript:;" onclick="display(\'key_'.$keypre.'\')"><span class="bold">['.$keypre.']</span></a>',
'',
'',
'',
''
));
echo '<tbody id="key_'.$keypre.'"'.($keypre != $openkeypre ? 'style="display: none"' : '').'>';
$inpre = ' ';
}
} else {
echo '<tbody>';
$inpre = '';
}
$lastpre = $keypre;
showtablerow('', array('class="td25"', '', 'width="40%"', 'width="10%"', 'width="20%"'), array(
!@in_array($key, $infosidestatus) ? '<input class="checkbox" type="checkbox" name="keyarray[]" value="'.dhtmlspecialchars($key).'">' : '<input class="checkbox" type="checkbox" disabled="disabled">',
$inpre.'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$jssetting['type']].'&jssetting='.rawurlencode($key).'"><span class="bold">'.($inpre ? substr($key, strlen($keypre) + 1) : $key).'</span></a>',
$jssetting['comment'].' ',
($jssetting['parameter']['cachelife'] !== '' ? $jssetting['parameter']['cachelife'] : '<font class="lightfont">'.$jscachelife.'</font>'),
(in_array($jstypes[$jssetting['type']], array('custom', 'side')) ? '<b>'.$lang['jswizard_'.$jstypes[$jssetting['type']]].'</b>' : $lang['jswizard_'.$jstypes[$jssetting['type']]]).
($jssetting['parameter']['sidestatus'] ? ' ('.$lang['jswizard_for_side'].')' : ''),
'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$jssetting['type']].'&jssetting='.rawurlencode($key).'">'.$lang['edit'].'</a> '.
'<a href="'.$BASESCRIPT.'?action=jswizard&operation=copy&jssetting='.rawurlencode($key).'">'.$lang['copy'].'</a> '
));
}
echo '</tbody>';
showtablerow('', array('', 'colspan="5"'), array(
'<input type="checkbox" name="chkall" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'keyarray\')">'.lang('select_all'),
'<input type="submit" class="btn" name="jsdelsubmit" value="'.$lang['delete'].'"> <input type="submit" class="btn" name="jsexportsubmit" value="'.$lang['export'].'">'
));
showtablefooter();
showformfooter();
} elseif(submitcheck('jsdelsubmit')) {
if(is_array($keyarray)) {
$keys = implode("','", $keyarray);
$db->query("DELETE FROM {$tablepre}request WHERE variable IN ('$keys')");
updatecache('request');
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard', 'succeed');
} else {
header("location: $boardurl$BASESCRIPT?action=jswizard");
dexit();
}
} elseif(submitcheck('jsexportsubmit')) {
if(is_array($keyarray)) {
$keys = implode("','", $keyarray);
$query = $db->query("SELECT * FROM {$tablepre}request WHERE variable IN ('$keys')");
$exportdataarray = array();
while($exportdata = $db->fetch_array($query)) {
$value = unserialize($exportdata['value']);
$value['type'] = $exportdata['type'];
switch($value['type']) {
case 0:
unset($value['parameter']['threads_forums']);
unset($value['parameter']['tids']);
unset($value['parameter']['typeids']);
break;
case 1:
unset($value['parameter']['forums_forums']);
break;
case 4:
unset($value['parameter']['images_forums']);
break;
}
$exportdataarray[$exportdata['variable']] = serialize($value);
}
$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);
$jswizard_export = "# Discuz! Request Dump\n".
"# Version: Discuz! $version\n".
"# Time: $time \n".
"# From: $bbname ($boardurl) \n".
"#\n".
"# Discuz! Community: http://www.Discuz.net\n".
"# Please visit our website for latest news about Discuz!\n".
"# --------------------------------------------------------\n\n\n".
wordwrap(base64_encode(serialize($exportdataarray)), 60, "\n", 1);
ob_end_clean();
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Encoding: none');
header('Content-Length: '.strlen($jswizard_export));
header('Content-Disposition: attachment; filename=discuz_request_'.date('Ymd').'.txt');
header('Content-Type: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
echo $jswizard_export;
dexit();
} else {
header("location: {$boardurl}$BASESCRIPT?action=jswizard");
dexit();
}
}
} elseif($type == 'threads') {
$tcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'lastpost') => 'checked');
for($i = 0; $i <= 6; $i++) {
$tcheckspecial[$i] = !empty($parameter['special'][$i]) ? 'checked' : '';
$tcheckdigest[$i] = !empty($parameter['digest'][$i]) ? 'checked' : '';
$tcheckstick[$i] = !empty($parameter['stick'][$i]) ? 'checked' : '';
}
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
$jsthreadtypeselect = '<select multiple="multiple" name="parameter[typeids][]" size="10"><option value="all">'.$lang['jswizard_all_typeids'].'</optoin><option value=""> </option>';
$jsthreadsortselect = '<select multiple="multiple" name="parameter[sortids][]" size="10"><option value="all">'.$lang['jswizard_all_sortids'].'</optoin><option value=""> </option>';
$query = $db->query("SELECT typeid, name, special FROM {$tablepre}threadtypes ORDER BY typeid DESC");
while($threadtype = $db->fetch_array($query)) {
if($threadtype['special']) {
$jsthreadsortselect .= '<option value="'.$threadtype['typeid'].'" '.(isset($parameter['sortids']) && in_array($threadtype['typeid'], $parameter['sortids']) ? 'selected' : '').'>'.$threadtype['name'].'</option>';
} else {
$jsthreadtypeselect .= '<option value="'.$threadtype['typeid'].'" '.(isset($parameter['typeids']) && in_array($threadtype['typeid'], $parameter['typeids']) ? 'selected' : '').'>'.$threadtype['name'].'</option>';
}
}
$jsthreadtypeselect .= '</select>';
$jsthreadsortselect .= '</select>';
$trewardstatus = array(intval($parameter['rewardstatus']) => 'checked');
if($jssubmit && $function == 'threads') {
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['threads_forums'] && !in_array('all', $parameter['threads_forums'])? '&fids='.jsfids($parameter['threads_forums']) : '').
"&sidestatus=$parameter[sidestatus]".
"&maxlength=$parameter[maxlength]".
"&fnamelength=$parameter[fnamelength]".
"&messagelength=$parameter[messagelength]".
"&startrow=$parameter[startrow]".
"&picpre=".rawurlencode($parameter['picpre']).
"&items=$parameter[items]".
"&tag=".rawurlencode($parameter[tag]).
'&tids='.str_replace(',', '_', $parameter['tids']).
($parameter['keyword'] ? '&keyword='.rawurlencode($parameter['keyword']) : '').
($parameter['typeids'] && !in_array('all', $parameter['typeids'])? '&typeids='.jsfids($parameter['typeids']) : '').
($parameter['sortids'] && !in_array('all', $parameter['sortids'])? '&sortids='.jsfids($parameter['sortids']) : '').
"&special=".bindec(intval($parameter['special'][1]).intval($parameter['special'][2]).intval($parameter['special'][3]).intval($parameter['special'][4]).intval($parameter['special'][5]).intval($parameter['special'][6]).intval($parameter['special'][0])).
"&rewardstatus=$parameter[rewardstatus]".
"&digest=".bindec(intval($parameter['digest'][1]).intval($parameter['digest'][2]).intval($parameter['digest'][3]).intval($parameter['digest'][4])).
"&stick=".bindec(intval($parameter['stick'][1]).intval($parameter['stick'][2]).intval($parameter['stick'][3]).intval($parameter['stick'][4])).
"&recommend=$parameter[recommend]".
"&newwindow=$parameter[newwindow]".
"&threadtype=$parameter[threadtype]".
"&threadsort=$parameter[threadsort]".
"&highlight=$parameter[highlight]".
"&orderby=$parameter[orderby]".
"&hours=".intval($parameter['hours']).
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(0);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=threads#'.$lang['jswizard_threads']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_threads').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_threads_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{prefix} {subject}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_threads');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_threads_fids', '', '', jsforumselect('threads'));
showsetting('jswizard_sidestatus', 'parameter[sidestatus]', $parameter['sidestatus'], 'radio');
showsetting('jswizard_threads_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_threads_items', 'parameter[items]', isset($parameter['items']) ? $parameter['items'] : 10, 'text');
showsetting('jswizard_threads_maxlength', 'parameter[maxlength]', isset($parameter['maxlength']) ? $parameter['maxlength'] : 50, 'text');
showsetting('jswizard_threads_fnamelength', 'parameter[fnamelength]', $parameter['fnamelength'], 'radio');
showsetting('jswizard_threads_messagelength', 'parameter[messagelength]', $parameter['messagelength'], 'text');
showsetting('jswizard_threads_picpre', 'parameter[picpre]', $parameter['picpre'], 'text');
showsetting('jswizard_threads_tids', 'parameter[tids]', ($parameter['tids'] ? str_replace('_', ',', $parameter['tids']) : ''), 'text');
showsetting('jswizard_threads_keyword', 'parameter[keyword]', $parameter['keyword'], 'text');
showsetting('jswizard_threads_tag', 'parameter[tag]', $parameter['tag'], 'text');
showsetting('jswizard_threads_typeids', '', '', $jsthreadtypeselect);
showsetting('jswizard_threads_threadtype', 'parameter[threadtype]', $parameter['threadtype'], 'radio');
showsetting('jswizard_threads_sortids', '', '', $jsthreadsortselect);
showsetting('jswizard_threads_threadsort', 'parameter[threadsort]', $parameter['threadsort'], 'radio');
showsetting('jswizard_threads_highlight', 'parameter[highlight]', $parameter['highlight'], 'radio');
showsetting('jswizard_threads_special', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckspecial[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][1]" value="1" '.$tcheckspecial[1].'> '.$lang['thread_poll'].'</li>
<li'.($tcheckspecial[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][2]" value="1" '.$tcheckspecial[2].'> '.$lang['thread_trade'].'</li>
<li'.($tcheckspecial[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" onclick="$(\'special_reward_ext\').style.display = this.checked ? \'\' : \'none\'" name="parameter[special][3]" value="1" '.$tcheckspecial[3].'> '.$lang['thread_reward'].'</li>
<li'.($tcheckspecial[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][4]" value="1" '.$tcheckspecial[4].'> '.$lang['thread_activity'].'</li>
<li'.($tcheckspecial[5] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][5]" value="1" '.$tcheckspecial[5].'> '.$lang['thread_debate'].'</li>
<li'.($tcheckspecial[6] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][6]" value="1" '.$tcheckspecial[6].'> '.$lang['thread_video'].'</li>
<li'.($tcheckspecial[0] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[special][0]" value="1" '.$tcheckspecial[0].'> '.$lang['jswizard_special_0'].'</li></ul>'
);
showtagheader('tbody', 'special_reward_ext', $tcheckspecial[3], 'sub');
showsetting('jswizard_threads_special_reward', array('parameter[rewardstatus]', array(
array(0, $lang['jswizard_threads_special_reward_0']),
array(1, $lang['jswizard_threads_special_reward_1']),
array(2, $lang['jswizard_threads_special_reward_2'])
), 1), $parameter['rewardstatus'], 'mradio');
showtagfooter('tbody');
showsetting('jswizard_threads_digest', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckdigest[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][1]" value="1" '.$tcheckdigest[1].'> '.$lang['jswizard_digest_1'].'</li>
<li'.($tcheckdigest[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][2]" value="1" '.$tcheckdigest[2].'> '.$lang['jswizard_digest_2'].'</li>
<li'.($tcheckdigest[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][3]" value="1" '.$tcheckdigest[3].'> '.$lang['jswizard_digest_3'].'</li>
<li'.($tcheckdigest[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][4]" value="1" '.$tcheckdigest[4].'> '.$lang['jswizard_digest_0'].'</li></ul>'
);
showsetting('jswizard_threads_stick', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckstick[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][1]" value="1" '.$tcheckstick[1].'> '.$lang['jswizard_stick_1'].'</li>
<li'.($tcheckstick[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][2]" value="1" '.$tcheckstick[2].'> '.$lang['jswizard_stick_2'].'</li>
<li'.($tcheckstick[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][3]" value="1" '.$tcheckstick[3].'> '.$lang['jswizard_stick_3'].'</li>
<li'.($tcheckstick[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[stick][4]" value="1" '.$tcheckstick[4].'> '.$lang['jswizard_stick_0'].'</li></ul>'
);
showsetting('jswizard_threads_recommend', 'parameter[recommend]', $parameter['recommend'], 'radio');
showsetting('jswizard_threads_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_threads_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckorderby['lastpost'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="lastpost" '.$tcheckorderby['lastpost'].'> '.$lang['jswizard_threads_orderby_lastpost'].'</li>
<li'.($tcheckorderby['dateline'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="dateline" '.$tcheckorderby['dateline'].'> '.$lang['jswizard_threads_orderby_dateline'].'</li>
<li'.($tcheckorderby['replies'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="replies" '.$tcheckorderby['replies'].'> '.$lang['jswizard_threads_orderby_replies'].'</li>
<li'.($tcheckorderby['views'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="views" '.$tcheckorderby['views'].'> '.$lang['jswizard_threads_orderby_views'].'</li>
<li'.($tcheckorderby['hourviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="hourviews" '.$tcheckorderby['hourviews'].'> <input type="text" class="txt" name="parameter[hours]" value="'.$parameter['hours'].'" style="width: 50px;" size="6"> '.$lang['jswizard_threads_orderby_hourviews'].'</li>
<li'.($tcheckorderby['todayviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="todayviews" '.$tcheckorderby['todayviews'].'> '.$lang['jswizard_threads_orderby_todayviews'].'</li>
<li'.($tcheckorderby['weekviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="weekviews" '.$tcheckorderby['weekviews'].'> '.$lang['jswizard_threads_orderby_weekviews'].'</li>
<li'.($tcheckorderby['monthviews'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="monthviews" '.$tcheckorderby['monthviews'].'> '.$lang['jswizard_threads_orderby_monthviews'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'forums') {
$fcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'displayorder') => 'checked');
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
if($jssubmit && $function == 'forums') {
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['forums_forums'] && !in_array('all', $parameter['forums_forums'])? '&fups='.jsfids($parameter['forums_forums']) : '').
"&startrow=$parameter[startrow]".
"&items=$parameter[items]".
"&newwindow=$parameter[newwindow]".
"&orderby=$parameter[orderby]".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(1);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=forums#'.$lang['jswizard_forums']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_forums').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_forums_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{forumname}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_forums');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_forums_fups', '', '', jsforumselect('forums'));
showsetting('jswizard_forums_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_forums_items', 'parameter[items]', intval($parameter['items']), 'text');
showsetting('jswizard_forums_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_forums_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($fcheckorderby['displayorder'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="displayorder" '.$fcheckorderby['displayorder'].'> '.$lang['jswizard_forums_orderby_displayorder'].'</li>
<li'.($fcheckorderby['threads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="threads" '.$fcheckorderby['threads'].'> '.$lang['jswizard_forums_orderby_threads'].'</li>
<li'.($fcheckorderby['posts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="posts" '.$fcheckorderby['posts'].'> '.$lang['jswizard_forums_orderby_posts'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'memberrank') {
$mcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'credits') => 'checked');
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
if($jssubmit && $function == 'memberrank') {
$jsurl = $jssetting ? $jssetting : "function=$function".
"&startrow=$parameter[startrow]".
"&items=$parameter[items]".
"&newwindow=$parameter[newwindow]".
"&extcredit=$parameter[extcredit]".
"&orderby=$parameter[orderby]".
"&hours=".intval($parameter['hours']).
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(2);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=memberrank#'.$lang['jswizard_memberrank']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_memberrank').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_memberrank_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{regdate} {member} {value}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
$extcreditsselect = '<select name="parameter[extcredit]">';
for($i = 1;$i <= 8;$i++) {
$extcreditsselect .= '<option value="'.$i.'"'.($parameter['extcredit'] == $i ? ' selected' : '').'>extcredits'.$i.($extcredits[$i]['title'] != '' ? ' ('.$extcredits[$i]['title'].')' : '').'</option>';
}
$extcreditsselect .= '</select>';
showtableheader();
showtitle('jswizard_memberrank');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_memberrank_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_memberrank_items', 'parameter[items]', isset($parameter['items']) ? $parameter['items'] : 10, 'text');
showsetting('jswizard_memberrank_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_memberrank_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($mcheckorderby['credits'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="credits" '.$mcheckorderby['credits'].'> '.$lang['jswizard_memberrank_orderby_credits'].'</li>
<li'.($mcheckorderby['extcredits'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="extcredits" '.$mcheckorderby['extcredits'].'> '.$lang['jswizard_memberrank_orderby_extcredits'].'<br />'.$extcreditsselect.'</li>
<li'.($mcheckorderby['posts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="posts" '.$mcheckorderby['posts'].'> '.$lang['jswizard_memberrank_orderby_posts'].'</li>
<li'.($mcheckorderby['digestposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="digestposts" '.$mcheckorderby['digestposts'].'> '.$lang['jswizard_memberrank_orderby_digestposts'].'</li>
<li'.($mcheckorderby['regdate'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="regdate" '.$mcheckorderby['regdate'].'> '.$lang['jswizard_memberrank_orderby_regdate'].'</li>
<li'.($mcheckorderby['hourposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="hourposts" '.$mcheckorderby['hourposts'].'> <input name="parameter[hours]" value="'.$parameter['hours'].'" size="6"> '.$lang['jswizard_memberrank_orderby_hourposts'].'</li>
<li'.($mcheckorderby['todayposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="todayposts" '.$mcheckorderby['todayposts'].'> '.$lang['jswizard_memberrank_orderby_todayposts'].'</li>
<li'.($mcheckorderby['weekposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="weekposts" '.$mcheckorderby['weekposts'].'> '.$lang['jswizard_memberrank_orderby_weekposts'].'</li>
<li'.($mcheckorderby['monthposts'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="monthposts" '.$mcheckorderby['monthposts'].'> '.$lang['jswizard_memberrank_orderby_monthposts'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'stats') {
$predefined = array('forums', 'threads', 'posts', 'members', 'online', 'onlinemembers');
if($jssubmit && $function == 'stats') {
if($jssetting) {
$jsurl = $jssetting;
} else {
$jsurl = "function=$function".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]";
asort($displayorder);
foreach($displayorder as $key => $order) {
if($parameter[$key]['display']) {
$jsurl .= "&info[$key]=".rawurlencode($parameter[$key]['title']);
}
}
}
$jsurl .= ($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(3);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=stats#'.$lang['jswizard_stats']);
echo '<a name="'.$lang['jswizard_stats'].'"></a>';
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_stats').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_stats_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{name} {value}<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader('jswizard_stats', 'nobottom');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
showtablefooter();
showtableheader('', 'noborder fixpadding');
showsubtitle(array('jswizard_stats_display', 'display_order', 'jswizard_stats_display_title', 'jswizard_stats_display_name'));
$order = 0;
foreach($predefined as $key) {
showtablerow('', array('class="td25"', 'class="td25"'), array(
'<input class="checkbox" type="checkbox" name="parameter['.$key.'][display]" value="1" '.(!isset($parameter[$key]) || $parameter[$key]['display'] ? 'checked' : '').'>',
'<input type="text" class="txt" name="displayorder['.$key.']" size="3" value="'.(isset($displayorder[$key]) ? intval($displayorder[$key]) : ++$order).'">',
$lang['jswizard_stats_'.$key],
'<input type="text" class="txt" name="parameter['.$key.'][title]" size="15" value="'.($parameter[$key]['title'] ? $parameter[$key]['title'] : $lang['jswizard_stats_'.$key].':').'">'
));
}
showtablefooter();
showtableheader('', 'notop');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1" /></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'images') {
$tcheckorderby = array((isset($parameter['orderby']) ? $parameter['orderby'] : 'dateline') => 'checked');
for($i = 1; $i <= 4; $i++) {
$icheckdigest[$i] = !empty($parameter['digest'][$i]) ? 'checked' : '';
}
$parameter['newwindow'] = isset($parameter['newwindow']) ? intval($parameter['newwindow']) : 1;
$parameter['isimage'] = isset($parameter['isimage']) ? $parameter['isimage'] : 1;
$parameter['threadmethod'] = isset($parameter['threadmethod']) ? $parameter['threadmethod'] : 1;
$tradionewwindow[$parameter['newwindow']] = 'checked';
if($jssubmit && $function == 'images') {
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['images_forums'] && !in_array('all', $parameter['images_forums'])? '&fids='.jsfids($parameter['images_forums']) : '').
"&sidestatus=$parameter[sidestatus]".
"&isimage=$parameter[isimage]".
"&threadmethod=$parameter[threadmethod]".
"&maxwidth=$parameter[maxwidth]".
"&maxheight=$parameter[maxheight]".
"&startrow=$parameter[startrow]".
"&items=$parameter[items]".
"&orderby=$parameter[orderby]".
"&hours=".intval($parameter['hours']).
"&digest=".bindec(intval($parameter['digest'][1]).intval($parameter['digest'][2]).intval($parameter['digest'][3]).intval($parameter['digest'][4])).
"&newwindow=$parameter[newwindow]".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting(4);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />'.jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
showformheader('jswizard&function=images#'.$lang['jswizard_images']);
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_images').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">'.$lang['jswizard_images_jstemplate_comment'].'</div><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '{file} ({filesize} Bytes)<br />').'</textarea>';
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_images');
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
showsetting('jswizard_images_fids', '', '', jsforumselect('images'));
showsetting('jswizard_sidestatus', 'parameter[sidestatus]', $parameter['sidestatus'], 'radio');
showsetting('jswizard_images_startrow', 'parameter[startrow]', intval($parameter['startrow']), 'text');
showsetting('jswizard_images_items', 'parameter[items]', isset($parameter['items']) ? $parameter['items'] : 5, 'text');
showsetting('jswizard_images_isimage', array('parameter[isimage]', array(
array(0, $lang['jswizard_images_isimage_0'], array('imgsetting' => 'none')),
array(1, $lang['jswizard_images_isimage_1'], array('imgsetting' => '')),
array(2, $lang['jswizard_images_isimage_2'], array('imgsetting' => 'none'))
), 1), $parameter['isimage'], 'mradio');
showtagheader('tbody', 'imgsetting', $parameter['isimage'] == 1, 'sub');
showsetting('jswizard_images_maxwidth', 'parameter[maxwidth]', isset($parameter['maxwidth']) ? $parameter['maxwidth'] : 200, 'text');
showsetting('jswizard_images_maxheight', 'parameter[maxheight]', isset($parameter['maxheight']) ? $parameter['maxheight'] : 200, 'text');
showtagfooter('tbody');
showsetting('jswizard_images_thread', 'parameter[threadmethod]', $parameter['threadmethod'], 'radio');
showsetting('jswizard_images_digest', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($icheckdigest[1] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][1]" value="1" '.$icheckdigest[1].'> '.$lang['jswizard_digest_1'].'</li>
<li'.($icheckdigest[2] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][2]" value="1" '.$icheckdigest[2].'> '.$lang['jswizard_digest_2'].'</li>
<li'.($icheckdigest[3] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][3]" value="1" '.$icheckdigest[3].'> '.$lang['jswizard_digest_3'].'</li>
<li'.($icheckdigest[4] ? ' class="checked"' : '').'><input class="checkbox" type="checkbox" name="parameter[digest][4]" value="1" '.$icheckdigest[4].'> '.$lang['jswizard_digest_0'].'</li></ul>'
);
showtagfooter('tbody');
showsetting('jswizard_images_newwindow', 'parameter[newwindow]', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tradionewwindow[0] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="0" '.$tradionewwindow[0].'> '.$lang['jswizard_newwindow_self'].'</li>
<li'.($tradionewwindow[1] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="1" '.$tradionewwindow[1].'> '.$lang['jswizard_newwindow_blank'].'</li>
<li'.($tradionewwindow[2] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[newwindow]" value="2" '.$tradionewwindow[2].'> '.$lang['jswizard_newwindow_main'].'</li></ul>'
);
showsetting('jswizard_images_orderby', '', '', '<ul class="nofloat" onmouseover="altStyle(this);">
<li'.($tcheckorderby['dateline'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="dateline" '.$tcheckorderby['dateline'].'> '.$lang['jswizard_images_orderby_dateline'].'</li>
<li'.($tcheckorderby['downloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="downloads" '.$tcheckorderby['downloads'].'> '.$lang['jswizard_images_orderby_downloads'].'</li>
<li'.($tcheckorderby['hourdownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="hourdownloads" '.$tcheckorderby['hourdownloads'].'> <input type="text" class="txt" style="width: 50px;" name="parameter[hours]" value="'.$parameter['hours'].'" size="6"> '.$lang['jswizard_images_orderby_hourdownloads'].'</li>
<li'.($tcheckorderby['todaydownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="todaydownloads" '.$tcheckorderby['todaydownloads'].'> '.$lang['jswizard_images_orderby_todaydownloads'].'</li>
<li'.($tcheckorderby['weekdownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="weekdownloads" '.$tcheckorderby['weekdownloads'].'> '.$lang['jswizard_images_orderby_weekdownloads'].'</li>
<li'.($tcheckorderby['monthdownloads'] ? ' class="checked"' : '').'><input class="radio" type="radio" name="parameter[orderby]" value="monthdownloads" '.$tcheckorderby['monthdownloads'].'> '.$lang['jswizard_images_orderby_monthdownloads'].'</li></ul>'
);
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
} elseif($type == 'module') {
$parameter['module'] = !empty($module) ? $module : $parameter['module'];
$parameter['module'] = str_replace(array('..', '/', '\\'), array('', '', ''), $parameter['module']);
$parameter['module'] = file_exists(DISCUZ_ROOT.'./include/request/'.$parameter['module']) ? $parameter['module'] : '';
include language('request');
if($parameter['module']) {
$requestrun = FALSE;
include_once DISCUZ_ROOT.'./include/request/'.$parameter['module'];
}
if($jssubmit && $function == 'module' && $parameter['module']) {
$settingsenc = rawurlencode(serialize($parameter['settings']));
$jsurl = $jssetting ? $jssetting : "function=$function".
"&module=$parameter[module]".
"&settings=$settingsenc".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '');
if(!$preview) {
jssavesetting(5);
}
$jspreview = $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br /><br />'.jspreviewcode($jsurl).'<br />';
}
if(!empty($request_name)) {
echo '<div class="colorbox"><h4>'.$request_name.' '.$request_version.'</h4>'.$request_description.'<div style="width:95%" align="right">'.$request_copyright.'</div></div><br /><br />';
}
if($jspreview) {
echo '<div class="colorbox">';
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
echo '<br /><input type="button" class="btn" onclick="$(\'cpform\').jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="$(\'cpform\').preview.value=0;$(\'cpform\').jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
}
showformheader('jswizard&function=module#'.$lang['jswizard_module']);
jsinsertunit();
showtableheader();
if($parameter['module']) {
if($jskeyempty) {
$jskey = str_replace(' ', '_', $request_name).'_'.random(3);
}
showtitle($lang['jswizard_module']);
echo '<input type="hidden" name="parameter[module]" value="'.$parameter['module'].'">';
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
if(is_array($request_settings)) {
foreach($request_settings as $settingvar => $setting) {
$varname = in_array($setting[2], array('mradio', 'mcheckbox', 'select', 'mselect')) ? array('parameter[settings]['.$settingvar.']', $setting[3]) : 'parameter[settings]['.$settingvar.']';
$value = $parameter['settings'][$settingvar] != '' ? stripslashes($parameter['settings'][$settingvar]) : $setting[4];
showsetting($setting[0].':', $varname, $value, $setting[2], '', 0, $setting[1]);
}
}
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
} else {
$requests = jsgetrequests();
showtips('jswizard_module_tips');
showtableheader('', 'fixpadding');
if($requests) {
showsubtitle(array('name', 'jswizard_module', 'jswizard_module_version', 'copyright', ''));
foreach($requests as $request) {
showtablerow('', '', array(
$request[1].($request['filemtime'] > $timestamp - 86400 ? ' <font color="red">New!</font>' : ''),
$request[0],
$request[2],
$request[3],
"<a href=\"$BASESCRIPT?action=jswizard&type=module&module=$request[0]\">$lang[add]</a>"
));
}
} else {
showtablerow('', '', $lang['jswizard_request_nonexistence']);
}
echo '<input type="hidden" id="parametermodule" name="parameter[module]"><input name="preview" type="hidden" value="1">';
}
showtablefooter();
showformfooter();
} elseif(in_array($type, array('custom', 'side'))) {
if($type == 'side') {
$jskey = substr($jskey, 0, strlen($lang['jswizard_infoside_pre'])) == $lang['jswizard_infoside_pre'] ? $jskey : $lang['jswizard_infoside_pre'].$jskey;
}
if($jssubmit && $function == $type) {
if($function == 'side' && !empty($parameter['selectmodule'])) {
$parameter['jstemplate'] = '';
$splitbar = '';
foreach($parameter['selectmodule'] as $value) {
$parameter['jstemplate'] .= $splitbar.'[module]'.$value.'[/module]';
$splitbar = '<hr class="shadowline"/>';
}
}
$jsurl = $jssetting ? $jssetting : "function=$function".
($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
"&jscharset=$parameter[jscharset]".
($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
if(!$preview) {
jssavesetting($type == 'custom' ? -1 : -2);
}
$jspreview = ($type == 'custom' ? $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
'</textarea><br />' : '').jspreviewcode($jsurl).'<br />';
}
echo '<div class="colorbox">';
if($jspreview && in_array($type, array('custom', 'side'))) {
echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
}
$jsmodule = '';$selectarray = $requests = array();
$requests = array();
$query = $db->query("SELECT * FROM {$tablepre}request WHERE type>=0");
while($settings = $db->fetch_array($query)) {
$value = unserialize($settings['value']);
$optionitem = '<option value="'.$settings['variable'].'">'.($value['parameter']['sidestatus'] ? '* ' : '').($value['comment'] != '' ? $value['comment'] : '').'['.$settings['variable'].']'.'</option>';
if($type == 'side' && !empty($parameter['selectmodule'])) {
$key = array_search($settings['variable'], $parameter['selectmodule']);
if($key !== FALSE && $key !== NULL) {
$selectarray[$key] = $optionitem;
} else {
$jsmodule .= $optionitem;
}
} else {
$jsmodule .= $optionitem;
}
}
if($type == 'side' && !empty($selectarray)) {
ksort($selectarray);
$selectmodule = implode($selectarray);
}
showformheader('jswizard&function='.$type.'#'.$lang['jswizard_'.$type]);
if($type == 'custom') {
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_custom').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">';
echo $lang['jswizard_custom_jstemplate_comment'].'</div><select onchange="insertunit(\'[module]\'+this.value+\'[/module]\')"><option>'.$lang['jswizard_custom_jstemplate_current_module'].'</option>'.$jsmodule.'</select><br /><br />';
jsinsertunit();
echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '').'</textarea>';
} else {
echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_side').'</h4><div class="extcredits">';
echo '<tr><td colspan="2">'.$lang['jswizard_sidemodule_comment'].'</div>';
echo '<script type="text/JavaScript">
function moveselect(fromitem, toitem) {
var selectindex = $(fromitem).selectedIndex;
if(selectindex == -1) return;
var itemtext = $(fromitem).options[selectindex].text;
var itemvalue = $(fromitem).value;
$(fromitem).removeChild($(fromitem).options[selectindex]);
var newoption = new Option(itemtext, itemvalue);
$(toitem).options.add(newoption);
}
function orderselect(option) {
var selectindex = $(\'selectmodule\').selectedIndex;
if(selectindex == -1) return;
var itemtext = $(\'selectmodule\').options[selectindex].text;
var itemvalue = $(\'selectmodule\').value;
var itemcount = $(\'selectmodule\').options.length;
if(option == 1 && selectindex == 0 || option == 0 && selectindex == itemcount - 1) return;
if(option == 1) {
if(selectindex == 0) return;var swapindex = selectindex - 1;
} else {
if(selectindex == itemcount - 1) return;var swapindex = selectindex + 1;
}
var tmptext = $(\'selectmodule\').options[swapindex].text;
var tmpvalue = $(\'selectmodule\').options[swapindex].value;
$(\'selectmodule\').options[swapindex].text = $(\'selectmodule\').options[selectindex].text;
$(\'selectmodule\').options[swapindex].value = $(\'selectmodule\').options[selectindex].value;
$(\'selectmodule\').options[selectindex].text = tmptext;
$(\'selectmodule\').options[selectindex].value = tmpvalue;
$(\'selectmodule\').selectedIndex = swapindex;
}
function selectall() {
var itemcount = $(\'selectmodule\').options.length;
for(i = 0;i < itemcount;i++) {
$(\'selectmodule\').options[i].selected = true;
}
}
</script>
<table width="95%" border="0" cellpadding="0" cellspacing="0"><tr><td style="text-align:center;border: 0">
<button class=button onclick="orderselect(1);return false">'.$lang['jswizard_custom_jstemplate_up'].'</button>
<br /><br /><button class=button onclick="orderselect(0);return false">'.$lang['jswizard_custom_jstemplate_down'].'</button>
</td><td width="40%" style="border: 0">
'.$lang['jswizard_custom_jstemplate_selected_module'].'<select ondblclick="moveselect(\'selectmodule\', \'currentmodule\')" id="selectmodule" name="parameter[selectmodule][]" multiple="multiple" size="10" style="width: 100%">'.$selectmodule.'</select>
</td><td style="text-align:center;border: 0">
<button class=button onclick="moveselect(\'currentmodule\', \'selectmodule\');return false">'.$lang['jswizard_custom_jstemplate_select'].'</button>
<br /><br /><button class=button onclick="moveselect(\'selectmodule\', \'currentmodule\');return false">'.$lang['jswizard_custom_jstemplate_remove'].'</button>
</td><td width="40%" style="border: 0">
'.$lang['jswizard_custom_jstemplate_current_module'].'<select ondblclick="moveselect(\'currentmodule\', \'selectmodule\')" id="currentmodule" multiple="multiple" size="10" style="width:100%">'.$jsmodule.'</select>
</td></tr></table>
';
}
echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';
showtableheader();
showtitle('jswizard_'.$type);
showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
showsetting('jswizard_comment', 'comment', $comment, 'text');
showsetting('jswizard_cachelife_custom', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
if($type == 'custom') {
if(strtoupper($charset) != 'UTF-8') {
showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
} else {
showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
}
}
showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit"'.($type == 'side' ? ' onclick="selectall()"' : '').' value="'.$lang['preview'].'"> <input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
showtablefooter();
showformfooter();
}
} elseif($operation == 'import') {
if(!submitcheck('importsubmit')) {
shownav('tools', 'nav_javascript');
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard', 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 1)
));
showformheader('jswizard&operation=import', 'enctype');
showtableheader('jswizard_import');
showimportdata();
showtablerow('', 'class="rowform"', mradio('importrewrite', array(
0 => lang('jswizard_import_default'),
1 => lang('jswizard_import_norewrite'),
2 => lang('jswizard_import_rewrite'),
), 0, FALSE));
showsubmit('importsubmit');
showtablefooter();
showformfooter();
} else {
$importarray = getimportdata(0);
$keys = implode("','", array_keys($importarray));
if($importrewrite != 2) {
$query = $db->query("SELECT variable FROM {$tablepre}request WHERE variable IN ('$keys')");
$existkeyarray = array();
while($existkey = $db->fetch_array($query)) {
if($importrewrite == 1) {
unset($importarray[$existkey['variable']]);
} else {
$existkeyarray[] = $existkey['variable'];
}
}
if($importrewrite == 0 && $existkeyarray) {
$existkeys = implode(", ", $existkeyarray);
cpmsg('jswizard_import_exist', '', 'error');
}
}
foreach($importarray as $key => $value) {
$value = unserialize($value);
$type = $value['type'];
unset($value['type']);
$value = addslashes(serialize($value));
$db->query("REPLACE INTO {$tablepre}request (variable, value, `type`) VALUES ('$key', '$value', '$type')");
}
updatecache('request');
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard', 'succeed');
}
} elseif($operation == 'copy') {
$requestdata = $db->fetch_first("SELECT * FROM {$tablepre}request WHERE variable='$jssetting'");
$requestdata = daddslashes($requestdata, 1);
$requestdata['variable'] = $requestdata['variable'].'_'.random(3);
$db->query("INSERT INTO {$tablepre}request (variable, value, `type`) VALUES ('$requestdata[variable]', '$requestdata[value]', '$requestdata[type]')");
cpmsg('jswizard_copy_succeed', $BASESCRIPT.'?action=jswizard', 'succeed');
} elseif($operation == 'infoside') {
if(submitcheck('globalsubmit')) {
$infosidestatus['allow'] = $infosidestatusnew['allow'];
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".addslashes(serialize($infosidestatus))."')");
updatecache('settings');
} elseif(submitcheck('submit')) {
if($infosidenew == -1) {
$sidekey = $infosidenew = $newproject ? $lang['jswizard_infoside_pre'].$newproject : '';
}
if($infosidenew) {
$modulearray = array();
$displayorder = 0;
if($availablenew) {
foreach($availablenew as $key) {
if(!$modulearray[$displayordernew[$key]]) {
$modulearray[$displayordernew[$key]] = $key;
} else {
$modulearray[] = $key;
}
}
}
ksort($modulearray);
$sidedata = unserialize($db->result_first("SELECT value FROM {$tablepre}request WHERE variable='$sidekey'"));
$parameter = array(
'selectmodule' => $modulearray,
'cachelife' => intval($cachelifenew),
'jstemplate' => $modulearray ? '[module]'.implode('[/module]<hr class="shadowline"/>[module]', $modulearray).'[/module]' : ''
);
$jsurl = 'function=side&jscharset='.($cachelifenew != '' ? "&cachelife=$cachelifenew" : '').(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');
$comment = $sidedata['comment'];
$infosidestatus[$sideid] = $jskey = $sidekey;
$edit = $sidedata ? $jskey : '';
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".addslashes(serialize($infosidestatus))."')");
updatecache('settings');
jssavesetting(-2);
} else {
$infosidestatus[$sideid] = '';
$db->query("REPLACE INTO {$tablepre}settings (variable, value) VALUES ('infosidestatus', '".addslashes(serialize($infosidestatus))."')");
updatecache('settings');
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard&operation=infoside&sideid='.$sideid.'&from='.$from, 'succeed');
}
}
if($from == 'style') {
shownav('style', 'settings_styles');
showsubmenu('settings_styles', array(
array('settings_styles_global', 'settings&operation=styles&anchor=global', 0),
array('settings_styles_index', 'settings&operation=styles&anchor=index', 0),
array('settings_styles_forumdisplay', 'settings&operation=styles&anchor=forumdisplay', 0),
array('settings_styles_viewthread', 'settings&operation=styles&anchor=viewthread', 0),
array('settings_styles_member', 'settings&operation=styles&anchor=member', 0),
array('settings_styles_customnav', 'misc&operation=customnav', 0),
$infosidemenu,
array('settings_styles_refresh', 'settings&operation=styles&anchor=refresh', 0),
array('settings_styles_sitemessage', 'settings&operation=styles&anchor=sitemessage', 0)
));
} else {
shownav('tools', 'nav_javascript');
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 0),
$infosidemenu,
array('admin', 'jswizard'.($keyp ? '&openkeypre='.$keypre : ''), 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 0),
));
}
if(!isset($sideid)) {
showformheader('jswizard&operation=infoside&from='.$from);
showtableheader('jswizard_infoside');
showsetting('jswizard_infoside_allow', 'infosidestatusnew[allow]', $infosidestatus['allow'], 'radio');
showsubmit('globalsubmit', 'submit');
showtablefooter();
showformfooter();
} else {
$query = $db->query("SELECT type, variable FROM {$tablepre}request");
$modules = array();
$sides[] = array('', lang('jswizard_infoside_off'));
while($request = $db->fetch_array($query)) {
if($request['type'] == -2) {
$v = substr($request['variable'], 0, strlen($lang['jswizard_infoside_pre'])) == $lang['jswizard_infoside_pre'] ? substr($request['variable'], strlen($lang['jswizard_infoside_pre'])) : $request['variable'];
$sides[] = array(rawurlencode($request['variable']), $v);
} elseif($request['type'] >= 0) {
$modules[$request['variable']] = $request;
}
}
$sides[] = array('-1', lang('jswizard_infoside_newproject'));
$sidekey = empty($sidekey) ? addslashes($infosidestatus[$sideid]) : $sidekey;
if($sidekey) {
$sidedata = unserialize($db->result_first("SELECT value FROM {$tablepre}request WHERE variable='$sidekey'"));
$selectmodules = $sidedata['parameter']['selectmodule'];
@ksort($selectmodules);
}
showformheader('jswizard&operation=infoside&sideid='.$sideid.'&sidekey='.rawurlencode($sidekey).'&from='.$from);
showtableheader(lang('jswizard_infoside').' - '.lang('jswizard_infoside_'.$sideid), 'nobottom');
showsetting('jswizard_infoside_project', array('infosidenew', $sides), rawurlencode($sidekey), 'select', '', 0, '', "onchange=\"if(this.value && this.value != -1) {window.location='$BASESCRIPT?action=jswizard&operation=infoside&sideid=$sideid&from=$from&sidekey='+this.value} else if(this.value == -1) {\$('newproject').style.display = '';} else {\$('newproject').style.display = 'none';}if(this.value) {\$('modulelist').style.display = '';} else {\$('modulelist').style.display = 'none';}\"");
showtagheader('tbody', 'newproject', 0, 'sub');
showsetting('jswizard_infoside_newprojectname', 'newproject', '', 'text');
showtagfooter('tbody');
showsetting('jswizard_infoside_cachelife', 'cachelifenew', $sidedata['parameter']['cachelife'] != '' ? intval($sidedata['parameter']['cachelife']) : '', 'text');
showtablefooter();
showtableheader('', 'fixpadding', 'id="modulelist"'.(empty($sidekey) ? ' style="display:none"': ''));
showsubtitle(array('jswizard_key', 'available', 'display_order', 'type', ''));
if($selectmodules) {
foreach($selectmodules as $displayorder => $selectmodule) {
$module = $modules[$selectmodule];
$key = htmlspecialchars($module['variable']);
showtablerow('', array('', '', 'class="td28 td24"'), array(
$module['variable'],
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[]\" value=\"$key\" checked=\"checked\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$key]\" value=\"$displayorder\">",
$lang['jswizard_'.$jstypes[$module['type']]],
'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$module['type']].'&jssetting='.rawurlencode($module['variable']).'">'.lang('edit').'</a>'
));
unset($modules[$selectmodule]);
}
}
foreach($modules as $module) {
$key = htmlspecialchars($module['variable']);
showtablerow('', array('', '', 'class="td28 td24"'), array(
$module['variable'],
"<input class=\"checkbox\" type=\"checkbox\" name=\"availablenew[]\" value=\"$key\">",
"<input type=\"text\" class=\"txt\" size=\"2\" name=\"displayordernew[$key]\" value=\"$module[displayorder]\">",
$lang['jswizard_'.$jstypes[$module['type']]],
'<a href="'.$BASESCRIPT.'?action=jswizard&function='.$jstypes[$module['type']].'&jssetting='.rawurlencode($module['variable']).'">'.lang('edit').'</a>'
));
}
showtablefooter();
showtableheader('', 'notop');
showsubmit('submit', 'submit', '', '<a href="'.$BASESCRIPT.'?action=jswizard">'.lang('jswizard_infoside_addcomment').'</a>');
showtablefooter();
showformfooter();
}
} elseif($operation == 'config') {
if(!submitcheck('settingsubmit')) {
showsubmenu('nav_javascript', array(
array('config', 'jswizard&operation=config', 1),
$infosidemenu,
array('admin', 'jswizard', 0),
array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
array('jswizard_module', 'jswizard&type=module', 0),
array('import', 'jswizard&operation=import', 0),
));
$query = $db->query("SELECT * FROM {$tablepre}settings WHERE variable IN ('jsstatus', 'jsdateformat', 'jsrefdomains', 'infosidestatus', 'jscachelife')");
while($setting = $db->fetch_array($query)) {
$settings[$setting['variable']] = $setting['value'];
}
showformheader('jswizard&operation=config', '', 'settings');
showhiddenfields(array('operation' => $operation));
$settings['jsdateformat'] = dateformat($settings['jsdateformat']);
showtableheader();
showsetting('jswizard_config_jsstatus', 'settingsnew[jsstatus]', $settings['jsstatus'], 'radio', '', 1);
showsetting('jswizard_config_jsdateformat', 'settingsnew[jsdateformat]', $settings['jsdateformat'], 'text');
showsetting('jswizard_config_jsrefdomains', 'settingsnew[jsrefdomains]', $settings['jsrefdomains'], 'textarea');
showtagfooter('tbody');
showsetting('jswizard_config_jscachelife', 'settingsnew[jscachelife]', $settings['jscachelife'], 'text');
showtablerow('', 'colspan="2"', '<input type="submit" class="btn" name="settingsubmit" value="'.lang('submit').'" />');
showtablefooter();
showformfooter();
} else {
foreach($settingsnew as $key => $val) {
$db->query("REPLACE INTO {$tablepre}settings (variable, value)
VALUES ('$key', '$val')");
}
updatecache('settings');
cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizard&operation=config', 'succeed');
}
}
function jsforumselect($function) {
global $parameter, $lang, $db, $tablepre;
if(empty($function) || in_array($function, array('forums', 'threads', 'images'))) {
$forumselect = '<select name="parameter['.$function.'_forums][]" size="10" multiple="multiple">'.
'<option value="all" '.(is_array($parameter[$function.'_forums']) && in_array('all', $parameter[$function.'_forums']) ? 'selected="selected"' : '').'> '.$lang['jswizard_all_forums'].'</option>'.
'<option value=""> </option>';
if($function == 'forums') {
$query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE type='group' AND status>0 ORDER BY displayorder");
while($category = $db->fetch_array($query)) {
$forumselect .= '<option value="'.$category['fid'].'">'.strip_tags($category['name']).'</option>';
};
} else {
require_once DISCUZ_ROOT.'./include/forum.func.php';
$forumselect .= forumselect();
}
$forumselect .= '</select>';
if(is_array($parameter[$function.'_forums'])) {
foreach($parameter[$function.'_forums'] as $key => $value) {
if(!$value) {
unset($parameter[$function.'_forums'][$key]);
}
}
if(!in_array('all', $parameter[$function.'_forums'])) {
$forumselect = preg_replace("/(\<option value=\"(".implode('|', $parameter[$function.'_forums']).")\")(\>)/", "\\1 selected=\"selected\"\\3", $forumselect);
}
}
return $forumselect;
}
}
function jspreviewcode($jsurlview) {
global $BASESCRIPT;
return '<div class="jswizard"><iframe id="preview" name="preview" frameborder="0" allowtransparency="true" onload="this.style.height = this.contentWindow.document.body.scrollHeight + \'px\'" width="95%" height="0"></iframe></div>
<form id="previewform" action="'.$BASESCRIPT.'?action=jswizard&previewurl=yes" method="post" target="preview"><input name="jsurl" type="hidden" value="'.htmlspecialchars($jsurlview).'" /></form>
<script type="text/javascript">$(\'previewform\').submit()</script>';
}
function jsfids($fidarray) {
foreach($fidarray as $key => $val) {
if(empty($val)) {
unset($fidarray[$key]);
}
}
return implode('_', $fidarray);
}
function jssavesetting($type) {
global $operation, $db, $tablepre, $jswizard, $jsurl, $parameter, $comment, $jskey, $edit, $BASESCRIPT, $sideid, $from;
$editadd = $edit ? "AND variable!='$edit'" : '';
if($db->result_first("SELECT variable FROM {$tablepre}request WHERE variable='$jskey' $editadd")) {
cpmsg('jswizard_jskey_exists', '', 'error');
}
$jskey = str_replace('&', '', $jskey);
$jswizard = addslashes(serialize(array('url' => $jsurl, 'parameter' => $parameter, 'comment' => $comment)));
if(strlen($jswizard) > 65535) {
cpmsg('jswizard_overflow', '', 'error');
}
if($edit) {
$db->query("UPDATE {$tablepre}request SET variable='$jskey', value='$jswizard' WHERE variable='$edit'");
} else {
$db->query("INSERT INTO {$tablepre}request (variable, value, `type`) VALUES ('$jskey', '$jswizard', '$type')");
}
updatecache('request');
list($keypre, $keyp) = explode('_', $jskey);
$msg = $type != -2 ? 'jswizard_succeed' : 'jswizard_infoside_succeed';
if($operation == 'infoside') {
cpmsg($msg, $BASESCRIPT.'?action=jswizard&operation=infoside&sideid='.$sideid.'&from='.$from, 'succeed');
} else {
cpmsg($msg, $BASESCRIPT.'?action=jswizard'.($keyp ? '&openkeypre='.$keypre : ''), 'succeed');
}
}
function jsinsertunit() {
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, obj) {
if(!obj) {
obj = 'jstemplate';
}
$(obj).focus();
if(!isUndefined($(obj).selectionStart)) {
var opn = $(obj).selectionStart + 0;
$(obj).value = $(obj).value.substr(0, $(obj).selectionStart) + text + $(obj).value.substr($(obj).selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$(obj).value += text;
}
}
</script>
<?
}
function jsgetrequests() {
global $requestlang;
$dir = DISCUZ_ROOT.'./include/request';
$requestdir = dir($dir);
$requests = array();
$requestrun = 0;
while($entry = $requestdir->read()) {
if(!in_array($entry, array('.', '..')) && preg_match("/^[\w\.]+$/", $entry) && substr($entry, -8) == '.inc.php' && strlen($entry) < 30 && is_file($dir.'/'.$entry)) {
include $dir.'/'.$entry;
$requests[$entry] = array($entry, $request_name, $request_version, $request_copyright, 'filemtime' => @filemtime($dir.'/'.$entry));
}
}
uasort($requests, 'filemtimesort');
return $requests;
}
function dateformat($string, $operation = 'formalise') {
$string = htmlspecialchars(trim($string));
$replace = $operation == 'formalise' ? array(array('n', 'j', 'y', 'Y'), array('mm', 'dd', 'yy', 'yyyy')) : array(array('mm', 'dd', 'yyyy', 'yy'), array('n', 'j', 'Y', 'y'));
return str_replace($replace[0], $replace[1], $string);
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/admin/jswizard.inc.php
|
PHP
|
asf20
| 80,419
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: viewthread.php 17531 2009-01-19 01:32:52Z tiger $
*/
if(!defined('CURSCRIPT')) {
define('CURSCRIPT', 'viewthread');
}
define('SQL_ADD_THREAD', ' t.dateline, t.special, t.lastpost AS lastthreadpost, ');
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/forum.func.php';
$page = max($page, 1);
if($cachethreadlife && $forum['threadcaches'] && !$discuz_uid && $page == 1 && !$forum['special']) {
viewthread_loadcache();
}
require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
$discuz_action = 3;
$sdb = loadmultiserver('viewthread');
$thread = $sdb->fetch_first("SELECT * FROM {$tablepre}threads t WHERE tid='$tid'".($auditstatuson ? '' : " AND displayorder>='0'"));
if(!$thread) {
showmessage('thread_nonexistence');
}
$oldtopics = isset($_DCOOKIE['oldtopics']) ? $_DCOOKIE['oldtopics'] : 'D';
if(strpos($oldtopics, 'D'.$tid.'D') === FALSE) {
$oldtopics = 'D'.$tid.$oldtopics;
if(strlen($oldtopics) > 3072) {
$oldtopics = preg_replace("((D\d+)+D).*$", "\\1", substr($oldtopics, 0, 3072));
}
dsetcookie('oldtopics', $oldtopics, 3600);
}
if($lastvisit < $thread['lastpost'] && (!isset($_DCOOKIE['fid'.$fid]) || $thread['lastpost'] > $_DCOOKIE['fid'.$fid])) {
dsetcookie('fid'.$fid, $thread['lastpost'], 3600);
}
$thisgid = 0;
$thread['subjectenc'] = rawurlencode($thread['subject']);
$fromuid = $creditspolicy['promotion_visit'] && $discuz_uid ? '&fromuid='.$discuz_uid : '';
$feeduid = $thread['authorid'] ? $thread['authorid'] : 0;
$feedpostnum = $thread['replies'] > $ppp ? $ppp : ($thread['replies'] ? $thread['replies'] : 1);
$upnavlink = 'forumdisplay.php?fid='.$fid.($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '');
$navigation = ' » <a href="'.$upnavlink.'">'.(strip_tags($forum['name']) ? strip_tags($forum['name']) : $forum['name']).'</a> » '.$thread['subject'];
if($thread['digest'] == '-2') {
$campaign = $db->fetch_first("SELECT id, type, status, url, autoupdate, lastupdated FROM {$tablepre}campaigns WHERE tid='$tid'");
if(!$campaign || $campaign['status'] != 2) {
showmessage('thread_nonexistence');
}
$insenz = $db->result_first("SELECT value FROM {$tablepre}settings WHERE variable='insenz'");
$insenz = $insenz ? unserialize($insenz) : array();
if(empty($insenz['authkey'])) {
showmessage('thread_nonexistence');
}
require_once DISCUZ_ROOT.'./include/insenz.func.php';
$member = $db->fetch_first("SELECT regdate FROM {$tablepre}members WHERE uid='$discuz_uid'");
$iframeurl = $campaign[url]."siteid=$insenz[siteid]&cid=$campaign[id]&s=".urlencode(insenz_authcode("sitename=$bbname&siteurl=$boardurl&username=$discuz_userss&uid=$discuz_uid&email=$email&grouptitle=$grouptitle®date=$member[regdate]&ppp=$ppp&tid=$tid", 'ENCODE', $insenz['authkey'])).'&'.$_SERVER['QUERY_STRING'];
$update = $campaign['autoupdate'] && ($timestamp - $campaign['lastupdated']) < 600 ? FALSE : TRUE;
include template('viewthread_iframe');
exit;
}
$navtitle = $thread['subject'].' - '.strip_tags($forum['name']);
if($forum['type'] == 'sub') {
$fup = $sdb->fetch_first("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$navigation = '» <a href="forumdisplay.php?fid='.$fup['fid'].'">'.(strip_tags($fup['name']) ? strip_tags($fup['name']) : $fup['name']).'</a> '.$navigation;
$navtitle = $navtitle.' - '.strip_tags($fup['name']);
}
$navtitle .= ' - ';
$forum['typemodels'] = $forum['typemodels'] ? unserialize($forum['typemodels']) : array();
$threadsort = isset($forum['threadsorts']['types'][$thread['sortid']]) ? 1 : 0;
$typetemplate = $tagscript = '';
$optiondata = $optionlist = array();
if($thread['sortid'] && $threadsort) {
if($forum['threadsorts']['types'][$thread['sortid']]) {
if(@include_once DISCUZ_ROOT.'./forumdata/cache/threadsort_'.$thread['sortid'].'.php') {
$query = $sdb->query("SELECT optionid, value FROM {$tablepre}typeoptionvars WHERE tid='$tid'");
while($option = $sdb->fetch_array($query)) {
$optiondata[$option['optionid']] = $option['value'];
}
$searchtitle = $searchvalue = array();
foreach($_DTYPE as $optionid => $option) {
$optionlist[$option['identifier']]['title'] = $_DTYPE[$optionid]['title'];
if($_DTYPE[$optionid]['type'] == 'checkbox') {
$optionlist[$option['identifier']]['value'] = '';
foreach(explode("\t", $optiondata[$optionid]) as $choiceid) {
$optionlist[$option['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].' ';
}
} elseif(in_array($_DTYPE[$optionid]['type'], array('radio', 'select'))) {
$optionlist[$option['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$optiondata[$optionid]];
} elseif($_DTYPE[$optionid]['type'] == 'image') {
$maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : '';
$maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : '';
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$optiondata[$optionid]\" onload=\"thumbImg(this)\" $maxwidth $maxheight border=\"0\"></a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'url') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\">$optiondata[$optionid]</a>" : '';
} elseif($_DTYPE[$optionid]['type'] == 'textarea') {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? nl2br($optiondata[$optionid]) : '';
} else {
$optionlist[$option['identifier']]['value'] = $optiondata[$optionid];
}
$searchtitle[] = '/{('.$option['identifier'].')}/e';
$searchvalue[] = '/\[('.$option['identifier'].')value\]/e';
}
if($_DTYPETEMPLATE) {
$typetemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $_DTYPETEMPLATE);
$typetemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $typetemplate);
}
}
}
}
$thread['subject'] = ($forum['threadsorts']['types'][$thread['sortid']] ? ($forum['threadsorts']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=sort&sortid='.$thread['sortid'].'">['.$forum['threadsorts']['types'][$thread['sortid']].']</a>' : '['.$forum['threadsorts']['types'][$thread['sortid']].']').' ' : '').
($forum['threadtypes']['types'][$thread['typeid']] ? ($forum['threadtypes']['listable'] ? '<a href="forumdisplay.php?fid='.$fid.'&filter=type&typeid='.$thread['typeid'].'">['.$forum['threadtypes']['types'][$thread['typeid']].']</a>' : '['.$forum['threadtypes']['types'][$thread['typeid']].']').' ' : '').
$thread['subject'];
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
$navtitle = '';
showmessage('forum_nopermission', NULL, 'NOPERM');
}
} elseif($forum['allowview'] == -1) {
$navtitle = '';
showmessage('forum_access_view_disallow');
}
if($forum['formulaperm']) {
formulaperm($forum['formulaperm']);
}
if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
dheader("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
}
if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
$threadpay = FALSE;
if($thread['price'] > 0 && $thread['special'] == 0) {
if($maxchargespan && $timestamp - $thread['dateline'] >= $maxchargespan * 3600) {
$db->query("UPDATE {$tablepre}threads SET price='0' WHERE tid='$tid'");
$thread['price'] = 0;
} else {
$exemptvalue = $forum['ismoderator'] ? 128 : 16;
if(!($exempt & $exemptvalue) && $thread['authorid'] != $discuz_uid) {
$query = $sdb->query("SELECT tid FROM {$tablepre}paymentlog WHERE tid='$tid' AND uid='$discuz_uid'");
if(!$sdb->num_rows($query)) {
require_once DISCUZ_ROOT.'./include/threadpay.inc.php';
$threadpay = TRUE;
}
}
}
}
$forum['modrecommend'] = $forum['modrecommend'] ? unserialize($forum['modrecommend']) : array();
$raterange = $modratelimit && $adminid == 3 && !$forum['ismoderator'] ? array() : $raterange;
$extra = rawurlencode($extra);
$allowgetattach = !empty($forum['allowgetattach']) || ($allowgetattach && !$forum['getattachperm']) || forumperm($forum['getattachperm']);
$seccodecheck = ($seccodestatus & 4) && (!$seccodedata['minposts'] || $posts < $seccodedata['minposts']);
$secqaacheck = $secqaa['status'][2] && (!$secqaa['minposts'] || $posts < $secqaa['minposts']);
$postlist = $attachtags = $attachlist = array();
$aimgcount = 0;
$attachpids = -1;
if(empty($action) && $tid) {
$thisgid = $forum['type'] == 'forum' ? $forum['fup'] : $_DCACHE['forums'][$forum['fup']]['fup'];
$lastmod = $thread['moderated'] ? viewthread_lastmod() : array();
$showsettings = str_pad(decbin($showsettings), 3, '0', STR_PAD_LEFT);
$customshow = $discuz_uid ? str_pad(base_convert($customshow, 10, 3), 4, '0', STR_PAD_LEFT) : '2222';
$disableddateconvert = $customshow{0};
$showsignatures = $customshow{1} == 2 ? $showsettings{0} : $customshow{1};
$showavatars = $customshow{2} == 2 ? $showsettings{1} : $customshow{2};
$showimages = $customshow{3} == 2 ? $showsettings{2} : $customshow{3};
$highlightstatus = isset($highlight) && str_replace('+', '', $highlight) ? 1 : 0;
$usesigcheck = $discuz_uid && $sigstatus ? 1 : 0;
$allowpostreply = ($forum['allowreply'] != -1) && ((!$thread['closed'] && !checkautoclose()) || $forum['ismoderator']) && ((!$forum['replyperm'] && $allowreply) || ($forum['replyperm'] && forumperm($forum['replyperm'])) || $forum['allowreply']);
$allowpost = $forum['allowpost'] != -1 && ((!$forum['postperm'] && $allowpost) || ($forum['postperm'] && forumperm($forum['postperm'])) || $forum['allowpost']);
$addfeedcheck = $customaddfeed & 4 ? 1 : 0;
if($allowpost) {
$allowpostpoll = $allowpostpoll && ($forum['allowpostspecial'] & 1);
$allowposttrade = $allowposttrade && ($forum['allowpostspecial'] & 2);
$allowpostreward = $allowpostreward && ($forum['allowpostspecial'] & 4) && isset($extcredits[$creditstrans]);
$allowpostactivity = $allowpostactivity && ($forum['allowpostspecial'] & 8);
$allowpostdebate = $allowpostdebate && ($forum['allowpostspecial'] & 16);
$allowpostvideo = $allowpostvideo && ($forum['allowpostspecial'] & 32) && $videoopen;
} else {
$allowpostpoll = $allowposttrade = $allowpostreward = $allowpostactivity = $allowpostdebate = $allowpostvideo = FALSE;
}
$visitedforums = $visitedforums ? visitedforums() : '';
$forummenu = '';
if($forumjump) {
$forummenu = forumselect(FALSE, 1);
}
$relatedthreadlist = array();
$relatedthreadupdate = $tagupdate = FALSE;
$relatedkeywords = $tradekeywords = $metakeywords = $firstpid = '';
$randnum = $qihoo['relate']['webnum'] ? rand(1, 1000) : '';
$statsdata = !empty($statsdata) ? dhtmlspecialchars($statsdata) : '';
if($qihoo['relate']['bbsnum'] || $insenz['topicrelatedad'] || ($insenz['traderelatedad'] && $thread['special'] == 2)) {
$site = site();
$query = $db->query("SELECT type, expiration, keywords, relatedthreads FROM {$tablepre}relatedthreads WHERE tid='$tid'");
if($db->num_rows($query)) {
while($related = $db->fetch_array($query)) {
if($related['expiration'] <= $timestamp) {
$relatedthreadupdate = TRUE;
$qihoo_up = 1;
} elseif($qihoo['relate']['bbsnum'] && $related['type'] == 'general') {
$relatedthreadlist = unserialize($related['relatedthreads']);
if($related['keywords']) {
$keywords = str_replace("\t", ' ', $related['keywords']);
$searchkeywords = rawurlencode($keywords);
$statskeywords = urlencode($keywords);
$statsurl = urlencode($boardurl.'viewthread.php?tid='.$tid);
$prefix = '';
foreach(explode("\t", $related['keywords']) as $keyword) {
$relatedkeywords .= $keyword ? $prefix.'<a href="http://www.qihoo.com/wenda.php?kw='.rawurlencode($keyword).'&do=search&noq=q" target="_blank">'.$keyword.'</a>' : '';
$prefix = ', ';
$metakeywords .= $keyword ? $keyword.',' : '';
}
}
} elseif($related['type'] == 'trade') {
$tradekeywords = explode("\t", $related['keywords']);
$tradekeywords = $tradekeywords[array_rand($tradekeywords)];
}
}
} else {
$relatedthreadupdate = TRUE;
$qihoo_up = 0;
}
$relatedthreadupdate && $verifykey = md5($authkey.$tid.$thread['subjectenc'].$charset.$site);
}
$relatedthreads = array();
if(!empty($relatedthreadlist)) {
if(!isset($_COOKIE['discuz_collapse']) || strpos($_COOKIE['discuz_collapse'], 'relatedthreads') === FALSE) {
$relatedthreads['img'] = 'collapsed_no.gif';
$relatedthreads['style'] = '';
} else {
$relatedthreads['img'] = 'collapsed_yes.gif';
$relatedthreads['style'] = 'display: none';
}
}
$threadtag = array();
$tagstatus = $tagstatus && $forum['allowtag'] ? ($tagstatus == 2 ? 2 : $forum['allowtag']) : 0;
if($tagstatus) {
$query = $sdb->query("SELECT tagname FROM {$tablepre}threadtags WHERE tid='$tid'");
$thread['tags'] = $prefix = '';
while($tags = $sdb->fetch_array($query)) {
$metakeywords .= $tags['tagname'].',';
$thread['tags'] .= $prefix.'<a href="tag.php?name='.rawurlencode($tags['tagname']).'" target="_blank">'.$tags['tagname'].'</a>';
$prefix = ', ';
}
if($tagstatus == 2 && !$thread['tags'] || $relatedthreadupdate) {
$tagupdate = TRUE;
}
$relatedthreadupdate && $thread['tagsenc'] = rawurlencode(strip_tags($thread['tags']));
}
viewthread_updateviews();
@extract($_DCACHE['custominfo']);
$infosidestatus['posts'] = $infosidestatus[1] && isset($infosidestatus['f'.$fid]['posts']) ? $infosidestatus['f'.$fid]['posts'] : $infosidestatus['posts'];
$infoside = $infosidestatus[1] && $thread['replies'] > $infosidestatus['posts'];
$specialadd1 = $specialadd2 = $specialextra = '';
if($thread['special'] == 2) {
$specialadd1 = "LEFT JOIN {$tablepre}trades tr ON p.pid=tr.pid";
$specialadd2 = "AND tr.tid IS null";
} elseif($thread['special'] == 5) {
if(isset($stand) && $stand >= 0 && $stand < 3) {
$specialadd1 .= "LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid";
if($stand) {
$specialadd2 .= "AND (dp.stand='$stand' OR p.first='1')";
} else {
$specialadd2 .= "AND (dp.stand='0' OR dp.stand IS NULL OR p.first='1')";
}
$specialextra = "&stand=$stand";
} else {
$specialadd1 = "LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid";
}
$fieldsadd .= ", dp.stand, dp.voters";
}
$onlyauthoradd = '';
if(empty($viewpid)) {
$authorid = intval($authorid);
if($authorid) {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0' AND authorid='$authorid'") - 1;
if($thread['replies'] < 0) {
showmessage('undefined_action');
}
$onlyauthoradd = "AND p.authorid='$authorid'";
} elseif($thread['special'] == 5) {
if(isset($stand) && $stand >= 0 && $stand < 3) {
if($stand) {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}debateposts WHERE tid='$tid' AND stand='$stand'");
} else {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}posts p LEFT JOIN {$tablepre}debateposts dp ON p.pid=dp.pid WHERE p.tid='$tid' AND (dp.stand='0' OR dp.stand IS NULL)");
}
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}debateposts WHERE tid='$tid' AND stand='$stand'");
} else {
$thread['replies'] = $sdb->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0'") - 1;
}
} elseif($thread['special'] == 2) {
$tradenum = $db->result_first("SELECT count(*) FROM {$tablepre}trades WHERE tid='$tid'");
$thread['replies'] -= $tradenum;
}
$ppp = $forum['threadcaches'] && !$discuz_uid ? $_DCACHE['settings']['postperpage'] : $ppp;
$totalpage = ceil(($thread['replies'] + 1) / $ppp);
$page > $totalpage && $page = $totalpage;
$pagebydesc = $page > 50 && $page > ($totalpage / 2) ? TRUE : FALSE;
if($pagebydesc) {
$firstpagesize = ($thread['replies'] + 1) % $ppp;
$ppp3 = $ppp2 = $page == $totalpage && $firstpagesize ? $firstpagesize : $ppp;
$realpage = $totalpage - $page + 1;
$start_limit = max(0, ($realpage - 2) * $ppp + $firstpagesize);
$numpost = ($page - 1) * $ppp;
$pageadd = "ORDER BY dateline DESC LIMIT $start_limit, $ppp2";
} else {
$start_limit = $numpost = ($page - 1) * $ppp;
if($start_limit > $thread['replies']) {
$start_limit = $numpost = 0;
$page = 1;
}
$pageadd = "ORDER BY dateline LIMIT $start_limit, $ppp";
}
$multipage = multi($thread['replies'] + 1, $ppp, $page, "viewthread.php?tid=$tid&extra=$extra".(isset($highlight) ? "&highlight=".rawurlencode($highlight) : '').(!empty($authorid) ? "&authorid=$authorid" : '').$specialextra);
} else {
$viewpid = intval($viewpid);
$pageadd = "AND p.pid='$viewpid'";
}
$newpostanchor = $postcount = $ratelogpids = 0;
$onlineauthors = array();
$query = $sdb->query("SELECT p.*, m.uid, m.username, m.groupid, m.adminid, m.regdate, m.lastactivity, m.posts, m.digestposts, m.oltime,
m.pageviews, m.credits, m.extcredits1, m.extcredits2, m.extcredits3, m.extcredits4, m.extcredits5, m.extcredits6,
m.extcredits7, m.extcredits8, m.email, m.gender, m.showemail, m.invisible, mf.nickname, mf.site,
mf.icq, mf.qq, mf.yahoo, mf.msn, mf.taobao, mf.alipay, mf.location, mf.medals,
mf.sightml AS signature, mf.customstatus, mf.spacename $fieldsadd
FROM {$tablepre}posts p
LEFT JOIN {$tablepre}members m ON m.uid=p.authorid
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
$specialadd1
WHERE p.tid='$tid'".($auditstatuson ? '' : "AND p.invisible='0'")." $specialadd2 $onlyauthoradd $pageadd");
while($post = $sdb->fetch_array($query)) {
if(($onlyauthoradd && $post['anonymous'] == 0) || !$onlyauthoradd) {
$postlist[$post['pid']] = viewthread_procpost($post);
}
}
if($thread['special'] > 0 && (empty($viewpid) || $viewpid == $firstpid)) {
$thread['starttime'] = gmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
$thread['remaintime'] = '';
switch($thread['special']) {
case 1: include_once DISCUZ_ROOT.'./include/viewthread_poll.inc.php'; break;
case 2: include_once DISCUZ_ROOT.'./include/viewthread_trade.inc.php'; break;
case 3: include_once DISCUZ_ROOT.'./include/viewthread_reward.inc.php'; break;
case 4: include_once DISCUZ_ROOT.'./include/viewthread_activity.inc.php'; break;
case 5: include_once DISCUZ_ROOT.'./include/viewthread_debate.inc.php'; break;
case 6: include_once DISCUZ_ROOT.'./include/viewthread_video.inc.php'; break;
}
}
if(empty($authorid) && empty($postlist)) {
$replies = intval($db->result_first("SELECT COUNT(*) FROM {$tablepre}posts WHERE tid='$tid' AND invisible='0'")) - 1;
if($thread['replies'] != $replies && $replies > 0) {
$db->query("UPDATE {$tablepre}threads SET replies='$replies' WHERE tid='$tid'");
dheader("Location: redirect.php?tid=$tid&goto=lastpost");
}
}
if($pagebydesc) {
$postlist = array_reverse($postlist, TRUE);
}
if($vtonlinestatus == 2 && $onlineauthors) {
$query = $db->query("SELECT uid FROM {$tablepre}sessions WHERE uid IN(".(implode(',', $onlineauthors)).") AND invisible=0");
$onlineauthors = array();
while($author = $db->fetch_array($query)) {
$onlineauthors[$author['uid']] = 1;
}
} else {
$onlineauthors = array();
}
if($ratelogpids) {
$query = $db->query("SELECT * FROM {$tablepre}ratelog WHERE pid IN ($ratelogpids) ORDER BY dateline DESC");
while($ratelog = $db->fetch_array($query)) {
if(count($postlist[$ratelog['pid']]['ratelog']) < $ratelogrecord) {
$ratelogs[$ratelog['uid']]['username'] = $ratelog['username'];
$ratelogs[$ratelog['uid']]['score'][$ratelog['extcredits']] = $ratelog['score'];
$ratelogs[$ratelog['uid']]['reason'] = dhtmlspecialchars($ratelog['reason']);
$postlist[$ratelog['pid']]['ratelog'][$ratelog['uid']] = $ratelogs[$ratelog['uid']];
}
if(!$postlist[$ratelog['pid']]['totalrate'] || !in_array($ratelog['uid'], $postlist[$ratelog['pid']]['totalrate'])) {
$postlist[$ratelog['pid']]['totalrate'][] = $ratelog['uid'];
}
}
}
if($attachpids != '-1') {
require_once DISCUZ_ROOT.'./include/attachment.func.php';
parseattach($attachpids, $attachtags, $postlist, $showimages);
}
if(empty($postlist)) {
showmessage('undefined_action', NULL, 'HALTED');
} else {
$seodescription = current($postlist);
$seodescription = str_replace(array("\r", "\n"), '', cutstr(htmlspecialchars(strip_tags($seodescription['message'])), 150));
}
viewthread_parsetags();
if(empty($viewpid)) {
include template('viewthread');
} else {
$admode = 0;
$post = $postlist[$viewpid];
$post['number'] = $sdb->result_first("SELECT count(*) FROM {$tablepre}posts WHERE tid='$post[tid]' AND dateline<='$post[dbdateline]'");
include template('header_ajax');
include template('viewthread_node');
include template('footer_ajax');
}
} elseif($action == 'printable' && $tid) {
require_once DISCUZ_ROOT.'./include/printable.inc.php';
}
function viewthread_updateviews() {
global $delayviewcount, $timestamp, $tablepre, $tid, $db, $adminid, $thread, $do;
if($delayviewcount == 1 || $delayviewcount == 3) {
$logfile = './forumdata/cache/cache_threadviews.log';
if(substr($timestamp, -2) == '00') {
require_once DISCUZ_ROOT.'./include/misc.func.php';
updateviews('threads', 'tid', 'views', $logfile);
}
if(@$fp = fopen(DISCUZ_ROOT.$logfile, 'a')) {
fwrite($fp, "$tid\n");
fclose($fp);
} elseif($adminid == 1) {
showmessage('view_log_invalid');
}
} else {
$db->query("UPDATE LOW_PRIORITY {$tablepre}threads SET views=views+1 WHERE tid='$tid'", 'UNBUFFERED');
}
}
function viewthread_procpost($post, $special = 0) {
global $_DCACHE, $newpostanchor, $numpost, $thisbg, $postcount, $ratelogpids, $onlineauthors, $lastvisit, $thread,
$attachpids, $attachtags, $forum, $dateformat, $timeformat, $timeoffset, $userstatusby, $allowgetattach,
$ratelogrecord, $showimages, $forum, $discuz_uid, $showavatars, $pagebydesc, $ppp, $ppp2, $ppp3,
$firstpid, $videoopen, $threadpay, $sigviewcond;
if(!$newpostanchor && $post['dateline'] > $lastvisit) {
$post['newpostanchor'] = '<a name="newpost"></a>';
$newpostanchor = 1;
} else {
$post['newpostanchor'] = '';
}
$post['lastpostanchor'] = $numpost == $thread['replies'] ? '<a name="lastpost"></a>' : '';
if($pagebydesc) {
$post['number'] = $numpost + $ppp2--;
$post['count'] = $ppp == $ppp3 ? $ppp - $postcount - 1 : $ppp3 - $postcount - 1;
} else {
$post['number'] = ++$numpost;
$post['count'] = $postcount;
}
$postcount++;
$post['dbdateline'] = $post['dateline'];
$post['dateline'] = dgmdate("$dateformat $timeformat", $post['dateline'] + $timeoffset * 3600);
$post['groupid'] = $_DCACHE['usergroups'][$post['groupid']] ? $post['groupid'] : 7;
if($post['username']) {
$onlineauthors[] = $post['authorid'];
$post['usernameenc'] = rawurlencode($post['username']);
!$special && $post['groupid'] = getgroupid($post['authorid'], $_DCACHE['usergroups'][$post['groupid']], $post);
$post['readaccess'] = $_DCACHE['usergroups'][$post['groupid']]['readaccess'];
if($_DCACHE['usergroups'][$post['groupid']]['userstatusby'] == 1) {
$post['authortitle'] = $_DCACHE['usergroups'][$post['groupid']]['grouptitle'];
$post['stars'] = $_DCACHE['usergroups'][$post['groupid']]['stars'];
} elseif($_DCACHE['usergroups'][$post['groupid']]['userstatusby'] == 2) {
foreach($_DCACHE['ranks'] as $rank) {
if($post['posts'] > $rank['postshigher']) {
$post['authortitle'] = $rank['ranktitle'];
$post['stars'] = $rank['stars'];
break;
}
}
}
$post['taobaoas'] = addslashes($post['taobao']);
$post['authoras'] = !$post['anonymous'] ? ' '.addslashes($post['author']) : '';
$post['regdate'] = gmdate($dateformat, $post['regdate'] + $timeoffset * 3600);
$post['lastdate'] = gmdate($dateformat, $post['lastactivity'] + $timeoffset * 3600);
if($post['medals']) {
@include_once DISCUZ_ROOT.'./forumdata/cache/cache_medals.php';
foreach($post['medals'] = explode("\t", $post['medals']) as $key => $medalid) {
list($medalid, $medalexpiration) = explode("|", $medalid);
if(isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
$post['medals'][$key] = $_DCACHE['medals'][$medalid];
} else {
unset($post['medals'][$key]);
}
}
}
if($showavatars) {
$post['avatar'] = discuz_uc_avatar($post['authorid']);
if($_DCACHE['usergroups'][$post['groupid']]['groupavatar']) {
$post['avatar'] .= '<br /><img src="'.$_DCACHE['usergroups'][$post['groupid']]['groupavatar'].'" border="0" alt="" />';
}
} else {
$post['avatar'] = '';
}
$post['status'] = sprintf('%b', $post['status']);
$post['banned'] = substr($post['status'], -1, 1);
$post['warned'] = substr($post['status'], -2, 1);
$post['msn'] = explode("\t", $post['msn']);
} else {
if(!$post['authorid']) {
$post['useip'] = substr($post['useip'], 0, strrpos($post['useip'], '.')).'.x';
}
}
$post['attachments'] = array();
if($post['attachment']) {
if($allowgetattach && !$threadpay) {
$attachpids .= ",$post[pid]";
$post['attachment'] = 0;
if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $post['message'], $matchaids)) {
$attachtags[$post['pid']] = $matchaids[1];
}
} else {
$post['message'] = preg_replace("/\[attach\](\d+)\[\/attach\]/i", '', $post['message']);
}
}
$ratelogpids .= ($ratelogrecord && $post['rate']) ? ','.$post['pid'] : '';
$forum['allowbbcode'] = $forum['allowbbcode'] ? ($_DCACHE['usergroups'][$post['groupid']]['allowcusbbcode'] ? 2 : 1) : 0;
$post['signature'] = $post['usesig'] ? ($sigviewcond ? (strlen($post['message']) > $sigviewcond ? $post['signature'] : '') : $post['signature']) : '';
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0), 0, $post['authorid'], $forum['allowmediacode'], $post['pid']);
$videoopen && $post['message'] = videocode($post['message'], $post['tid'], $post['pid']);
$post['first'] && $firstpid = $post['pid'];
$firstpid = intval($firstpid);
return $post;
}
function showoption($var, $type) {
global $optionlist;
if($optionlist[$var][$type]) {
return $optionlist[$var][$type];
} else {
return '';
}
}
function viewthread_loadcache() {
global $tid, $forum, $timestamp, $cachethreadlife, $_DCACHE, $gzipcompress, $debug, $styleid;
$forum['livedays'] = ceil(($timestamp - $forum['dateline']) / 86400);
$forum['lastpostdays'] = ceil(($timestamp - $forum['lastthreadpost']) / 86400);
$threadcachemark = 100 - (
$forum['displayorder'] * 15 +
$forum['digest'] * 10 +
min($forum['views'] / max($forum['livedays'], 10) * 2, 50) +
max(-10, (15 - $forum['lastpostdays'])) +
min($forum['replies'] / $_DCACHE['settings']['postperpage'] * 1.5, 15));
if($threadcachemark < $forum['threadcaches']) {
$threadcache = getcacheinfo($tid);
if($timestamp - $threadcache['filemtime'] > $cachethreadlife) {
@unlink($threadcache['filename']);
define('CACHE_FILE', $threadcache['filename']);
$styleid = $_DCACHE['settings']['styleid'];
@include DISCUZ_ROOT.'./forumdata/cache/style_'.$styleid.'.php';
} else {
readfile($threadcache['filename']);
viewthread_updateviews();
$debug && debuginfo();
$debug ? die('<script type="text/javascript">document.getElementById("debuginfo").innerHTML = " '.($debug ? 'Updated at '.gmdate("H:i:s", $threadcache['filemtime'] + 3600 * 8).', Processed in '.$debuginfo['time'].' second(s), '.$debuginfo['queries'].' Queries'.($gzipcompress ? ', Gzip enabled' : '') : '').'";</script>') : die();
}
}
}
function viewthread_lastmod() {
global $db, $tablepre, $dateformat, $timeformat, $timeoffset, $tid;
if($lastmod = $db->fetch_first("SELECT uid AS moduid, username AS modusername, dateline AS moddateline, action AS modaction, magicid
FROM {$tablepre}threadsmod
WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1")) {
include language('modactions');
$lastmod['modusername'] = $lastmod['modusername'] ? $lastmod['modusername'] : 'System';
$lastmod['moddateline'] = dgmdate("$dateformat $timeformat", $lastmod['moddateline'] + $timeoffset * 3600);
$lastmod['modaction'] = $modactioncode[$lastmod['modaction']];
if($lastmod['magicid']) {
require_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
$lastmod['magicname'] = $_DCACHE['magics'][$lastmod['magicid']]['name'];
}
} else {
$db->query("UPDATE {$tablepre}threads SET moderated='0' WHERE tid='$tid'", 'UNBUFFERED');
}
return $lastmod;
}
function viewthread_parsetags() {
global $tagstatus, $_DCACHE, $firstpid, $postlist, $forum, $tagscript;
if($firstpid && $tagstatus && $forum['allowtag'] && !($postlist[$firstpid]['htmlon'] & 2) && !empty($_DCACHE['tags'])) {
$tagscript = '<script type="text/javascript">var tagarray = '.$GLOBALS['_DCACHE']['tags'][0].';var tagencarray = '.$GLOBALS['_DCACHE']['tags'][1].';parsetag('.$firstpid.');</script>';
}
}
function remaintime($time) {
$seconds = $time % 60;
$minutes = $time % 3600 / 60;
$hours = $time % 86400 / 3600;
$days = $time / 86400;
return array((int)$days, (int)$hours, (int)$minutes, (int)$seconds);
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/viewthread.php
|
PHP
|
asf20
| 30,436
|
<?php
/*
[Discuz!] (C)2001-2009 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: index.php 16688 2008-11-14 06:41:07Z cnteacher $
*/
$kw_spiders = 'Bot|Crawl|Spider';
// keywords regular expression of search engine spiders
$kw_browsers = 'MSIE|Netscape|Opera|Konqueror|Mozilla';
// keywords regular expression of Internet browsers
$kw_searchengines = 'google|yahoo|msn|baidu|yisou|sogou|iask|zhongsou|sohu|sina|163';
// keywords regular expression of search engine names
error_reporting(0);
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
ob_start();
define('DISCUZ_ROOT', '../');
define('IN_DISCUZ', TRUE);
define('CURSCRIPT', 'archiver');
require_once '../forumdata/cache/cache_settings.php';
if(!$_DCACHE['settings']['archiverstatus']) {
exit('Sorry, Discuz! Archiver is not available.');
} elseif($_DCACHE['settings']['bbclosed']) {
exit('Sorry, the bulletin board has been closed temporarily.');
}
require_once '../config.inc.php';
require_once '../include/db_'.$database.'.class.php';
require_once '../templates/default/archiver.lang.php';
require_once '../forumdata/cache/cache_forums.php';
require_once '../forumdata/cache/cache_archiver.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);
$db->select_db($dbname);
if(!function_exists('loadmultiserver')) {
function loadmultiserver($type = '') {
global $db, $dbcharset, $multiserver;
$type = empty($type) && defined('CURSCRIPT') ? CURSCRIPT : $type;
static $sdb = null;
if($type && !empty($multiserver['enable'][$type])) {
if(!is_a($sdb, 'dbstuff')) $sdb = new dbstuff();
if($sdb->link > 0) {
return $sdb;
} elseif($sdb->link === null && (!empty($multiserver['slave']['dbhost']) || !empty($multiserver[$type]['dbhost']))) {
$setting = !empty($multiserver[$type]['host']) ? $multiserver[$type] : $multiserver['slave'];
$sdb->connect($setting['dbhost'], $setting['dbuser'], $setting['dbpw'], $setting['dbname'], $setting['pconnect'], false, $dbcharset);
if($sdb->link) {
return $sdb;
} else {
$sdb->link = -32767;
}
}
}
return $db;
}
}
$sdb = loadmultiserver();
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$_SERVER = empty($_SERVER) ? $HTTP_SERVER_VARS : $_SERVER;
$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$boardurl = 'http://'.$_SERVER['HTTP_HOST'].substr($PHP_SELF, 0, strpos($PHP_SELF, 'archiver/'));
$groupid = 7;
$extgroupids = '';
$fid = $page = $tid = 0;
$qm = $_DCACHE['settings']['rewritestatus'] & 16 ? '' : '?';
$fullversion = array('title' => $_DCACHE['settings']['bbname'], 'link' => $_DCACHE['settings']['indexname']);
$querystring = preg_replace("/\.html$/i", '', trim($_SERVER['QUERY_STRING']));
if($querystring) {
$queryparts = explode('-', $querystring);
$lastpart = '';
foreach($queryparts as $querypart) {
if(empty($lastpart)) {
$lastpart = in_array($querypart, array('fid', 'page', 'tid')) ? $querypart : '';
} else {
$$lastpart = intval($querypart);
$lastpart = '';
}
}
}
$navtitle = $meta_contentadd = $advlist = null;
if($tid) {
$action = 'thread';
$forward = 'viewthread.php?tid='.$tid;
} elseif($fid) {
$action = 'forum';
$forward = 'forumdisplay.php?fid='.$fid;
} else {
$action = 'index';
$forward = 'index.php';
}
if($_DCACHE['settings']['archiverstatus'] != 1 && !preg_match("/($kw_spiders)/i", $_SERVER['HTTP_USER_AGENT']) &&
(($_DCACHE['settings']['archiverstatus'] == 2 && preg_match("/($kw_searchengines)/", $_SERVER['HTTP_REFERER'])) ||
($_DCACHE['settings']['archiverstatus'] == 3 && preg_match("/($kw_browsers)/", $_SERVER['HTTP_USER_AGENT'])))) {
header("Location: $boardurl$forward");
exit;
}
if(($globaladvs = $_DCACHE['settings']['globaladvs']) || !empty($_DCACHE['advs'])) {
$redirectadvs = $_DCACHE['settings']['redirectadvs'];
require_once '../include/advertisements.inc.php';
}
$headernav = '<a href="archiver/"><strong>'.$_DCACHE['settings']['bbname'].'</strong></a> ';
$headerbanner = !empty($advlist['headerbanner']) ? $advlist[headerbanner] : '';
require_once "./include/$action.inc.php";
showfooter();
function multi($total, $page, $perpage, $link) {
$pages = @ceil($total / $perpage) + 1;
$pagelink = '';
if($pages > 1) {
$pagelink .= "{$GLOBALS[lang][page]}: \n";
$pagestart = $page - 10 < 1 ? 1 : $page - 10;
$pageend = $page + 10 >= $pages ? $pages : $page + 10;
for($i = $pagestart; $i < $pageend; $i++) {
$pagelink .= ($i == $page ? "<strong>[$i]</strong>" : "<a href=archiver/$link-page-$i.html>$i</a>")." \n";
}
}
return $pagelink;
}
function forumperm($viewperm) {
return (empty($viewperm) || ($viewperm && strstr($viewperm, "\t7\t")));
}
function forumformulaperm($formula) {
$formula = unserialize($formula);$formula = $formula[1];
if(!$formula) {
return TRUE;
}
$_DSESSION = array();
@eval("\$formulaperm = ($formula) ? TRUE : FALSE;");
return $formulaperm;
}
function showheader() {
header('Content-Type: text/html; charset='.$charset);
global $boardurl, $_DCACHE, $charset, $navtitle, $headerbanner, $headernav;
echo <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<base href="{$boardurl}" />
<title>{$navtitle} {$_DCACHE['settings']['bbname']} {$_DCACHE['settings']['seotitle']} - Powered by Discuz! Archiver</title>
{$_DCACHE['settings']['seohead']}
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta name="keywords" content="Discuz!,Board,Comsenz,forums,bulletin board,{$_DCACHE['settings']['seokeywords']}" />
<meta name="description" content="{$meta_contentadd} {$_DCACHE['settings']['bbname']} {$_DCACHE['settings']['seodescription']} - Discuz! Archiver" />
<meta name="generator" content="Discuz! Archiver {$_DCACHE['settings']['version']}" />
<meta name="author" content="Discuz! Team & Comsenz UI Team" />
<meta name="copyright" content="2001-2009 Comsenz Inc." />
<style type="text/css">
body {font-family: Verdana;FONT-SIZE: 12px;MARGIN: 0;color: #000000;background: #ffffff;}
img {border:0;}
li {margin-top: 8px;}
.page {padding: 4px; border-top: 1px #EEEEEE solid}
.author {background-color:#EEEEFF; padding: 6px; border-top: 1px #ddddee solid}
#nav, #content, #footer {padding: 8px; border: 1px solid #EEEEEE; clear: both; width: 95%; margin: auto; margin-top: 10px;}
</style>
</head>
<body vlink="#333333" link="#333333">
<h2 style="text-align: center; margin-top: 20px">{$_DCACHE[settings][bbname]}'s Archiver </h2>
<center>{$headerbanner}</center>
<div id="nav">$headernav</div>
<div id="content">
EOT;
}
function showfooter() {
global $lang, $fullversion, $advlist, $_DCACHE;
echo "</div><div id=\"footer\">{$lang['full_version']}: <strong><a href=\"{$fullversion['link']}\" target=\"_blank\">{$fullversion['title']}</a></strong></div>";
empty($advlist['footerbanner1']) or print '<div class="archiver_banner">'.$advlist[footerbanner1].'</div>';
empty($advlist['footerbanner2']) or print '<div class="archiver_banner">'.$advlist[footerbanner2].'</div>';
empty($advlist['footerbanner3']) or print '<div class="archiver_banner">'.$advlist[footerbanner3].'</div>';
echo <<<EOT
<br /><center>
<div style="text-algin: center; font-size: 11px">Powered by <strong><a href="http://www.discuz.net" target="_blank">Discuz! Archiver</a></strong> {$_DCACHE['settings']['version']}
© 2001-2009 <a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a><br /><br /></div>
</center>
</body>
</html>
EOT;
}
?>
|
zyyhong
|
trunk/jiaju001/51shangcheng.cn/htdocs/archiver/index.php
|
PHP
|
asf20
| 7,832
|