forked from newz/2thchat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
791 additions
and
674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
<?php | ||
|
||
if(!defined('IN_DISCUZ')) { | ||
if (!defined('IN_DISCUZ')) { | ||
exit('Access Denied'); | ||
} | ||
|
||
require_once libfile('commonblock_html', 'class/block/html'); | ||
|
||
class block_thchat extends commonblock_html { | ||
class block_thchat extends commonblock_html | ||
{ | ||
|
||
function name() { | ||
function name() | ||
{ | ||
return '2th Chat'; | ||
} | ||
|
||
function block_forumtree() {} | ||
function getsetting() {} | ||
|
||
function getdata($style, $parameter) { | ||
function block_forumtree() | ||
{ | ||
} | ||
function getsetting() | ||
{ | ||
} | ||
|
||
function getdata($style, $parameter) | ||
{ | ||
global $_G; | ||
include DISCUZ_ROOT. './source/plugin/th_chat/include.php'; | ||
include DISCUZ_ROOT . './source/plugin/th_chat/include.php'; | ||
include template('th_chat:discuz'); | ||
return array('html' => $return, 'data' => null); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?php | ||
if(!defined('IN_DISCUZ')) { exit('Access Denied'); } | ||
if (!defined('IN_DISCUZ')) { | ||
exit('Access Denied'); | ||
} | ||
include 'include.php'; | ||
include template('th_chat:big'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,98 @@ | ||
<?php | ||
function getat($attextn){ | ||
function getat($attextn) | ||
{ | ||
global $config; | ||
if(preg_match_all('/@(.*?)(\s|\z)/',$attextn,$atmatch)) { | ||
foreach ($atmatch[1] as $atvalue) { | ||
$atuser = DB::fetch_first("SELECT m.uid,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.username='{$atvalue}' LIMIT 1"); | ||
if($atuser){ | ||
$attext = addslashes('<a class="nzuserat nzat_'.$atuser['uid'].'" onclick="nzAt(\''.($atvalue).'\');"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>@'.stripslashes($atvalue).'</a> '); | ||
}else{ | ||
$attext = '@'.$atvalue; | ||
if (preg_match_all('/@(.*?)(\s|\z)/', $attextn, $atmatch)) { | ||
foreach ($atmatch[1] as $atvalue) { | ||
$atuser = DB::fetch_first("SELECT m.uid,m.groupid,g.color FROM " . DB::table('common_member') . " m LEFT JOIN " . DB::table('common_usergroup') . " g ON m.groupid=g.groupid WHERE m.username='{$atvalue}' LIMIT 1"); | ||
if ($atuser) { | ||
$attext = addslashes('<a class="nzuserat nzat_' . $atuser['uid'] . '" onclick="nzAt(\'' . ($atvalue) . '\');"' . ($atuser['color'] ? ' style="color:' . $atuser['color'] . '"' : '') . '>@' . stripslashes($atvalue) . '</a> '); | ||
} else { | ||
$attext = '@' . $atvalue; | ||
} | ||
$attextn = str_replace("@".$atvalue,$attext,$attextn); | ||
} | ||
$attextn = str_replace("@" . $atvalue, $attext, $attextn); | ||
} | ||
} | ||
return $attextn; | ||
} | ||
function getat2($uid){ | ||
function getat2($uid) | ||
{ | ||
global $config; | ||
$atuser = DB::fetch_first("SELECT m.uid,m.username,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1"); | ||
$attext = '<a class="nzuserat2 nzat_'.$atuser['uid'].'" onclick="showWindow(\'th_chat_profile\', \'plugin.php?id=th_chat:profile&uid='.$uid.'\');return false;"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>'.$atuser['username'].'</a>'; | ||
$atuser = DB::fetch_first("SELECT m.uid,m.username,m.groupid,g.color FROM " . DB::table('common_member') . " m LEFT JOIN " . DB::table('common_usergroup') . " g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1"); | ||
$attext = '<a class="nzuserat2 nzat_' . $atuser['uid'] . '" onclick="showWindow(\'th_chat_profile\', \'plugin.php?id=th_chat:profile&uid=' . $uid . '\');return false;"' . ($atuser['color'] ? ' style="color:' . $atuser['color'] . '"' : '') . '>' . $atuser['username'] . '</a>'; | ||
return $attext; | ||
} | ||
function getat3($uid){ | ||
function getat3($uid) | ||
{ | ||
global $config; | ||
$atuser = DB::fetch_first("SELECT m.uid,m.username,m.groupid,g.color FROM ".DB::table('common_member')." m LEFT JOIN ".DB::table('common_usergroup')." g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1"); | ||
$attext = '<a class="nzuserat nzat_'.$atuser['uid'].'" onclick="nzAt(\''.addslashes($atuser['username']).'\');"'.($atuser['color']?' style="color:'.$atuser['color'].'"':'').'>'.$atuser['username'].'</a>'; | ||
$atuser = DB::fetch_first("SELECT m.uid,m.username,m.groupid,g.color FROM " . DB::table('common_member') . " m LEFT JOIN " . DB::table('common_usergroup') . " g ON m.groupid=g.groupid WHERE m.uid='{$uid}' LIMIT 1"); | ||
$attext = '<a class="nzuserat nzat_' . $atuser['uid'] . '" onclick="nzAt(\'' . addslashes($atuser['username']) . '\');"' . ($atuser['color'] ? ' style="color:' . $atuser['color'] . '"' : '') . '>' . $atuser['username'] . '</a>'; | ||
return $attext; | ||
} | ||
function getquota($quota){ | ||
function getquota($quota) | ||
{ | ||
global $config; | ||
if($quo = DB::query("SELECT uid,text FROM ".DB::table('newz_data')." WHERE id='".$quota."'")) | ||
{ | ||
if ($quo = DB::query("SELECT uid,text FROM " . DB::table('newz_data') . " WHERE id='" . $quota . "'")) { | ||
$quo = DB::fetch($quo); | ||
$quo['text'] = preg_replace('/\[quota\](.*?)\[\/quota\]/', '', $quo['text']); | ||
$attext = getat3($quo['uid']); | ||
$text = '[quota]'.addslashes('<div class="nzblockquote">'.$attext.': '.$quo['text'].'</div>').'[/quota]'; | ||
$text = '[quota]' . addslashes('<div class="nzblockquote">' . $attext . ': ' . $quo['text'] . '</div>') . '[/quota]'; | ||
} | ||
return $text; | ||
} | ||
function chatrow($id,$text,$uid_p,$username,$time,$touid,$icon,$mod){ | ||
global $uid,$config,$_G; | ||
function chatrow($id, $text, $uid_p, $username, $time, $touid, $icon, $mod) | ||
{ | ||
global $uid, $config, $_G; | ||
$tag = ''; | ||
if($icon=='alert'){ | ||
if ($icon == 'alert') { | ||
$tag = '<span class="nztag" style="background:#e53935">āđāļāđāļāđāļāļ·āļāļ</span>'; | ||
}elseif($icon=='bot'){ | ||
} elseif ($icon == 'bot') { | ||
$tag = '<span class="nztag" style="background:#546E7A">āļāļąāļāđāļāļĄāļąāļāļī</span>'; | ||
} | ||
if($uid_p == $_G['uid']){ | ||
return '<div class="nzchatrow" id="nzrows_'.$id.'" onMouseOver="nzchatobj(\'#nzchatquota'.$id.'\').css(\'opacity\',\'1\');" onMouseOut="nzchatobj(\'#nzchatquota'.$id.'\').css(\'opacity\',\'0\');"> | ||
if ($uid_p == $_G['uid']) { | ||
return '<div class="nzchatrow" id="nzrows_' . $id . '" onMouseOver="nzchatobj(\'#nzchatquota' . $id . '\').css(\'opacity\',\'1\');" onMouseOut="nzchatobj(\'#nzchatquota' . $id . '\').css(\'opacity\',\'0\');"> | ||
<div></div> | ||
<div class="nzcontentt nzme"> | ||
<div class="nzchatimenu"> | ||
<span id="nzchatquota'.$id.'" class="nzcq"><a href="javascript:void(0);" onClick="nzQuota('.$id.')">āļāđāļēāļāļāļīāļ</a> '.(($config['editmsg']==1)&&$mod||($config['editmsg']==2)&&$mod||(($config['editmsg']==3))?' <a href="javascript:;" onClick=\'nzCommand("edit","'.$id.'");\'>āđāļāđāđāļ</a>':'').($mod?' <a href="javascript:;" onClick=\'nzCommand("del","'.$id.'");\'>āļĨāļ</a>':'').'</span> | ||
<span id="nzchatquota' . $id . '" class="nzcq"><a href="javascript:void(0);" onClick="nzQuota(' . $id . ')">āļāđāļēāļāļāļīāļ</a> ' . (($config['editmsg'] == 1) && $mod || ($config['editmsg'] == 2) && $mod || (($config['editmsg'] == 3)) ? ' <a href="javascript:;" onClick=\'nzCommand("edit","' . $id . '");\'>āđāļāđāđāļ</a>' : '') . ($mod ? ' <a href="javascript:;" onClick=\'nzCommand("del","' . $id . '");\'>āļĨāļ</a>' : '') . '</span> | ||
<br> | ||
<span class="nztime" title="'.date("c",$time).'">'.get_date($time).'</span> | ||
<span class="nztime" title="' . date("c", $time) . '">' . get_date($time) . '</span> | ||
</div> | ||
<div class="nzinnercontent">'.$tag.$text.'</div> | ||
<div class="nzinnercontent">' . $tag . $text . '</div> | ||
</div> | ||
</div> | ||
<script>nzchatobj("#nzrows_'.$id.' span.nztime").timeago();</script>'; | ||
}else{ | ||
return '<div class="nzchatrow" id="nzrows_'.$id.'" onMouseOver="nzchatobj(\'#nzchatquota'.$id.'\').css(\'opacity\',\'1\');" onMouseOut="nzchatobj(\'#nzchatquota'.$id.'\').css(\'opacity\',\'0\');"> | ||
<script>nzchatobj("#nzrows_' . $id . ' span.nztime").timeago();</script>'; | ||
} else { | ||
return '<div class="nzchatrow" id="nzrows_' . $id . '" onMouseOver="nzchatobj(\'#nzchatquota' . $id . '\').css(\'opacity\',\'1\');" onMouseOut="nzchatobj(\'#nzchatquota' . $id . '\').css(\'opacity\',\'0\');"> | ||
<div class="nzavatart"> | ||
<a href="javascript:void(0);" onclick="showWindow(\'th_chat_profile\', \'plugin.php?id=th_chat:profile&uid='.$uid_p.'\');return false;"><img src="'.avatar($uid_p,'small',1).'" title="'.$username.'" class="nzchatavatar" onError="this.src=\'uc_server/images/noavatar_small.gif\';" /></a> | ||
<a href="javascript:void(0);" onclick="showWindow(\'th_chat_profile\', \'plugin.php?id=th_chat:profile&uid=' . $uid_p . '\');return false;"><img src="' . avatar($uid_p, 'small', 1) . '" title="' . $username . '" class="nzchatavatar" onError="this.src=\'uc_server/images/noavatar_small.gif\';" /></a> | ||
</div> | ||
<div class="nzcontentt"> | ||
'.getat2($uid_p).' | ||
' . getat2($uid_p) . ' | ||
<br> | ||
<div style="display:flex;align-items:flex-end;"> | ||
<div class="nzinnercontent">'.$tag.$text.'</div> | ||
<div class="nzinnercontent">' . $tag . $text . '</div> | ||
<div class="nzchatimenu"> | ||
<span id="nzchatquota'.$id.'" class="nzcq"><a href="javascript:void(0);" onClick="nzQuota('.$id.')">āļāđāļēāļāļāļīāļ</a> <a href="javascript:void(0);" onclick="nzAt(\''.addslashes($username).'\')">@</a> <a href="javascript:void(0);" onclick="nzTouid('.$uid_p.')">āđāļāļāļŠāđāļ§āļāļāļąāļ§</a> '.(($config['editmsg']==1)&&$mod?' <a href="javascript:;" onClick=\'nzCommand("edit","'.$id.'");\'>āđāļāđāđāļ</a>':'').($mod?' <a href="javascript:;" onClick=\'nzCommand("del","'.$id.'");\'>āļĨāļ</a>':'').'</span> | ||
<span id="nzchatquota' . $id . '" class="nzcq"><a href="javascript:void(0);" onClick="nzQuota(' . $id . ')">āļāđāļēāļāļāļīāļ</a> <a href="javascript:void(0);" onclick="nzAt(\'' . addslashes($username) . '\')">@</a> <a href="javascript:void(0);" onclick="nzTouid(' . $uid_p . ')">āđāļāļāļŠāđāļ§āļāļāļąāļ§</a> ' . (($config['editmsg'] == 1) && $mod ? ' <a href="javascript:;" onClick=\'nzCommand("edit","' . $id . '");\'>āđāļāđāđāļ</a>' : '') . ($mod ? ' <a href="javascript:;" onClick=\'nzCommand("del","' . $id . '");\'>āļĨāļ</a>' : '') . '</span> | ||
<br> | ||
<span class="nztime" title="'.date("c",$time).'">'.get_date($time).'</span> | ||
<span class="nztime" title="' . date("c", $time) . '">' . get_date($time) . '</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script>nzchatobj("#nzrows_'.$id.' span.nztime").timeago();</script>'; | ||
<script>nzchatobj("#nzrows_' . $id . ' span.nztime").timeago();</script>'; | ||
} | ||
} | ||
function get_date($timestamp) | ||
function get_date($timestamp) | ||
{ | ||
$strYear = substr(date("Y",$timestamp)+543,2,2); | ||
$strMonth= date("n",$timestamp); | ||
$strDay= date("j",$timestamp); | ||
$strHour= date("H",$timestamp); | ||
$strMinute= date("i",$timestamp); | ||
$strSeconds= date("s",$timestamp); | ||
$strMonthCut = array("","āļĄ.āļ.","āļ.āļ.","āļĄāļĩ.āļ.","āđāļĄ.āļĒ.","āļ.āļ.","āļĄāļī.āļĒ.","āļ.āļ.","āļŠ.āļ.","āļ.āļĒ.","āļ.āļ.","āļ.āļĒ.","āļ.āļ."); | ||
$strMonthThai=$strMonthCut[$strMonth]; | ||
$strYear = substr(date("Y", $timestamp) + 543, 2, 2); | ||
$strMonth = date("n", $timestamp); | ||
$strDay = date("j", $timestamp); | ||
$strHour = date("H", $timestamp); | ||
$strMinute = date("i", $timestamp); | ||
$strSeconds = date("s", $timestamp); | ||
$strMonthCut = array("", "āļĄ.āļ.", "āļ.āļ.", "āļĄāļĩ.āļ.", "āđāļĄ.āļĒ.", "āļ.āļ.", "āļĄāļī.āļĒ.", "āļ.āļ.", "āļŠ.āļ.", "āļ.āļĒ.", "āļ.āļ.", "āļ.āļĒ.", "āļ.āļ."); | ||
$strMonthThai = $strMonthCut[$strMonth]; | ||
return "$strDay $strMonthThai $strYear $strHour:$strMinute āļ."; | ||
} | ||
$time = TIMESTAMP; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
<?php | ||
if (!defined('IN_DISCUZ')) {exit('Access Denied');} | ||
if (!defined('IN_DISCUZ')) { | ||
exit('Access Denied'); | ||
} | ||
loadcache('plugin'); | ||
$config = $_G['cache']['plugin']['th_chat']; | ||
if ($_G['uid'] < 1) { | ||
die('Login'); | ||
die('Login'); | ||
} | ||
$maximgsize = 0; | ||
if(!empty($_G['group']['maxattachsize'])) { | ||
if (!empty($_G['group']['maxattachsize'])) { | ||
$maximgsize = intval($_G['group']['maxattachsize']); | ||
} else { | ||
$maximgsize = @ini_get(upload_max_filesize); | ||
$unit = strtolower(substr($maximgsize, -1, 1)); | ||
$maximgsize = intval($maximgsize); | ||
if($unit == 'k') { | ||
$maximgsize = $maximgsize*1024; | ||
} elseif($unit == 'm') { | ||
$maximgsize = $maximgsize*1024*1024; | ||
} elseif($unit == 'g') { | ||
$maximgsize = $maximgsize*1024*1024*1024; | ||
if ($unit == 'k') { | ||
$maximgsize = $maximgsize * 1024; | ||
} elseif ($unit == 'm') { | ||
$maximgsize = $maximgsize * 1024 * 1024; | ||
} elseif ($unit == 'g') { | ||
$maximgsize = $maximgsize * 1024 * 1024 * 1024; | ||
} | ||
} | ||
$todayimgcount = 0; | ||
$todayimgsize = 0; | ||
foreach (glob(__DIR__ . '/img_up/' . $_G['uid'] . '_'.date('Ymd',TIMESTAMP).'*') as $filename) { | ||
foreach (glob(__DIR__ . '/img_up/' . $_G['uid'] . '_' . date('Ymd', TIMESTAMP) . '*') as $filename) { | ||
$todayimgcount++; | ||
$todayimgsize += filesize($filename); | ||
} | ||
if($_G['group']['maxattachnum']) { | ||
if($todayimgcount >= $_G['group']['maxattachnum']){ | ||
if ($_G['group']['maxattachnum']) { | ||
if ($todayimgcount >= $_G['group']['maxattachnum']) { | ||
header('Content-Type: application/json'); | ||
echo json_encode(array('error' => 'āļāļāļāļ āļąāļĒ āļāļĨāļļāđāļĄāļŠāļĄāļēāļāļīāļāļāļāļāļāļļāļāļāļąāļāđāļŦāļĨāļāļ āļēāļāđāļāļĩāļĒāļāļ§āļąāļāļĨāļ° '.$_G['group']['maxattachnum'].' āļ āļēāļāđāļāđāļēāļāļąāđāļ')); | ||
exit(); | ||
echo json_encode(array('error' => 'āļāļāļāļ āļąāļĒ āļāļĨāļļāđāļĄāļŠāļĄāļēāļāļīāļāļāļāļāļāļļāļāļāļąāļāđāļŦāļĨāļāļ āļēāļāđāļāļĩāļĒāļāļ§āļąāļāļĨāļ° ' . $_G['group']['maxattachnum'] . ' āļ āļēāļāđāļāđāļēāļāļąāđāļ')); | ||
exit(); | ||
} | ||
} | ||
if($_G['group']['maxsizeperday']) { | ||
if($todayimgsize >= $_G['group']['maxsizeperday']){ | ||
if ($_G['group']['maxsizeperday']) { | ||
if ($todayimgsize >= $_G['group']['maxsizeperday']) { | ||
header('Content-Type: application/json'); | ||
echo json_encode(array('error' => 'āļāļāļāļ āļąāļĒ āļāļĨāļļāđāļĄāļŠāļĄāļēāļāļīāļāļāļāļāļāļļāļāļāļąāļāđāļŦāļĨāļāļ āļēāļāđāļāļĩāļĒāļāļ§āļąāļāļĨāļ° '.$_G['group']['maxsizeperday'].' Kb āđāļāđāļēāļāļąāđāļ')); | ||
exit(); | ||
echo json_encode(array('error' => 'āļāļāļāļ āļąāļĒ āļāļĨāļļāđāļĄāļŠāļĄāļēāļāļīāļāļāļāļāļāļļāļāļāļąāļāđāļŦāļĨāļāļ āļēāļāđāļāļĩāļĒāļāļ§āļąāļāļĨāļ° ' . $_G['group']['maxsizeperday'] . ' Kb āđāļāđāļēāļāļąāđāļ')); | ||
exit(); | ||
} | ||
} | ||
require_once "bulletproof.php"; | ||
$image = new Bulletproof\Image($_FILES); | ||
$image->setSize(1, $maximgsize); | ||
$image->setLocation(__DIR__ . "/img_up"); | ||
$image->setName($_G['uid'] . '_' . date('YmdHis',TIMESTAMP)); | ||
$image->setName($_G['uid'] . '_' . date('YmdHis', TIMESTAMP)); | ||
if ($image["pictures"]) { | ||
$upload = $image->upload(); | ||
header('Content-Type: application/json'); | ||
if ($upload) { | ||
echo json_encode(array('url' => $_G['siteurl'] . 'source/plugin/th_chat/img_up/' . $image->getName() . '.' . $image->getMime())); | ||
} else { | ||
echo json_encode(array('error' => $image->getError())); | ||
} | ||
$upload = $image->upload(); | ||
header('Content-Type: application/json'); | ||
if ($upload) { | ||
echo json_encode(array('url' => $_G['siteurl'] . 'source/plugin/th_chat/img_up/' . $image->getName() . '.' . $image->getMime())); | ||
} else { | ||
echo json_encode(array('error' => $image->getError())); | ||
} | ||
} |
Oops, something went wrong.