Commit 548320ca authored by winddramon's avatar winddramon

insite message system v0.1

初步移植了站内信(后台发站内信功能还没移植)。为了偷懒,直接把新电波的jQuery和滚动条功能照搬过来,现在多了一堆文件,不过应该虱子多了不痒……吧?
parent aef88df9
.b_button {
display: inline-block;
zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */
*display: inline;
vertical-align: baseline;
margin: 0 2px;
outline: none;
cursor: pointer;
text-align: center;
text-decoration: none;
font: bold 14px/100% 微软雅黑, Arial, Helvetica, sans-serif;
padding: .5em 2em .55em;
text-shadow: 0 1px 1px rgba(0,0,0,.3);
-webkit-border-radius: .5em;
-moz-border-radius: .5em;
border-radius: .5em;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.b_button:hover {
text-decoration: none;
}
.b_button:active {
position: relative;
top: 1px;
}
.b_bigrounded {
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
border-radius: 2em;
}
.b_medium {
font-size: 12px;
padding: .4em 1.5em .42em;
}
.b_small {
font-size: 11px;
padding: .2em 1em .275em;
}
.bc_black {
color: #d7d7d7;
border: solid 1px #333;
background: #333;
background: -webkit-gradient(linear, left top, left bottom, from(#666), to(#000));
background: -moz-linear-gradient(top, #666, #000);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#666666', endColorstr='#000000');
}
.bc_black:hover {
background: #000;
background: -webkit-gradient(linear, left top, left bottom, from(#444), to(#000));
background: -moz-linear-gradient(top, #444, #000);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#444444', endColorstr='#000000');
}
.bc_black:active {
color: #666;
background: -webkit-gradient(linear, left top, left bottom, from(#000), to(#444));
background: -moz-linear-gradient(top, #000, #444);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#666666');
}
.bc_gray {
color: #e9e9e9;
border: solid 1px #555;
background: #6e6e6e;
background: -webkit-gradient(linear, left top, left bottom, from(#888), to(#575757));
background: -moz-linear-gradient(top, #888, #575757);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#888888', endColorstr='#575757');
}
.bc_gray:hover {
background: #616161;
background: -webkit-gradient(linear, left top, left bottom, from(#757575), to(#4b4b4b));
background: -moz-linear-gradient(top, #757575, #4b4b4b);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#757575', endColorstr='#4b4b4b');
}
.bc_gray:active {
color: #afafaf;
background: -webkit-gradient(linear, left top, left bottom, from(#575757), to(#888));
background: -moz-linear-gradient(top, #575757, #888);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#575757', endColorstr='#888888');
}
.bc_white {
color: #606060;
border: solid 1px #b7b7b7;
background: #fff;
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
background: -moz-linear-gradient(top, #fff, #ededed);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
}
.bc_white:hover {
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#dcdcdc));
background: -moz-linear-gradient(top, #fff, #dcdcdc);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dcdcdc');
}
.bc_white:active {
color: #999;
background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#fff));
background: -moz-linear-gradient(top, #ededed, #fff);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#ffffff');
}
\ No newline at end of file
div.message_line{display:flex;display:-webkit-flex;justify-content:flex-start;}
div.message_ib{margin:5px 10px 10px 0px;display:inline-block;}
div.message_box
{
background-color:rgba(20,22,24,0.5); *BACKGROUND: rgb(20,22,24); *filter:alpha(opacity=50);
width:290px;
border:1px solid #666; border-radius:7px;
}
div.message_box span{position:relative;max-height:300px;overflow:hidden;}
div.message_title_bar {position:relative;text-align:center;margin: 5px 5px 10px 5px;}
div.message_cont{text-align:left;margin: 0 5px;min-height:50px;}
div.message_encl{position:relative;text-align:center;text-align:left;margin: 0 5px;min-height:32px;}
div.message_encl_hint{z-index:5;position:absolute;left:0px;top:0px;}
div.message_date{text-align:right;margin: 0 5px;}
span.message_title{color:#98fb98;font:bold 15pt "微软雅黑";}
div.message_hint{position:absolute;right:3px;bottom:3px}
hr.message_hr{border:1px dashed #777;}
img.message_sign{
position:absolute;right:15px;top:5px;display:none;font:bold 22pt "微软雅黑";color:#999;
}
\ No newline at end of file
......@@ -208,6 +208,11 @@ if(CURSCRIPT !== 'chat')
save_gameinfo();
}
//除拉取聊天以外的访问都判定一下是否有新的站内信。
$new_messages = 0;
include_once GAME_ROOT.'./include/messages.func.php';
is_there_new_messages();
fclose($plock);
}
?>
/*
* CSS Styles that are needed by jScrollPane for it to operate correctly.
*
* Include this stylesheet in your site or copy and paste the styles below into your stylesheet - jScrollPane
* may not operate correctly without them.
*/
.jspContainer
{
overflow: hidden;
position: relative;
}
.jspPane
{
position: absolute;
}
.jspVerticalBar
{
position: absolute;
top: 0;
right: 0;
width: 9px;
height: 100%;
background: red;
}
.jspHorizontalBar
{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 16px;
background: red;
}
.jspCap
{
display: none;
}
.jspHorizontalBar .jspCap
{
float: left;
}
.jspTrack
{
background: #dde;
position: relative;
}
.jspDrag
{
background: #bbd;
position: relative;
top: 0;
left: 0;
cursor: pointer;
}
.jspHorizontalBar .jspTrack,
.jspHorizontalBar .jspDrag
{
float: left;
height: 100%;
}
.jspArrow
{
background: #50506d;
text-indent: -20000px;
display: block;
cursor: pointer;
padding: 0;
margin: 0;
}
.jspArrow.jspDisabled
{
cursor: default;
background: #80808d;
}
.jspVerticalBar .jspArrow
{
height: 16px;
}
.jspHorizontalBar .jspArrow
{
width: 16px;
float: left;
height: 100%;
}
.jspVerticalBar .jspArrow:focus
{
outline: none;
}
.jspCorner
{
background: #eeeef4;
float: left;
height: 100%;
}
/* Yuk! CSS Hack for IE6 3 pixel bug :( */
* html .jspCorner
{
margin: 0 -3px 0 0;
}
\ No newline at end of file
This diff is collapsed.
.jspHorizontalBar,
.jspVerticalBar,
.jspTrack
{
background: url('ScrollBarBackground.png') repeat-y;
filter:alpha(opacity=60);
opacity:0.6;
}
.jspDrag
{
background: #bbd;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
.jspTrack .jspActive,
.jspTrack .jspHover,
.jspDrag:hover
{
background: #8B8B9F;
}
.jspArrow
{
/*
background: url(../image/ui-icons_222222_256x240.png) no-repeat;
*/
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
.jspVerticalBar>.jspActive,
.jspArrow:hover
{
/*
background-image: url('../image/ui-icons_cd0a0a_256x240.png');
*/
}
.jspVerticalBar>.jspDisabled,
.jspVerticalBar>.jspDisabled:hover,
.jspHorizontalBar>.jspDisabled,
.jspHorizontalBar>.jspDisabled:hover
{
background-color: transparent;
/*
background-image: url('../image/ui-icons_888888_256x240.png');
*/
}
.jspVerticalBar .jspArrow
{
height: 15px;
}
.jspHorizontalBar .jspArrow
{
width: 15px;
}
.jspArrowUp
{
background-position: 0 0;
}
.jspArrowDown
{
background-position: -64px 0 !important;
}
.jspArrowLeft
{
background-position: -96px 0 !important;
}
.jspArrowRight
{
background-position: -32px 0 !important;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/*!
* jQuery Mousewheel 3.1.12
*
* Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
(function (factory) {
if ( typeof define === 'function' && define.amd ) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS style for Browserify
module.exports = factory;
} else {
// Browser globals
factory(jQuery);
}
}(function (jQuery) {
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice = Array.prototype.slice,
nullLowestDeltaTimeout, lowestDelta;
if ( jQuery.event.fixHooks ) {
for ( var i = toFix.length; i; ) {
jQuery.event.fixHooks[ toFix[--i] ] = jQuery.event.mouseHooks;
}
}
var special = jQuery.event.special.mousewheel = {
version: '3.1.12',
setup: function() {
if ( this.addEventListener ) {
for ( var i = toBind.length; i; ) {
this.addEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
// Store the line height and page height for this particular element
jQuery.data(this, 'mousewheel-line-height', special.getLineHeight(this));
jQuery.data(this, 'mousewheel-page-height', special.getPageHeight(this));
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i = toBind.length; i; ) {
this.removeEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
// Clean up the data we added to the element
jQuery.removeData(this, 'mousewheel-line-height');
jQuery.removeData(this, 'mousewheel-page-height');
},
getLineHeight: function(elem) {
var jQueryelem = jQuery(elem),
jQueryparent = jQueryelem['offsetParent' in jQuery.fn ? 'offsetParent' : 'parent']();
if (!jQueryparent.length) {
jQueryparent = jQuery('body');
}
return parseInt(jQueryparent.css('fontSize'), 10) || parseInt(jQueryelem.css('fontSize'), 10) || 16;
},
getPageHeight: function(elem) {
return jQuery(elem).height();
},
settings: {
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
normalizeOffset: true // calls getBoundingClientRect for each event
}
};
jQuery.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
},
unmousewheel: function(fn) {
return this.unbind('mousewheel', fn);
}
});
function handler(event) {
var orgEvent = event || window.event,
args = slice.call(arguments, 1),
delta = 0,
deltaX = 0,
deltaY = 0,
absDelta = 0,
offsetX = 0,
offsetY = 0;
event = jQuery.event.fix(orgEvent);
event.type = 'mousewheel';
// Old school scrollwheel delta
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaX = deltaY * -1;
deltaY = 0;
}
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
delta = deltaY === 0 ? deltaX : deltaY;
// New school wheel delta (wheel event)
if ( 'deltaY' in orgEvent ) {
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
}
if ( 'deltaX' in orgEvent ) {
deltaX = orgEvent.deltaX;
if ( deltaY === 0 ) { delta = deltaX * -1; }
}
// No change actually happened, no reason to go any further
if ( deltaY === 0 && deltaX === 0 ) { return; }
// Need to convert lines and pages to pixels if we aren't already in pixels
// There are three delta modes:
// * deltaMode 0 is by pixels, nothing to do
// * deltaMode 1 is by lines
// * deltaMode 2 is by pages
if ( orgEvent.deltaMode === 1 ) {
var lineHeight = jQuery.data(this, 'mousewheel-line-height');
delta *= lineHeight;
deltaY *= lineHeight;
deltaX *= lineHeight;
} else if ( orgEvent.deltaMode === 2 ) {
var pageHeight = jQuery.data(this, 'mousewheel-page-height');
delta *= pageHeight;
deltaY *= pageHeight;
deltaX *= pageHeight;
}
// Store lowest absolute delta to normalize the delta values
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
if ( !lowestDelta || absDelta < lowestDelta ) {
lowestDelta = absDelta;
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
lowestDelta /= 40;
}
}
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
// Divide all the things by 40!
delta /= 40;
deltaX /= 40;
deltaY /= 40;
}
// Get a whole, normalized value for the deltas
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
// Normalise offsetX and offsetY properties
if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
var boundingRect = this.getBoundingClientRect();
offsetX = event.clientX - boundingRect.left;
offsetY = event.clientY - boundingRect.top;
}
// Add information to the event object
event.deltaX = deltaX;
event.deltaY = deltaY;
event.deltaFactor = lowestDelta;
event.offsetX = offsetX;
event.offsetY = offsetY;
// Go ahead and set deltaMode to 0 since we converted to pixels
// Although this is a little odd since we overwrite the deltaX/Y
// properties with normalized deltas.
event.deltaMode = 0;
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
// Clearout lowestDelta after sometime to better
// handle multiple device types that give different
// a different lowestDelta
// Ex: trackpad = 3 and mouse wheel = 120
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
return (jQuery.event.dispatch || jQuery.event.handle).apply(this, args);
}
function nullLowestDelta() {
lowestDelta = null;
}
function shouldAdjustOldDeltas(orgEvent, absDelta) {
// If this is an older event and the delta is divisable by 120,
// then we are assuming that the browser is treating this as an
// older mouse wheel event and that we should divide the deltas
// by 40 to try and get a more usable deltaFactor.
// Side note, this actually impacts the reported scroll distance
// in older browsers and can cause scrolling to be slower than native.
// Turn this off by setting jQuery.event.special.mousewheel.settings.adjustOldDeltas to false.
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
}
}));
/**
* @author trixta
* @version 1.2
*/
(function(jQuery){
var mwheelI = {
pos: [-260, -260]
},
minDif = 3,
doc = document,
root = doc.documentElement,
body = doc.body,
longDelay, shortDelay
;
function unsetPos(){
if(this === mwheelI.elem){
mwheelI.pos = [-260, -260];
mwheelI.elem = false;
minDif = 3;
}
}
jQuery.event.special.mwheelIntent = {
setup: function(){
var jElm = jQuery(this).bind('mousewheel', jQuery.event.special.mwheelIntent.handler);
if( this !== doc && this !== root && this !== body ){
jElm.bind('mouseleave', unsetPos);
}
jElm = null;
return true;
},
teardown: function(){
jQuery(this)
.unbind('mousewheel', jQuery.event.special.mwheelIntent.handler)
.unbind('mouseleave', unsetPos)
;
return true;
},
handler: function(e, d){
var pos = [e.clientX, e.clientY];
if( this === mwheelI.elem || Math.abs(mwheelI.pos[0] - pos[0]) > minDif || Math.abs(mwheelI.pos[1] - pos[1]) > minDif ){
mwheelI.elem = this;
mwheelI.pos = pos;
minDif = 250;
clearTimeout(shortDelay);
shortDelay = setTimeout(function(){
minDif = 10;
}, 200);
clearTimeout(longDelay);
longDelay = setTimeout(function(){
minDif = 3;
}, 1500);
e = jQuery.extend({}, e, {type: 'mwheelIntent'});
return (jQuery.event.dispatch || jQuery.event.handle).apply(this, arguments);
}
}
};
jQuery.fn.extend({
mwheelIntent: function(fn) {
return fn ? this.bind("mwheelIntent", fn) : this.trigger("mwheelIntent");
},
unmwheelIntent: function(fn) {
return this.unbind("mwheelIntent", fn);
}
});
jQuery(function(){
body = doc.body;
//assume that document is always scrollable, doesn't hurt if not
jQuery(doc).bind('mwheelIntent.mwheelIntentDefault', jQuery.noop);
});
})(jQuery);
<?php
if(!defined('IN_GAME')) {
exit('Access Denied');
}
$title2qiegao = 50;//已有头衔再次获得时转成多少切糕。单独一项配置不想放在其他文件里,干脆就丢这
$messages_autocreatedb = 1;//自动建表功能,一个很丑陋的开关
function init_messages($mode){
if('showdel' == $mode || 'recover' == $mode) {
return deleted_message_load();
}else{
return message_load();
}
}
//判断有没有新站内信,基本上每次载入页面都需要调用
//因为check这个词用在查收站内信上了,不要吐槽这个命名
function is_there_new_messages(){
global $db, $gtablepre, $cuser, $new_messages, $messages_autocreatedb;
$new_messages = 0;
if($cuser){
//考虑到devtools.php也得先载入common.inc.php,从而如果没有建表就会直接出错,必须在这里就做判断是否存在message表
//而既然做了判断为什么不直接建表呢?
//可以把$messages_autocreatedb关掉来阻止这罪恶的一切
if(!empty($messages_autocreatedb)){
$result = $db->query("SHOW TABLES LIKE '{$gtablepre}messages'");
$ret = $db->fetch_array($result);
if(empty($ret)){
create_messages_db();
}
}
$result = $db->query("SELECT mid FROM {$gtablepre}messages WHERE receiver='$cuser' AND rd=0");
$new_messages = $db->num_rows($result);
}
}
//很丑陋
function create_messages_db(){
global $db, $gtablepre;
$query =
"DROP TABLE IF EXISTS bra_messages;
CREATE TABLE bra_messages (
`mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` int(10) unsigned NOT NULL DEFAULT '0',
`rd` tinyint(1) unsigned NOT NULL DEFAULT '0',
`checked` tinyint(1) unsigned NOT NULL DEFAULT '0',
`receiver` char(15) NOT NULL DEFAULT '',
`sender` char(15) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`enclosure` text NOT NULL DEFAULT '',
PRIMARY KEY (`mid`),
INDEX `RECEIVER` (`receiver`),
INDEX `SENDER` (`sender`)
) ENGINE=MyISAM;
DROP TABLE IF EXISTS bra_del_messages;
CREATE TABLE bra_del_messages (
`mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` int(10) unsigned NOT NULL DEFAULT '0',
`dtimestamp` int(10) unsigned NOT NULL DEFAULT '0',
`rd` tinyint(1) unsigned NOT NULL DEFAULT '0',
`checked` tinyint(1) unsigned NOT NULL DEFAULT '0',
`receiver` char(15) NOT NULL DEFAULT '',
`sender` char(15) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`enclosure` text NOT NULL DEFAULT '',
PRIMARY KEY (`mid`),
INDEX `RECEIVER` (`receiver`),
INDEX `SENDER` (`sender`)
) ENGINE=MyISAM;";
$db->queries(str_replace('bra_',$gtablepre,$query));
}
function message_create($to, $title='', $content='', $enclosure='', $from='sys', $t=0)
{
global $now,$db,$gtablepre;
if(!$t) $t = $now;
if(!$to) return;
$ins_arr = array(
'timestamp' => $t,
'sender' => $from,
'receiver' => $to,
'title' => $title,
'content' => $content,
'enclosure' => $enclosure
);
$db->array_insert("{$gtablepre}messages", $ins_arr);
}
//虽然直接放到sys模块里了,但是某些地方需要第二次更新的话,还是需要这个
function message_check_new($username)
{
global $db,$gtablepre;
$result = $db->query("SELECT mid FROM {$gtablepre}messages WHERE receiver='$username' AND rd=0");
$num = $db->num_rows($result);
return $num;
}
function message_load($mid_only=0)
{
global $udata,$db,$gtablepre;
$username = $udata['username'];
if($mid_only) $result = $db->query("SELECT mid FROM {$gtablepre}messages WHERE receiver='$username' ORDER BY timestamp DESC, mid DESC");
else $result = $db->query("SELECT * FROM {$gtablepre}messages WHERE receiver='$username' ORDER BY timestamp DESC, mid DESC");
$messages = array();
while($r = $db->fetch_array($result)){
$messages[$r['mid']] = $r;
}
return $messages;
}
function deleted_message_load()
{
global $udata,$db,$gtablepre;
$username = $udata['username'];
$result = $db->query("SELECT * FROM {$gtablepre}del_messages WHERE receiver='$username' ORDER BY dtimestamp DESC, mid DESC");
$d_messages = array();
while($r = $db->fetch_array($result)){
$d_messages[$r['mid']] = $r;
}
return $d_messages;
}
//获得站内信附件中的数字,$tp为传入的前缀,会匹配并返回"tp_xxx"中的xxx数字
function message_get_encl_num($encl, $tp)
{
preg_match('/'.$tp.'_(\d+)/s', $encl, $matches);
if($matches && is_numeric($matches[1])) return $matches[1];
else return 0;
}
//显示站内信前的处理
function message_disp($messages)
{
global $udata, $titles_list, $title_desc;
foreach($messages as $mi => &$mv){
$mv['hint'] = '<span class="L5 b">NEW!</span>';
if($mv['rd']) $mv['hint'] = '';
$mv['time_disp'] = date("Y年m月d日 H:i:s", $mv['timestamp']);
if(isset($mv['dtimestamp'])) $mv['del_time_disp'] = date("Y年m月d日 H:i:s", $mv['dtimestamp']);
$mv['encl_disp'] = '';
if(!empty($mv['enclosure'])){
if($mv['checked']) $mv['encl_hint'] = '<span class="grey b">附件已收</span>';
else $mv['encl_hint'] = "<a class='L5 b' onclick=\"$('extracmd').name='sl$mi';$('extracmd').value='1';$('mode').value='check';postCmd('message_cmd', 'messages.php');$('extracmd').name='extracmd';$('extracmd').value='';\">附件<br>点此查收</a>";
//切糕判定
$getqiegao = message_get_encl_num($mv['enclosure'], 'getqiegao');
if($getqiegao) {
$mv['encl_disp'] .= '<div class="gold b">'.$getqiegao.'切糕</div>';
}
//头衔判定
$gettitle = message_get_encl_num($mv['enclosure'], 'gettitle');
if($gettitle && !empty($titles_list[$gettitle])) {//不存在的头衔不要发
$nicksrev_disp = is_array($udata['nicksrev']) ? $udata['nicksrev'] : json_decode($udata['nicksrev'],true);
$nownew = !in_array($gettitle, $nicksrev_disp['nicks']);
$mv['encl_disp'] .= '<div>头衔:<span class="'.$title_desc[$gettitle]['class'].'">'.$titles_list[$gettitle].($nownew ? ' <span class="L5 b">NEW!</span>' : '').'</span></div>';
}
}
}
return $messages;
}
//查收站内信
function message_check($checklist, $messages)
{
global $udata,$db,$gtablepre,$info, $titles_list, $title_desc, $title2qiegao;
if(empty($udata['nicksrev'])) $udata['nicksrev'] = Array('nicks' => Array(0));
//不知道$nicksrev在保存前究竟要不要手动转义,保险点不改原值
$nicksrev_disp = is_array($udata['nicksrev']) ? $udata['nicksrev'] : json_decode($udata['nicksrev'],true);
$getqiegaosum = $gettitleflag = 0;
foreach($checklist as $cid){
if($messages[$cid]['checked']) continue;
if(!empty($messages[$cid]['enclosure'])){
//获得切糕
$getqiegao = message_get_encl_num($messages[$cid]['enclosure'], 'getqiegao');
if($getqiegao) {
$info[] = '获得了<span class="gold b">'.$getqiegao.'切糕</span>';
$getqiegaosum += $getqiegao;
}
//获得卡片
$gettitle = message_get_encl_num($messages[$cid]['enclosure'], 'gettitle');
if(!empty($gettitle)) {
$getname = $titles_list[$gettitle];
if(!in_array($gettitle, $nicksrev_disp['nicks'])) {
$info[] = '获得了头衔 “<span class="'.$title_desc[$gettitle]['class'].'">'.$titles_list[$gettitle].'</span>”!';
titles_get_new($udata, $gettitle);
}else {
$info[] = '已有头衔 “<span class="'.$title_desc[$gettitle]['class'].'">'.$titles_list[$gettitle].'</span>”,转化为了'.$title2qiegao.'切糕!';
$getqiegaosum += $title2qiegao;
}
$gettitleflag = 1;
}
}
}
if($getqiegaosum || $gettitle) {//头衔在titles_get_new()似乎就已经更新了,这里只更新切糕
$n = $udata['username'];
$c = $udata['credits2']+$getqiegaosum;
$t = $udata['nicksrev'];
$db->array_update("{$gtablepre}users", Array('credits2' => $c, 'nicksrev' => $t), "username='".$n."'");
}
}
/* End of file messages.func.php */
/* Location: include/messages.func.php */
\ No newline at end of file
......@@ -227,4 +227,39 @@ CREATE TABLE bra_vnmixitem (
`itmsk` varchar(40) NOT NULL DEFAULT '',
PRIMARY KEY (iid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS bra_messages;
CREATE TABLE bra_messages (
`mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` int(10) unsigned NOT NULL DEFAULT '0',
`rd` tinyint(1) unsigned NOT NULL DEFAULT '0',
`checked` tinyint(1) unsigned NOT NULL DEFAULT '0',
`receiver` char(15) NOT NULL DEFAULT '',
`sender` char(15) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`enclosure` text NOT NULL DEFAULT '',
PRIMARY KEY (`mid`),
INDEX `RECEIVER` (`receiver`),
INDEX `SENDER` (`sender`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS bra_del_messages;
CREATE TABLE `bra_del_messages` (
`mid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`timestamp` int(10) unsigned NOT NULL DEFAULT '0',
`dtimestamp` int(10) unsigned NOT NULL DEFAULT '0',
`rd` tinyint(1) unsigned NOT NULL DEFAULT '0',
`checked` tinyint(1) unsigned NOT NULL DEFAULT '0',
`receiver` char(15) NOT NULL DEFAULT '',
`sender` char(15) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL DEFAULT '',
`enclosure` text NOT NULL DEFAULT '',
PRIMARY KEY (`mid`),
INDEX `RECEIVER` (`receiver`),
INDEX `SENDER` (`sender`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
\ No newline at end of file
<?php
define('CURSCRIPT', 'messages');
require './include/common.inc.php';
require_once './include/messages.func.php';
if(!$cuser||!$cpass) { gexit($_ERROR['no_login'],__file__,__line__); }
if(!$udata) { gexit($_ERROR['login_check'],__file__,__line__); }
if($udata['password'] != $cpass) { gexit($_ERROR['wrong_pw'], __file__, __line__); }
if($udata['groupid'] <= 0) { gexit($_ERROR['user_ban'], __file__, __line__); }
$username = $udata['username'];
$message_rec_cost = 100;//恢复邮件价格
if(!isset($mode)){
$mode = 'show';
}
$messages = init_messages($mode);
$editflag = 0;
$info = array();
if($mode == 'del' || $mode == 'del2') {//删除
$dellist = array();
foreach(array_keys($messages) as $mi){
if(!empty(${'sl'.$mi})) $dellist[] = $mi;
}
if(!empty($dellist)) $editflag = 1;
}elseif($mode == 'check') {//查看并收取附件
$checklist = array();
foreach(array_keys($messages) as $mi){
if(!empty(${'sl'.$mi}) && !$messages[$mi]['checked'] && !empty($messages[$mi]['enclosure'])) $checklist[] = $mi;
}
if(!empty($checklist)) $editflag = 1;
}elseif($mode == 'recover') {//恢复删除邮件
$reclist = array();
foreach(array_keys($messages) as $mi){
if(!empty(${'sl'.$mi})) $reclist[] = $mi;
}
if(!empty($reclist)) {
$cost = $message_rec_cost * sizeof($reclist);
if($udata['gold'] < $cost) {
$info[] = '切糕不足,无法恢复邮件!';
}else {
\cardbase\get_qiegao(-$cost, $udata);
$info[] = '支付了'.$cost.'切糕';
$editflag = 1;
}
}
}
if($editflag) {
if(!empty($checklist)){
message_check($checklist, $messages);
$checkc = implode(',',$checklist);
if(count($checklist) > 1) $info[] = '已查收'.count($checklist).'条消息!';
else $info[] = '消息已查收!';
$db->query("UPDATE {$gtablepre}messages SET checked='1' WHERE mid IN ($checkc) AND receiver='$username'");
}
if(!empty($dellist)){
$ins_arr = array();
foreach($dellist as $di){
$tmp = $messages[$di];
$tmp['dtimestamp'] = $now;
unset($tmp['mid']);
$ins_arr[] = $tmp;
}
if(!empty($ins_arr)) $db->array_insert("{$gtablepre}del_messages", $ins_arr);
$delc = implode(',',$dellist);
if('del' == $mode){
$db->query("DELETE FROM {$gtablepre}messages WHERE mid IN ($delc) AND receiver='$username'");
$dnum = $db->affected_rows();
$info[] = '已删除'.$dnum.'条消息!';
}elseif('del2' == $mode){
$db->query("DELETE FROM {$gtablepre}dmessages WHERE mid IN ($delc) AND receiver='$username'");
$dnum = $db->affected_rows();
$info[] = '已彻底删除'.$dnum.'条消息!';
}
}
if(!empty($reclist)){
$ins_arr = array();
foreach($reclist as $ri){
$tmp = $messages[$ri];
unset($tmp['mid'],$tmp['dtimestamp']);
$ins_arr[] = $tmp;
}
if(!empty($ins_arr)) $db->array_insert("{$gtablepre}messages", $ins_arr);
$recc = implode(',',$reclist);
$db->query("DELETE FROM {$gtablepre}del_messages WHERE mid IN ($recc) AND receiver='$username'");
$rnum = $db->affected_rows();
$info[] = '已恢复'.$rnum.'条消息!';
}
//重载一次信息
$messages = init_messages($mode);
}elseif(strpos($mode,'show') !== 0 && empty($info)){
$info[] = '没有做任何更改';
}
//全部设为已读
if('show' == $mode){
foreach($messages as $mv){
if(!$mv['rd']) {
$db->query("UPDATE {$gtablepre}messages SET rd='1' WHERE receiver='$username' AND rd='0'");
break;
}
}
}
$messages = message_disp($messages);
if('show'==$mode){//生成整个页面,不用ajax
include template('message_page');
}else{//有指令,需要ajax
$gamedata=Array();
$gamedata['innerHTML']['info'] = implode('<br>', $info);
if(isset($error)) $gamedata['innerHTML']['error'] = $error;
include template('messages');
$gamedata['innerHTML']['messages'] = ob_get_contents();
$jgamedata = compatible_json_encode($gamedata);
ob_clean();
echo $jgamedata;
}
/* End of file messages.php */
/* Location: /messages.php */
\ No newline at end of file
......@@ -8,6 +8,24 @@
<!--{if isset($extrahead)}-->$extrahead<!--{/if}-->
<script async defer data-website-id="645ba563-c97e-4270-97af-d669335db957" src="https://tracker.dts.gay/umami.js"></script>
<!--{if $allowcsscache}--><link rel="stylesheet" type="text/css" id="css" href="gamedata/cache/style_20190718.css"><!--{else}--><style type="text/css" id="css">{template css}</style><!--{/if}-->
<!--{if (CURSCRIPT == 'messages')}-->
<link rel="stylesheet" type="text/css" href="gamedata/cache/style_buttons.20180118.css">
<link rel="stylesheet" type="text/css" href="gamedata/cache/style_messages.20180221.css">
<!--{/if}-->
<!-- 为了在移植时偷懒,我直接对jQuery进行一个入的引 -->
<!-- jScrollPanel Utility Start -->
<link type="text/css" href="include/javascript/jScrollPane/jquery.jscrollpane.css" rel="stylesheet" media="all" />
<link type="text/css" href="include/javascript/jScrollPane/jquery.jscrollpane.lozenge.css" rel="stylesheet" media="all" />
<script type="text/javascript" src="include/javascript/jScrollPane/jquery.min.js"></script>
<script type="text/javascript" src="include/javascript/jScrollPane/jquery.mousewheel.js"></script>
<script type="text/javascript" src="include/javascript/jScrollPane/mwheelIntent.js"></script>
<script type="text/javascript" src="include/javascript/jScrollPane/jquery.jscrollpane.js"></script>
<script type="text/javascript" id="sourcecode">
jQuery.noConflict();
</script>
<!-- jScrollPanel Utility End -->
<script type="text/javascript" src="include/common.js"></script>
<script type="text/javascript" src="include/game20130526.js"></script>
<script type="text/javascript" src="include/json.js"></script>
......@@ -28,7 +46,13 @@
<div class="title" >{lang title}</div>
<div class="headerlink" >
<a href="index.php">>>{lang index}</a>
<!--{if isset($cuser) && isset($cpass)}--><a href="user_profile.php">>>{lang user}</a>
<!--{if isset($cuser) && isset($cpass)}-->
<a href="messages.php">>>{lang messages}
<!--{if !empty($new_messages)}-->
<span class="L5 b">NEW!</span>
<!--{/if}-->
</a>
<a href="user_profile.php">>>{lang user}</a>
<!--{else}--><a href="register.php">>>{lang register}</a><!--{/if}-->
<a href="game.php">>>{lang game}</a>
<a href="map.php">>>{lang map}</a>
......
{template header}
<div class="subtitle" align="center">{lang messages}</div>
<center>
<div class="yellow b" id="info"></div>
<div>
<form method="post" name="message_cmd" onsubmit="messages.php">
<input type="hidden" id="mode" name="mode" value="show">
<input type="hidden" id="extracmd" name="extracmd" value="">
<div id="messages">
{template messages}
</div>
</form>
</div>
</center>
{template footer}
\ No newline at end of file
<div style="position:relative">
<div id="loading"></div>
<div>
<!--{if 'showdel' == $mode && empty($info) }--><div class="grey b">系统会定期清空垃圾箱中1个月以上的邮件</div><!--{/if}-->
<!--{if 'showdel' == $mode || 'recover' == $mode}-->
<div style="display:inline-block;width:160px"></div>
<input type="button" class="b_button bc_black" value="返回邮箱" onclick="$('mode').value='showmail';postCmd('message_cmd', 'messages.php');this.disabled=true;" />&nbsp;&nbsp;&nbsp;
<!--{if !empty($messages)}-->
<!--<input type="button" class="b_button bc_black" value="全选/反选" onclick="jQuery('.message_sl').each(function(){this.click();});" />-->
<input type="button" class="b_button bc_black" style="width:114px" value="恢复" onclick="
var recflag=0;
jQuery('.message_sl').each(function(){
if(this.checked){recflag=1;return false;}
});
if(recflag){
if($('mode').value!='recover') {
$('rec_confirm').style.display='inline';
this.value='确认恢复';
$('mode').value='recover';
}else{
$('rec_confirm').style.display='none';
postCmd('message_cmd', 'messages.php');this.disabled=true;
$('mode').value='';
}
}
" />
<!--{/if}-->
<div style="display:inline-block;width:160px"><span class="yellow b" id="rec_confirm" style="display:none">每条{$message_rec_cost}切糕,确认恢复?</span></div>
<!--{else}-->
<div style="display:inline-block;width:80px"></div>
<input type="button" class="b_button bc_black" value="查看已删邮件" onclick="$('mode').value='showdel';postCmd('message_cmd', 'messages.php');this.disabled=true;" />&nbsp;&nbsp;&nbsp;
<!--{if !empty($messages)}-->
<input type="button" class="b_button bc_black" value="全选/反选" onclick="jQuery('.message_sl').each(function(){this.click();});" />
<input type="button" class="b_button bc_black" value="查收附件" onclick="$('mode').value='check';postCmd('message_cmd', 'messages.php');this.disabled=true;" />
<input type="button" class="b_button bc_black" style="width:114px" value="删除" onclick="
var delflag=0;
jQuery('.message_sl').each(function(){
if(this.checked){delflag=1;return false;}
});
if(delflag){
if($('mode').value!='del') {
$('del_confirm').style.display='inline';
this.value='确认删除';
$('mode').value='del';
}else{
$('del_confirm').style.display='none';
postCmd('message_cmd', 'messages.php');this.disabled=true;
$('mode').value='';
}
}
" />
<!--{/if}-->
<div style="display:inline-block;width:80px"><span class="yellow b" id="del_confirm" style="display:none">确认删除?</span></div>
<!--{/if}-->
</div>
<div class="scroll-pane" style="max-width:1210px;max-height:640px;overflow:hidden;vertical-align:top">
<!--{if empty($messages)}-->
<span class="grey b">一条信息都没有呢</span>
<!--{else}-->
<!--{eval $i=0;}-->
<!--{loop $messages $mi $mv}-->
<!--{if $i%4==0}--><div class="message_line"><!--{/if}-->
<div class="message_ib">
<div class="message_box" onclick="$('message_sl$mi').click();if($('message_sl$mi').checked) {$('sign$mi').style.display='block';} else {$('sign$mi').style.display='none';}">
<div class="message_title_bar">
<img id="sign$mi" class="message_sign" src="img/message_sl_sign.png">
<input type="checkbox" name="sl$mi" id="message_sl$mi" style="display:none" class="message_sl" value="1" />
<span class="message_title">$mv['title']</span> <div class="message_hint">$mv['hint']</div>
</div>
<div class="message_cont"><span>$mv['content']</span></div>
<hr class="message_hr">
<div class="message_encl">
<div class="message_encl_hint">$mv['encl_hint']</div>
<div style="text-align:center">
<span>$mv['encl_disp']</span>
</div>
</div>
<hr class="message_hr">
<div class="grey b message_date">
<!--{if isset($mv['del_time_disp'])}-->
<span>删除时间: $mv['del_time_disp']</span>
<!--{else}-->
<span>$mv['time_disp']</span>
<!--{/if}-->
</div>
</div>
</div>
<!--{if $i%4==3 || $i==count($messages)-1}--></div><!--{/if}-->
<!--{eval $i++;}-->
<!--{/loop}-->
<!--{/if}-->
</div>
<img type="hidden" style="display:none" src="img/blank.png" onload="jQuery(function() { jQuery('.scroll-pane').jScrollPane(); });">
</div>
\ No newline at end of file
......@@ -7,8 +7,9 @@ $language = array
'index' => '首页',
'fullwin' => '全屏模式',
'backindex' => '返回首页',
'messages' => '站内邮件',
'register' => '账号注册',
'user' => '帐号资料',
'game' => '进入游戏',
'map' => '战场地图',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment