Don't like ads? PRO users don't see any ads ;-)

Untitled

By: mxneo on Dec 2nd, 2011  |  syntax: None  |  size: 3.89 KB  |  hits: 121  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. #Chatbox 1.1 For Discuz!X2 By I~DiscuzX_Serie
  3.  
  4. global $_G;
  5.  
  6. include('cache.lib.php');
  7. include('version.php');
  8.  
  9. loadcache('plugin');
  10.  
  11. $config = $_G['cache']['plugin']['chatbox'];
  12. $user = GetUserInfo($_G['username']);
  13.  
  14. $clang = ($user['lang']?$user['lang']:$config['defaultlang']);
  15.  
  16. include('lang/'.$clang.'/'.$clang.'.php');
  17.  
  18. $langs = get_lang();
  19.  
  20. foreach($langs as $v) {
  21.         $langlist[] = "['$v[langname]','$v[lang]']";
  22. }
  23.  
  24. $langlist = '['.implode(',',$langlist).']';
  25.  
  26. $_CB = array(
  27.         'authkey' => encode($_G['username'],$key),
  28.         'update' => $config['updatetime']*1000,
  29.         'messagelimit' => $config['messagelimit'],
  30.         'sendlimit' => $config['sendmessagelimit'],
  31.         'roomname' => $config['roomindex'],
  32.         'welcome' => $config['welcome'],
  33.         'height' => $config['height'],
  34.         'botname' => addslashes(htmlspecialchars($config['botname'])),
  35.         'messagelength' => $config['messagelength'],
  36.         'clear_message' => $config['clear_message'],
  37.         'defaultlang' => $config['defaultlang'],
  38.         'lang' => $clang,
  39.         'langlist' => $langlist,
  40. );
  41.  
  42. $_CB['bot'] = array(
  43.            'Chatbox1'=>array('nick'=>'Bot <<---','color'=>'blue','admin'=>2),
  44.            'Chatbox2'=>array('nick'=>'Bot --->>','color'=>'green','admin'=>2)
  45. );
  46.  
  47. function GetUserInfo($username) {
  48.         $discuz_user = DB::fetch_first("SELECT * FROM ".DB::table('common_member')." WHERE `username` = '{$username}'");
  49.         $group = DB::fetch_first("SELECT * FROM  ".DB::table('common_usergroup')." WHERE `groupid` = '$discuz_user[groupid]'");
  50.         $user = DB::fetch_first("SELECT * FROM ".DB::table('chatbox_member')." WHERE `username` = '{$discuz_user[username]}'");
  51.         if($discuz_user['adminid']==1) {
  52.                 $admin=1;
  53.         } elseif($group['radminid']>0||$user['admin']==1) {
  54.                 $admin=2;
  55.         } else {
  56.                 $admin=0;
  57.         }
  58.         $return['uid'] = (string)$user['uid'];
  59.         $return['username'] = (string)$user['username'];
  60.         $return['color'] = (string)$group['color'];
  61.         $return['point']['like'] = $user['point_like'];
  62.         $return['point']['dislike'] = $user['point_dislike'];
  63.         $return['like'] = explode(',',(string)$user['like']);
  64.         $return['showsys'] = (string)$user['showsys'];
  65.         $return['private'] = explode(',',(string)$user['private']);
  66.         $return['uprivate'] = (string)$user['uprivate'];
  67.         $return['lang'] = (string)$user['lang'];
  68.         $return['nick'] = (string)$user['nick'];
  69.         $return['background'] = explode('|',(string)$user['background']);
  70.         $return['ban'] = (int)$user['ban'];
  71.         $return['admin'] = (int)$admin;
  72.         return $return;
  73. }
  74.  
  75. function clang($lang,$mod='') {
  76.         if(is_array($mod)) {
  77.                 foreach($mod as $k => $v) {
  78.                         $lang = str_replace('{'.$k.'}', $v, $lang);
  79.                 }
  80.         }
  81.         return $lang;
  82. }
  83.  
  84. function get_lang() {
  85.         $langlist = array();
  86.         $dir = dirname(__FILE__).'/lang';
  87.         if($handle = opendir($dir)) {
  88.                 while($langs = readdir($handle))  {
  89.                         $file = $dir.'/'.$langs.'/'.$langs;
  90.                         if(file_exists($file.'.php')&&file_exists($file.'.js')) {
  91.                                 include($file.'.php');
  92.                                 $langlist[] = array('langname'=>$lang['name'],'lang'=>$langs);
  93.                         }
  94.                 }
  95.         }      
  96.         rsort($langlist);
  97.         return $langlist;
  98. }
  99.  
  100. function ip($ip) {
  101.         $ip = explode('.',$ip);
  102.         return "{$ip[0]}.{$ip[1]}.{$ip[2]}.xxx";
  103. }
  104.  
  105. function checkauth($text,$key) {
  106.         global $_G;
  107.         if(decode($text,$key)==$_G['username']) {
  108.                 return true;
  109.         } else {
  110.                 return false;
  111.         }
  112. }
  113.  
  114. function encode($string,$key) {
  115.         $key = sha1($key);
  116.         $strLen = strlen($string);
  117.         $keyLen = strlen($key);
  118.         for ($i=0;$i<$strLen;$i++) {
  119.                 $ordStr = ord(substr($string,$i,1));
  120.                 if($j==$keyLen) { $j = 0; }
  121.                 $ordKey = ord(substr($key,$j,1));
  122.                 $j++;
  123.                 $hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
  124.         }
  125.         return $hash;
  126. }
  127.  
  128. function decode($string,$key) {
  129.         $key = sha1($key);
  130.         $strLen = strlen($string);
  131.         $keyLen = strlen($key);
  132.         for($i=0;$i<$strLen;$i+=2) {
  133.                 $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16));
  134.                 if($j==$keyLen) { $j = 0; }
  135.                 $ordKey = ord(substr($key,$j,1));
  136.                 $j++;
  137.                 $hash .= chr($ordStr - $ordKey);
  138.         }
  139.         return $hash;
  140. }
  141.  
  142. ?>
  143.