page_begin("Chat Module", FALSE); class chat extends ajax_module{ function ajax(){ global $session,$config,$db,$tpl,$log,$error,$ccache; $curl='chat.funch.at'; $locs=array('default'=>array(array('title'=>'N/A','name'=>'nolocation','icon'=>'nolocation.png')),'Ponyville'=>array(array('title'=>'N/A','name'=>'nolocation','icon'=>'nolocation.png'),array('title'=>'Marketplace','name'=>'marketplace','icon'=>'marketplace.png'),array('title'=>'SCC','name'=>'candycane','icon'=>'candycane.png'),array('title'=>'SAA','name'=>'apple','icon'=>'apple.png'),array('title'=>'Library','name'=>'book','icon'=>'book.png'),array('title'=>'Fountain','name'=>'fountain','icon'=>'fountain.png'),array('title'=>'Spa','name'=>'spa','icon'=>'spa.png'),array('title'=>'Hospital','name'=>'redcross','icon'=>'redcross.png'),array('title'=>'Guard-House','name'=>'shield','icon'=>'shield.png'),array('title'=>'Home','name'=>'house','icon'=>'house.png')),'Wilds'=>array(array('title'=>'N/A','name'=>'nolocation','icon'=>'nolocation.png'),array('title'=>'Everfree Forest','name'=>'everfree','icon'=>'everfree.png'),array('title'=>'Zecoras Hut','name'=>'zecora','icon'=>'zecora.png'),array('title'=>'Ghastly Gorge','name'=>'ghastlygorge','icon'=>'ghastlygorge.png'),array('title'=>'Old Castle Ruins','name'=>'castle','icon'=>'castle.png'))); $weather=array('clear'=>array('day'=>array('name'=>'Sunny Day'),'night'=>array('name'=>'Clear Night')),'cloudy'=>array('night'=>array('name'=>'Cloudy Night'),'day'=>array('name'=>'Cloudy Day')),'drizzle'=>array('name'=>'Drizzle'),'rain'=>array('name'=>'Rain'),'rainbow'=>array('name'=>'Rainbow'),'fog'=>array('name'=>'Foggy'),'thunderstorm'=>array('name'=>'Thunderstorm'),'overcast'=>array('name'=>'Overcast'),'snow'=>array('name'=>'Snowing'),'snowstorm'=>array('name'=>'Blizzard'),'winter'=>array('name'=>'Winter'),'storm'=>array('name'=>'Stormy')); $adminweather=array('magicstorm'=>array('name'=>'Magical Storm')); function daytime() { $now = time(); $sun = date_sun_info($now, 47.6880, 13.1344); return ($sun['sunrise'] < $now && $now < $sun['sunset']); } if($_POST['call']=='userlist'){ if($session->userdata['uid']!=0){ $room = json_decode($_POST['dat']); //{"roomname":"Lounge","usercolor":"25a1ed","roomusers":[{"nick":"genuineparts","color":"25a1ed","typing":false,"notice":0}]} foreach($room->roomusers as $user) { if($user->notice==0){ $notice='notice_off.png'; }else{ $notice='notice_on.png'; } $result = $db->query("SELECT * FROM `aa_v_nickpage` WHERE `username`='".$user->nick."'"); $gender = $db->fetch_array($result); if($gender['gender']=='m'){ $gen='male'; }elseif($gender['gender']=='f'){ $gen='female'; }else{ $gen='na'; } if($session->userdata['chatrights']>=50){ $js="var menu = [ { name: \"kick\", action: function (element) { sendMsg(\"/k \"+$(element).attr('id')); } }, { name: \"jail\", action: function (element) { sendMsg(\"/jail \"+$(element).attr('id')); } }, { name: \"gag\", action: function (element) { sendMsg(\"/gag \"+$(element).attr('id')); } }, { name: \"ignore\", action: function (element) { sendMsg(\"/ig \"+$(element).attr('id')); } }, { name: \"invite\", action: function (element) { sendMsg(\"/i \"+$(element).attr('id')); } }, { name: \"catch\", action: function (element) { sendMsg(\"/c \"+$(element).attr('id')); } }, { name: \"whisperwindow\", action: function (element) { if ($('#'+$(element).attr('id')+'_whisper').length > 0){ $('#'+$(element).attr('id')+'_whisper').dialog('open'); $('#'+$(element).attr('id')+'_whisper').dialog('moveToTop'); }else{ create_whisper($(element).attr('id'),\"\"); } } }, { name: \"report\", action: function (element) { reportwindow($(element).attr('id')); } }, { name: \"reports\", action: function (element) { sendMsg(\"/rel \"+$(element).attr('id')); } } ];"; }else{ $js="var menu = [ { name: \"ignore\", action: function (element) { sendMsg(\"/ig \"+$(element).attr('id')); } }, { name: \"invite\", action: function (element) { sendMsg(\"/i \"+$(element).attr('id')); } }, { name: \"whisperwindow\", action: function (element) { if ($('#'+$(element).attr('id')+'_whisper').length > 0){ $('#'+$(element).attr('id')+'_whisper').dialog('open'); $('#'+$(element).attr('id')+'_whisper').dialog('moveToTop'); }else{ create_whisper($(element).attr('id'),\"\"); } } }, { name: \"report\", action: function (element) { reportwindow($(element).attr('id')); } } ];"; } $users[]=array('nick'=>$user->nick,'color'=>$user->color,'notice'=>$notice,'gender'=>$gen,'typing'=>$user->typing); } $tpl->assign('col',$room->usercolor); $tpl->assign('room',$room->roomname); $tpl->assign('users',$users); $tpl->assign('js',$js); return $tpl->fetch($config['fullpath'].'/modules/chat/templates/default/userlist.tpl'); } } if($_POST['call']=='rooms'){ if($session->userdata['uid']!=0){ $rooms = json_decode($_POST['dat']); foreach($rooms as $room) { $userlist[$room->room]['s'] = $room->lock; $userlist[$room->room]['g'] = $room->type; $userlist[$room->room]['u'] = array(); $i=0; foreach($room->users as $user) { if($user->notice==0){ $notice='notice_off.png'; }else{ $notice='notice_on.png'; } $result = $db->query("SELECT * FROM `aa_v_nickpage` WHERE `username`='".$user->nick."'"); $gender = $db->fetch_array($result); if($gender['gender']=='m'){ $gen='male'; }elseif($gender['gender']=='f'){ $gen='female'; }else{ $gen='na'; } $userlist[$room->room]['u'][$i]['c'] = $user->color; $userlist[$room->room]['u'][$i]['n'] = $user->nick; $userlist[$room->room]['u'][$i]['i'] = $notice; $userlist[$room->room]['u'][$i]['g'] = $gen; $i++; } } if($session->userdata['chatrights']>=50){ $js="var menu = [ { name: \"kick\", action: function (element) { window.socket.send(\"/k \"+$(element).attr('id')); } }, { name: \"jail\", action: function (element) { window.socket.send(\"/jail \"+$(element).attr('id')); } }, { name: \"gag\", action: function (element) { socket.send(\"/gag \"+$(element).attr('id')); } }, { name: \"toggle private\", action: function (element) { window.socket.send(\"/tpc \"+$(element).attr('id')); } }, { name: \"ignore\", action: function (element) { window.socket.send(\"/ig \"+$(element).attr('id')); } }, { name: \"invite\", action: function (element) { window.socket.send(\"/i \"+$(element).attr('id')); } }, { name: \"catch\", action: function (element) { window.socket.send(\"/c \"+$(element).attr('id')); } }, { name: \"whisperwindow\", action: function (element) { if ($('#'+$(element).attr('id')+'_whisper').length > 0){ $('#'+$(element).attr('id')+'_whisper').dialog('open'); $('#'+$(element).attr('id')+'_whisper').dialog('moveToTop'); }else{ create_whisper($(element).attr('id'),\"\"); } } }, { name: \"report\", action: function (element) { reportwindow($(element).attr('id')); } }, { name: \"reports\", action: function (element) { window.socket.send(\"/rel \"+$(element).attr('id')); } } ];"; }else{ $js="var menu = [ { name: \"ignore\", action: function (element) { window.socket.send(\"/ig \"+$(element).attr('id')); } }, { name: \"invite\", action: function (element) { window.socket.send(\"/i \"+$(element).attr('id')); } }, { name: \"report\", action: function (element) { reportwindow($(element).attr('id')); } } ];"; } $tpl->assign('users',$userlist); $tpl->assign('js',$js); return $tpl->fetch($config['fullpath'].'/modules/chat/templates/default/allroomlist.tpl'); } } if($_GET['call']=='col'){ if(isset($_GET['yacsid']) && $_GET['yacsid']!='' && $session->userdata['uid']!=0){ if (!$fh = fopen('http://'.$curl.':'.$config['SOCK_PORT'].'/room?yacsid='.$_GET['yacsid'], 'r')){ return false; } // Read data and close while(!feof($fh)) $content .= fread($fh, 1024); fclose($fh); $content = trim($content); $stuff = explode('/', $content); return $stuff[0]; } } if($_GET['call']=='notice'){ if(isset($_GET['yacsid']) && $_GET['yacsid']!='' && $_GET['nuser']!='' && $session->userdata['uid']!=0){ if (!$fh = fopen('http://'.$curl.':'.$config['SOCK_PORT'].'/notice?yacsid='.$_GET['yacsid'].'&nuser='.$_GET['nuser'], 'r')){ return false; } // Read data and close while(!feof($fh)) $content .= fread($fh, 1024); fclose($fh); return trim($content); } } if($_GET['call']=='groupnotice'){ if(isset($_GET['yacsid']) && $_GET['yacsid']!='' && $_GET['ngroup']!='' && $_GET['user']!='' && $session->userdata['uid']!=0){ $res = $db->query("SELECT u.`name` FROM `yac_users` c LEFT JOIN `" . $config["prefix"] . "rp_chars` u ON u.`id`=c.`uid` WHERE c.`location`='".$db->escape($_GET['ngroup'])."' AND c.`uid` <> '".intval($_GET['user'])."'"); while($dat = $db->fetch_array($res)){ if (!$fh = fopen('http://'.$curl.':'.$config['SOCK_PORT'].'/notice?yacsid='.$_GET['yacsid'].'&nuser='.$dat['name'], 'r')){ return false; } // Read data and close fclose($fh); } return TRUE; } } if($_GET['call']=='getlocations'){ if($_GET['room']!='' && $_GET['room']!='null' && $_GET['chid']!='' && $session->userdata['uid']!=0){ $locations = '
'; if(!is_array($locs[$_GET['room']])){ $locs[$_GET['room']]=$locs['default']; } $res = $db->query("SELECT `location` FROM `ptc_users` WHERE `uid`='".intval($_GET['chid'])."' LIMIT 1"); $dat = $db->fetch_array($res); foreach($locs[$_GET['room']] as $loc){ if($dat['location'] == $loc['name']){ $locations .= ''; }else{ $locations .= ''; } } if($session->userdata['uid']==1){ $locations.=''; } return $locations.'