2025-06-02 10:01:12 +02:00
< ? php
2025-06-23 20:45:15 +02:00
global $session ;
If ( ! defined ( " INBCWE " )) {
2025-06-02 10:01:12 +02:00
die ( " Dieses Script kann nicht ausserhalb des Frameworks laufen! " );
}
$addnav [ " right " ] = FALSE ;
2025-06-23 20:45:15 +02:00
$session -> page_begin ( " Chat Module " , FALSE );
2025-06-02 10:01:12 +02:00
class chat extends ajax_module {
function ajax (){
global $session , $config , $db , $tpl , $log , $error , $ccache ;
2025-06-08 21:24:12 +02:00
$curl = 'chat.funch.at' ;
2025-06-02 10:01:12 +02:00
$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 ();
$sunrise = date_sunrise ( $now , SUNFUNCS_RET_TIMESTAMP , 47.6880 , 13.1344 );
$sunset = date_sunset ( $now , SUNFUNCS_RET_TIMESTAMP , 47.6880 , 13.1344 );
return ( $sunrise < $now && $now < $sunset );
}
if ( $_POST [ 'call' ] == 'userlist' ){
if ( $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 = $ccache->get('userroom'.$_GET['yacsid']);
$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 );
2025-06-19 00:07:46 +02:00
if ( $gender [ 'gender' ] == 'm' ){
2025-06-02 10:01:12 +02:00
$gen = 'male' ;
2025-06-19 00:07:46 +02:00
} elseif ( $gender [ 'gender' ] == 'f' ){
2025-06-02 10:01:12 +02:00
$gen = 'female' ;
} else {
$gen = 'na' ;
}
if ( $session -> userdata [ 'rp_admin' ] == 1 ){
$js = " var menu = [
2025-06-08 21:24:12 +02:00
{ 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')); } },
2025-06-02 10:01:12 +02:00
{ 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 {
2025-06-08 21:24:12 +02:00
create_whisper ( $ ( element ) . attr ( 'id' ), \ " \" );
2025-06-02 10:01:12 +02:00
} } },
{ name : \ " report \" , action: function (element) { reportwindow( $ (element).attr('id')); } },
2025-06-08 21:24:12 +02:00
{ name : \ " reports \" , action: function (element) { sendMsg( \" /rel \" + $ (element).attr('id')); } }
2025-06-02 10:01:12 +02:00
]; " ;
} else {
$js = " var menu = [
2025-06-08 21:24:12 +02:00
{ name : \ " ignore \" , action: function (element) { sendMsg( \" /ig \" + $ (element).attr('id')); } },
{ name : \ " invite \" , action: function (element) { sendMsg( \" /i \" + $ (element).attr('id')); } },
2025-06-02 10:01:12 +02:00
{ 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 {
2025-06-08 21:24:12 +02:00
create_whisper ( $ ( element ) . attr ( 'id' ), \ " \" );
2025-06-02 10:01:12 +02:00
} } },
{ name : \ " report \" , action: function (element) { reportwindow( $ (element).attr('id')); } }
]; " ;
}
$users [] = array ( 'nick' => $user -> nick , 'color' => $user -> color , 'notice' => $notice , 'gender' => $gen , 'typing' => $user -> typing , 'location' => $location );
}
$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 ) {
if ( $session -> userdata [ 'allow_grimdark' ] == 0 && $room -> type == 'grimdark' ){
continue ;
}
$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' ;
}
2025-06-03 08:40:33 +02:00
$result = $db -> query ( " SELECT * FROM `aa_v_nickpage` WHERE `username`=' " . $user -> nick . " ' " );
2025-06-02 10:01:12 +02:00
$gender = $db -> fetch_array ( $result );
2025-06-19 00:07:46 +02:00
if ( $gender [ 'fid3' ] == 'Männlich' ){
2025-06-02 10:01:12 +02:00
$gen = 'male' ;
2025-06-19 00:07:46 +02:00
} elseif ( $gender [ 'fid3' ] == 'Weiblich' ){
2025-06-02 10:01:12 +02:00
$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 ;
$userlist [ $room -> room ][ 'u' ][ $i ][ 'l' ] = $location ;
$i ++ ;
}
}
if ( $session -> userdata [ 'rp_admin' ] == 1 ){
$js = " var menu = [
2025-06-15 22:25:18 +02:00
{ name : \ " kick \" , action: function (element) { window.socket.send( \" /k \" + $ (element).attr('id')); } },
{ name : \ " jail \" , action: function (element) { window.socket.send( \" /jail \" + $ (element).attr('id')); } },
2025-06-08 21:24:12 +02:00
{ name : \ " gag \" , action: function (element) { socket.send( \" /gag \" + $ (element).attr('id')); } },
2025-06-15 22:25:18 +02:00
{ 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')); } },
2025-06-02 10:01:12 +02:00
{ 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 {
2025-06-08 21:24:12 +02:00
create_whisper ( $ ( element ) . attr ( 'id' ), \ " \" );
2025-06-02 10:01:12 +02:00
} } },
{ name : \ " report \" , action: function (element) { reportwindow( $ (element).attr('id')); } },
2025-06-15 22:25:18 +02:00
{ name : \ " reports \" , action: function (element) { window.socket.send( \" /rel \" + $ (element).attr('id')); } }
2025-06-02 10:01:12 +02:00
]; " ;
} else {
$js = " var menu = [
2025-06-15 22:25:18 +02:00
{ name : \ " ignore \" , action: function (element) { window.socket.send( \" /ig \" + $ (element).attr('id')); } },
{ name : \ " invite \" , action: function (element) { window.socket.send( \" /i \" + $ (element).attr('id')); } },
2025-06-02 10:01:12 +02:00
{ 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 = '<div style="padding-right:1px; width:18px; float:left;"><a class="loc" id="reset"><img title="Remove Location" alt="Remove Location" src="/modules/chat/locations/remove.png" style="border:0;"/></a></div>' ;
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 .= '<div style="padding-right:1px; width:18px; float:left;"><a class="loc" id="' . $loc [ 'name' ] . '"><img title="' . $loc [ 'title' ] . '" alt="' . $loc [ 'title' ] . '" src="/modules/chat/locations/' . $loc [ 'icon' ] . '" style="padding:1px; border:2px solid #FFFF00;"/></a><br/><a class="setgroup" id="' . $loc [ 'name' ] . '"><img title=" Toggle ' . $loc [ 'title' ] . ' for notifications" alt="Set ' . $loc [ 'title' ] . ' for notifications" src="/themes/ponytopia/images/notice_on.png" style="padding:2px;"/></a></div>' ;
} else {
$locations .= '<div style="padding-right:1px; width:18px; float:left;"><a class="loc" id="' . $loc [ 'name' ] . '"><img title="' . $loc [ 'title' ] . '" alt="' . $loc [ 'title' ] . '" src="/modules/chat/locations/' . $loc [ 'icon' ] . '" style="padding:2px; border:0;"/></a><br/><a class="setgroup" id="' . $loc [ 'name' ] . '"><img title=" Set ' . $loc [ 'title' ] . ' for notifications" alt="Toggle ' . $loc [ 'title' ] . ' for notifications" src="/themes/ponytopia/images/notice_on.png" style="padding:2px;"/></a></div>' ;
}
}
if ( $session -> userdata [ 'uid' ] == 1 ){
$locations .= '<div style="padding-right:1px; width:18px; float:left;"><a class="loc" id="coding"><img title="Coding" alt="coding" src="/modules/chat/locations/coding.png" style="padding:4px; border:0;"/></a></div>' ;
}
return $locations . '<br style="clear:left;" />' ;
}
}
if ( $_GET [ 'call' ] == 'setlocation' ){
if ( $_GET [ 'chid' ] != '' && $_GET [ 'location' ] != '' && $session -> userdata [ 'uid' ] != 0 ){
if ( $_GET [ 'location' ] == 'reset' ){
$_GET [ 'location' ] = '' ;
}
$db -> query ( " UPDATE `ptc_users` SET `location`=' " . $db -> escape ( $_GET [ 'location' ]) . " ' WHERE `uid`=' " . intval ( $_GET [ 'chid' ]) . " ' " );
}
}
if ( $_GET [ 'call' ] == 'getweather' ){
if ( $session -> userdata [ 'uid' ] != 0 && $_GET [ 'chid' ] != '' ){
if ( $_GET [ 'weather' ] == " none " ){
return '<img src="/modules/chat/weather/none.png" title="None" alt="This Room has no weather enabled or does not provide Weather information" />' ;
} else {
$teamset = '' ;
$lock = '' ;
$uweather = array_merge ( $weather , $adminweather );
$curweather = $weather [ $_GET [ 'weather' ]];
//$res = $db->query("SELECT `weatherteam` FROM `" . $config["prefix"] . "rp_chars` WHERE `id`='".intval($_GET['chid'])."'");
//$team = $db->fetch_array($res);
if ( $_GET [ 'can' ] == 'true' || $session -> userdata [ 'rp_admin' ] == '1' ){
if ( $config [ 'weatherlocked' ] == 1 && $session -> userdata [ 'weather_admin' ] != '1' )
{
$lock = ' disabled="disabled"' ;
} else {
$lock = '' ;
}
$teamset = '<br /><select' . $lock . ' name="setweather" onchange="setweather(this.value)">' ;
if ( $session -> userdata [ 'weather_admin' ] == '1' )
{
$weather = array_merge ( $weather , $adminweather );
}
foreach ( $weather as $key => $value ){
if ( $_GET [ 'weather' ] == $key ){
$current = ' selected="selected"' ;
} else {
$current = '' ;
}
if ( isset ( $value [ 'day' ]) && isset ( $value [ 'night' ])){
$teamset .= '<option' . $current . ' value="' . $key . '">' . ucfirst ( $key ) . '</option>' ;
} else {
$teamset .= '<option' . $current . ' value="' . $key . '">' . $value [ 'name' ] . '</option>' ;
}
}
$teamset .= '</select>' ;
}
if ( $session -> userdata [ 'weather_admin' ] == '1' ){
if ( $config [ 'weatherlocked' ] == 1 ){
$checked = 'checked="checked"' ;
}
$teamset .= '<br /><input type="checkbox" ' . $checked . ' name="lockweather" onchange="setlock(this.value)" /><span style="color:#ffffff">Weatherlock</span>' ;
}
if ( isset ( $curweather [ 'day' ]) && isset ( $curweather [ 'night' ])){
$daytime = daytime ();
if ( $daytime || $config [ 'forceday' ] == 1 ){
$wt [ $_GET [ 'weather' ] . '_day' ] = $curweather [ 'day' ];
$wt [ 'name' ] = $curweather [ 'day' ][ 'name' ];
} elseif ( $config [ 'forcenight' ] == 1 ){
$wt [ $_GET [ 'weather' ] . '_night' ] = $curweather [ 'night' ];
$wt [ 'name' ] = $curweather [ 'night' ][ 'name' ];
} else {
$wt [ $_GET [ 'weather' ] . '_night' ] = $curweather [ 'night' ];
$wt [ 'name' ] = $curweather [ 'night' ][ 'name' ];
}
return '<img src="/modules/chat/weather/' . key ( $wt ) . '.png" title="' . $wt [ 'name' ] . '" alt="' . $wt [ 'name' ] . '" />' . $teamset ;
} else {
$wt = $curweather ;
}
return '<img src="/modules/chat/weather/' . $_GET [ 'weather' ] . '.png" title="' . $wt [ 'name' ] . '" alt="' . $wt [ 'name' ] . '" />' . $teamset ;
}
}
}
if ( $_GET [ 'call' ] == 'setweather' ){
if ( $session -> userdata [ 'uid' ] != 0 && $_GET [ 'chid' ] != '' && $_GET [ 'weather' ] != '' ){
if ( $config [ 'weatherlocked' ] != 1 || $session -> userdata [ 'weather_admin' ] == 1 )
{
$teamset = '' ;
$curweather = $weather [ $config [ 'weather' ]];
$res = $db -> query ( " SELECT `weatherteam` FROM ` " . $config [ " prefix " ] . " rp_chars` WHERE `id`=' " . intval ( $_GET [ 'chid' ]) . " ' " );
$team = $db -> fetch_array ( $res );
if ( $team [ 'weatherteam' ] == 'true' || $session -> userdata [ 'rp_admin' ] == '1' ){
$result = $db -> query ( " UPDATE ` " . $config [ " prefix " ] . " config` SET `value`=' " . $db -> escape ( $_GET [ 'weather' ]) . " ' WHERE `name`='weather' " );
}
}
}
}
if ( $_GET [ 'call' ] == 'setlock' ){
if ( $session -> userdata [ 'uid' ] != 0 && $session -> userdata [ 'weather_admin' ] == '1' ){
if ( $config [ 'weatherlocked' ] == 1 )
{
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " config` SET `value`='0' WHERE `name`='weatherlocked' " );
} else {
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " config` SET `value`='1' WHERE `name`='weatherlocked' " );
}
}
}
if ( $_GET [ 'call' ] == 'chars' ){
$chars = '' ;
$result = $db -> query ( " SELECT `name` FROM ` " . $config [ " prefix " ] . " rp_chars` WHERE `name` LIKE ' " . $db -> escape ( $_GET [ 'term' ]) . " %' " );
while ( $n = $db -> fetch_array ( $result )){
$chars [] = $n [ 'name' ];
}
if ( ! empty ( $chars )){
return '["' . join ( $chars , '","' ) . '"]' ;
}
}
if ( $_GET [ 'call' ] == 'users' ){
$chars = '' ;
$result = $db -> query ( " SELECT `username` FROM ` " . $config [ " prefix " ] . " users` WHERE `username` LIKE ' " . $db -> escape ( $_GET [ 'term' ]) . " %' " );
while ( $n = $db -> fetch_array ( $result )){
$chars [] = $n [ 'username' ];
}
if ( ! empty ( $chars )){
return '["' . join ( $chars , '","' ) . '"]' ;
}
}
if ( $_GET [ 'call' ] == 'adduser' ){
$result = $db -> query ( " SELECT `uid`,`username` FROM ` " . $config [ " prefix " ] . " users` WHERE `username` = ' " . $db -> escape ( $_GET [ 'user' ]) . " ' " );
if ( $db -> num_rows ( $result ) <= 0 ){
return false ;
} else {
$dat = $db -> fetch_array ( $result );
$results = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " conversations` WHERE `id` = ' " . $db -> escape ( $_GET [ 'cid' ]) . " ' AND `owner`=' " . $session -> userdata [ 'uid' ] . " ' " );
$datr = $db -> fetch_array ( $results );
if ( $db -> num_rows ( $results ) <= 0 ){
return false ;
} else {
$resultss = $db -> query ( " SELECT * FROM ` " . $config [ " prefix " ] . " conversations` WHERE `room` = ' " . $db -> escape ( $datr [ 'room' ]) . " ' AND `timestamp`=' " . $db -> escape ( $datr [ 'timestamp' ]) . " ' " );
while ( $row = $db -> fetch_array ( $resultss )){
$users [] = $row [ 'uid' ];
}
if ( ! in_array ( $dat [ 'uid' ], $users )){
$db -> query ( " INSERT INTO ` " . $config [ " prefix " ] . " conversations` (`uid`,`owner`,`room`,`timestamp`,`shared`) VALUES (' " . $db -> escape ( $dat [ 'uid' ]) . " ',' " . $db -> escape ( $datr [ 'owner' ]) . " ',' " . $db -> escape ( $datr [ 'room' ]) . " ',' " . $db -> escape ( $datr [ 'timestamp' ]) . " ','') " );
return $dat [ 'uid' ];
} else {
return false ;
}
}
}
}
if ( $_GET [ 'call' ] == 'repdelete' ){
if ( $session -> userdata [ 'rp_admin' ] == '1' ){
$db -> query ( " DELETE FROM `ptc_reports` WHERE `rid` = ' " . intval ( $_GET [ 'id' ]) . " ' " );
}
}
if ( $_GET [ 'call' ] == 'repseen' ){
if ( $session -> userdata [ 'rp_admin' ] == '1' ){
$db -> query ( " UPDATE `ptc_reports` SET `seen`=1 WHERE `rid` = ' " . intval ( $_GET [ 'id' ]) . " ' " );
}
}
if ( $_GET [ 'call' ] == 'repunseen' ){
if ( $session -> userdata [ 'rp_admin' ] == '1' ){
$sql = " UPDATE `ptc_reports` SET `seen`='0' WHERE `rid` = ' " . intval ( $_GET [ 'id' ]) . " ' " ;
echo $sql ;
$db -> query ( " UPDATE `ptc_reports` SET `seen`='0' WHERE `rid` = ' " . intval ( $_GET [ 'id' ]) . " ' " );
}
}
if ( $_GET [ 'call' ] == 'deleteuser' ){
$results = $db -> query ( " SELECT `room` FROM ` " . $config [ " prefix " ] . " conversations` WHERE `id` = ' " . $db -> escape ( $_GET [ 'cid' ]) . " ' AND `owner`=' " . $session -> userdata [ 'uid' ] . " ' " );
$datr = $db -> fetch_array ( $results );
$db -> query ( " DELETE FROM ` " . $config [ " prefix " ] . " conversations` WHERE `uid` = ' " . $db -> escape ( $_GET [ 'id' ]) . " ' AND `room` = ' " . $db -> escape ( $datr [ 'room' ]) . " ' AND `owner`=' " . $session -> userdata [ 'uid' ] . " ' " );
}
if ( $_GET [ 'call' ] == 'public' ){
$results = $db -> query ( " SELECT u.`username`, c.`shared` FROM ` " . $config [ " prefix " ] . " conversations` c LEFT JOIN ` " . $config [ " prefix " ] . " users` u ON c.`uid`=u.`uid` WHERE c.`id` = ' " . $db -> escape ( $_GET [ 'id' ]) . " ' AND c.`owner`=' " . $session -> userdata [ 'uid' ] . " ' " );
$datr = $db -> fetch_array ( $results );
if ( $datr [ 'shared' ] == '' ){
$key = $session -> generate_Key ();
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " conversations` SET `shared`=' " . $key . " ' WHERE `id` = ' " . $db -> escape ( $_GET [ 'id' ]) . " ' AND `owner`=' " . $session -> userdata [ 'uid' ] . " ' " );
return '//logs.' . $config [ 'domain' ] . '/user/' . $datr [ 'username' ] . '/key/' . $key ;
} else {
$db -> query ( " UPDATE ` " . $config [ " prefix " ] . " conversations` SET `shared`='' WHERE `id` = ' " . $db -> escape ( $_GET [ 'id' ]) . " ' AND `owner`=' " . $session -> userdata [ 'uid' ] . " ' " );
return false ;
}
}
if ( $_GET [ 'call' ] == 'bg_music' ){
$result = $db -> query ( " UPDATE ` " . $config [ " prefix " ] . " rp_chars` SET `bgmusic`=' " . $db -> escape ( $_GET [ 'value' ]) . " ' WHERE `id`=' " . $db -> escape ( $_GET [ 'char' ]) . " ' AND `uid`=' " . $session -> userdata [ 'uid' ] . " ' " );
}
if ( $_GET [ 'call' ] == 'wh' ){
$result = $db -> query ( " UPDATE `ptc_users` SET `whisperwindow`=' " . $db -> escape ( $_GET [ 'value' ]) . " ' WHERE `uid`=' " . $session -> userdata [ 'uid' ] . " ' " );
}
if ( $_GET [ 'call' ] == 'noticech' ){
$result = $db -> query ( " UPDATE `ptc_users` SET `notice`=' " . $db -> escape ( $_GET [ 'value' ]) . " ' WHERE `uid`=' " . $session -> userdata [ 'uid' ] . " ' " );
}
if ( $_GET [ 'call' ] == 'subm' ){
$result = $db -> query ( " UPDATE `ptc_users` SET `submit`=' " . $db -> escape ( $_GET [ 'value' ]) . " ' WHERE `uid`=' " . $session -> userdata [ 'uid' ] . " ' " );
}
}
}
?>