34 if(is_dir($sPluginsPath)) {
36 while(
false !== ($sPlugin = readdir($rDirHandle)))
37 if(strpos($sPlugin,
".swf") === strlen($sPlugin)-4)
39 closedir($rDirHandle);
77 $rHandle = fopen($sFileName,
"rt");
78 $sContents = fread($rHandle, filesize($sFileName)) ;
82 $iMaxFileSize = min((ini_get(
'upload_max_filesize') + 0), (ini_get(
'post_max_size') + 0), $iFileSize);
97 if(
empty($sKey) || $sValue ==
"")
break;
98 setCookie(
"RayzFont" . $sKey, $sValue,
time() + 31536000);
103 8 =>
'<settings bold="#1#" italic="#2#" underline="#3#" color="#4#" font="#5#" size="#6#" volume="#7#" muted="#8#" />'
105 $sContents =
parseXml($aSettings, $_COOKIE[
"RayzFontbold"], $_COOKIE[
"RayzFontitalic"], $_COOKIE[
"RayzFontunderline"], $_COOKIE[
"RayzFontcolor"], $_COOKIE[
"RayzFontfont"], $_COOKIE[
"RayzFontsize"], $_COOKIE[
"RayzFontvolume"], $_COOKIE[
"RayzFontmuted"]);
108 case 'RzGetBlockingUsers':
111 case 'RzGetBlockedUsers':
112 if(!isset($bBlocking))
124 case 'RayzGetMemberships':
135 case 'RayzSetMembershipSetting':
138 $aKeys =
getArray(
"SELECT `keys`.`ID` AS `KeyID`, `values`.`ID` AS `ValueID` FROM `" . MODULE_DB_PREFIX .
"MembershipsSettings` AS `keys` LEFT JOIN `" . MODULE_DB_PREFIX .
"Memberships` AS `values` ON `keys`.`ID`=`values`.`Setting` AND `values`.`Membership`='" .
$sId .
"' WHERE `keys`.`Name`='" . $sKey .
"' LIMIT 1");
139 if(
empty($aKeys[
'KeyID'])) {
142 }
else if(
empty($aKeys[
'ValueID']))
143 getResult(
"INSERT INTO `" . MODULE_DB_PREFIX .
"Memberships` (`Setting`, `Value`, `Membership`) VALUES('" . $aKeys[
'KeyID'] .
"', '" . $sValue .
"', '" .
$sId .
"')");
145 getResult(
"UPDATE `" . MODULE_DB_PREFIX .
"Memberships` SET `Value`='" . $sValue .
"' WHERE `ID`='" . $aKeys[
'ValueID'] .
"'");
148 case 'RayzGetMembership':
156 if(!
empty($sUserId)) {
161 getResult(
"DELETE FROM `" . MODULE_DB_PREFIX .
"Profiles` WHERE `ID`='" .
$sId .
"'");
162 getResult(
"INSERT INTO `" . MODULE_DB_PREFIX .
"Profiles` SET `ID`='" .
$sId .
"', `Type`='" . CHAT_TYPE_FULL .
"', `Smileset`='" .
$sDefSmileset .
"'");
164 $iCurrentTime =
time();
168 getResult(
"REPLACE `" . MODULE_DB_PREFIX .
"CurrentUsers` SET `ID`='" .
$sId .
"', `Nick`='" .
$sNick .
"', `Sex`='" .
$sSex .
"', `Age`='" .
$sAge .
"', `Desc`='" .
$sDesc .
"', `Photo`='" . $sPhoto .
"', `Profile`='" .
$sProfileUrl .
"', `Start`='" . $iCurrentTime .
"', `When`='" . $iCurrentTime .
"', `Status`='" . USER_STATUS_NEW .
"'");
169 getResult(
"DELETE FROM `" . MODULE_DB_PREFIX .
"RoomsUsers` WHERE `User`='" .
$sId .
"'");
178 case 'userAuthorize':
181 $aUser = array(
'id' => $aUserInfo[
'id'],
'nick' => $aUserInfo[
'nick'],
'sex' => $aUserInfo[
'sex'],
'age' => $aUserInfo[
'age'],
'desc' => $aUserInfo[
'desc'],
'photo' => $aUserInfo[
'photo'],
'profile' => $aUserInfo[
'profile'],
'type' => CHAT_TYPE_ADMIN);
193 $sContents .=
parseXml(
$aXmlTemplates[
'user'],
$aUser[
'id'], USER_STATUS_NEW,
$aUser[
'nick'],
$aUser[
'sex'],
$aUser[
'age'],
$aUser[
'desc'],
$aUser[
'photo'],
$aUser[
'profile'],
$aUser[
'type'], USER_STATUS_ONLINE);
198 $sUserId =
getValue(
"SELECT `ID` FROM `" . MODULE_DB_PREFIX .
"Profiles` WHERE `ID` = '" .
$sId .
"' LIMIT 1");
200 ?
"INSERT INTO `" . MODULE_DB_PREFIX .
"Profiles`(`ID`, `Banned`) VALUES('" .
$sId .
"', '" . $sBanned .
"')"
201 :
"UPDATE `" . MODULE_DB_PREFIX .
"Profiles` SET `Banned`='" . $sBanned .
"' WHERE `ID`='" .
$sId .
"'");
205 getResult(
"UPDATE `" . MODULE_DB_PREFIX .
"CurrentUsers` SET `Status`='" . USER_STATUS_KICK .
"', `When`='" .
time() .
"' WHERE `ID`='" .
$sId .
"'");
208 case 'changeUserType':
209 $sUserId =
getValue(
"SELECT `ID` FROM `" . MODULE_DB_PREFIX .
"Profiles` WHERE `ID` = '" .
$sId .
"' LIMIT 1");
211 ?
"INSERT INTO `" . MODULE_DB_PREFIX .
"Profiles`(`ID`, `Type`) VALUES('" .
$sId .
"', '" .
$sType .
"')"
212 :
"UPDATE `" . MODULE_DB_PREFIX .
"Profiles` SET `Type`='" .
$sType .
"' WHERE `ID`='" .
$sId .
"'");
218 if(
empty($sUserId))
break;
222 $aProfile =
getArray(
"SELECT * FROM `" . MODULE_DB_PREFIX .
"Profiles` WHERE `ID` = '" . $sUserId .
"' LIMIT 1");
234 if(file_exists($sFileName)) {
235 $rHandle = fopen($sFileName,
"rt");
236 $sContents = fread($rHandle, filesize($sFileName));
245 $sConfigFile =
"config.xml";
247 $aSmilesets = array();
249 while(
false !== ($sDir = readdir($rDirHandle)))
251 $aSmilesets[] = $sDir;
252 closedir($rDirHandle);
253 if(count($aSmilesets) == 0)
break;
255 if(isset($_COOKIE[
"RayzFontsmileset"]))
259 $sUserSmileset =
getValue(
"SELECT `Smileset` FROM `" . MODULE_DB_PREFIX .
"Profiles` WHERE `ID`='" .
$sId .
"'");
264 for($i=0; $i<count($aSmilesets); $i++) {
275 getResult(
"UPDATE `" . MODULE_DB_PREFIX .
"Profiles` SET `Smileset`='" .
$sSmileset .
"' WHERE `ID`='" .
$sId .
"'");
318 case 'checkRoomPassword':
330 case 'getOnlineUsers':
332 $rResult =
getResult(
"SELECT `ID` FROM `" . MODULE_DB_PREFIX .
"CurrentUsers`");
333 if($rResult->rowCount() == 0)
getResult(
"TRUNCATE TABLE `" . MODULE_DB_PREFIX .
"CurrentUsers`");
334 $rResult =
getResult(
"SELECT `ID` FROM `" . MODULE_DB_PREFIX .
"Messages`");
335 if($rResult->rowCount() == 0)
getResult(
"TRUNCATE TABLE `" . MODULE_DB_PREFIX .
"Messages`");
344 getResult(
"UPDATE `" . MODULE_DB_PREFIX .
"CurrentUsers` SET `Online`='" .
$sOnline .
"', `When`='" .
time() .
"', `Status`='" . USER_STATUS_ONLINE .
"' WHERE `ID`='" .
$sId .
"'");
353 $res =
getResult(
"SELECT * FROM `" . MODULE_DB_PREFIX .
"Messages` WHERE `Type`='file' AND `Recipient`='" .
$sId .
"'");
354 while($aFile = $res->fetch()) {
355 $sFileName = $aFile[
'ID'] .
".file";
356 if(!file_exists(
$sFilesPath . $sFileName))
continue;
359 getResult(
"DELETE FROM `" . MODULE_DB_PREFIX .
"Messages` WHERE `Type`='file' AND `Recipient`='" .
$sId .
"'");
371 $sRooms =
getValue(
"SELECT GROUP_CONCAT(DISTINCT `Room` SEPARATOR ',') FROM `" . MODULE_DB_PREFIX .
"RoomsUsers` WHERE `User`='" .
$sId .
"' AND `Status`='" . ROOM_STATUS_NORMAL .
"'");
372 if(
empty($sRooms)) $sRooms =
"''";
373 $sSql =
"SELECT * FROM `" . MODULE_DB_PREFIX .
"Messages` WHERE `Type`='text' AND `Sender`<>'" .
$sId .
"' AND ((`Room` IN (" . $sRooms .
") AND `Whisper`='" . FALSE_VAL .
"') OR `Recipient`='" .
$sId .
"') AND `When`>='" . (
time() - $iUpdateInterval) .
"' ORDER BY `ID`";
375 while($aMsg = $res->fetch()) {
376 $aStyle = unserialize($aMsg[
'Style']);
377 $sMsgs .=
parseXml(
$aXmlTemplates[
'message'], $aMsg[
'ID'], stripslashes($aMsg[
'Message']), $aMsg[
'Room'], $aMsg[
'Sender'], $aMsg[
'Recipient'], $aMsg[
'Whisper'], $aStyle[
'color'], $aStyle[
'bold'], $aStyle[
'underline'], $aStyle[
'italic'], $aStyle[
'size'], $aStyle[
'font'], $aStyle[
'smileset'], $aMsg[
'When']);
397 $sStyle = serialize(array(
'color' => $sColor,
'bold' => $sBold,
'underline' => $sUnderline,
'italic' => $sItalic,
'smileset' =>
$sSmileset,
'size' => $iSize,
'font' => $sFont));
398 getResult(
"INSERT INTO `" . MODULE_DB_PREFIX .
"Messages`(`Room`, `Sender`, `Recipient`, `Message`, `Whisper`, `Style`, `When`) VALUES('" .
$iRoomId .
"', '" .
$sSender .
"', '" .
$sRcp .
"', '" .
$sMessage .
"', '" . $sWhisper .
"', '" . $sStyle .
"', '" .
time() .
"')");
404 getResult(
"INSERT INTO `" . MODULE_DB_PREFIX .
"History`(`Room`, `SndRcp`, `Sender`, `Recipient`, `Message`, `When`) VALUES('" .
$iRoomId .
"', '" . $sSndRcp .
"', '" .
$sSender .
"', '" .
$sRcp .
"', '" .
$sMessage .
"', '" .
time() .
"')");
411 $iStartDate = mktime(0, 0, 0, $iMonth, $iDay, $iYear);
412 $iEndDate = mktime(0, 0, 0, $iMonth, ($iDay+1), $iYear);
413 $aMessages = array();
415 $rRes =
getResult(
"SELECT * FROM `" . MODULE_DB_PREFIX .
"History` WHERE `When`>=" . $iStartDate .
" AND `When`<" . $iEndDate .
" ORDER BY `Room`, `Sender`, `Recipient` ASC");
416 if($rRes->rowCount() == 0)
423 $iUsersCount = $rRes->rowCount();
424 for($i=0; $i<$iUsersCount; $i++)
426 $aMsg = $rRes->fetch();
427 $aMessages[] = $aMsg;
428 if(!
empty($aMsg[
'Sender']))
429 $aUsers[] = $aMsg[
'Sender'];
430 if(!
empty($aMsg[
'Recipient']))
431 $aUsers[] = $aMsg[
'Recipient'];
434 $aUsers = array_flip(array_unique($aUsers));
435 foreach($aUsers
as $iUserId => $sValue)
443 $rResRooms =
getResult(
"SELECT `history`.*, `rooms`.`Name` AS `Title` FROM `" . MODULE_DB_PREFIX .
"History` AS `history` INNER JOIN `" . MODULE_DB_PREFIX .
"Rooms` AS `rooms` ON `history`.`Room`=`rooms`.`ID` WHERE `history`.`Room`>0 AND `history`.`When`>=" . $iStartDate .
" AND `history`.`When`<" . $iEndDate .
" ORDER BY `Room`, `When` ASC");
449 $iRoomsCount = $rResRooms->rowCount();
450 for($i=0; $i<$iRoomsCount; $i++)
452 $aMsg = $rResRooms->fetch();
453 if($aMsg[
'Room'] != $iRoom)
461 $iRoom = $aMsg[
'Room'];
465 $sMsgs .=
parseXml(
$aXmlTemplates[
'history'][
'msg'], $aMsg[
'ID'], $aMsg[
'Sender'], $aMsg[
'Recipient'], $aMsg[
'Message']);
472 $rResMsgs =
getResult(
"SELECT * FROM `" . MODULE_DB_PREFIX .
"History` WHERE `Room`=0 AND `When`>=" . $iStartDate .
" AND `When`<" . $iEndDate .
" ORDER BY `SndRcp`, `When` ASC");
477 $iMsgsCount = $rResMsgs->rowCount();
478 for($i=0; $i<$iMsgsCount; $i++)
480 $aMsg = $rResMsgs->fetch();
481 if($aMsg[
'SndRcp'] != $sSndRcp)
485 $sPrivate .=
parseXml(
$aXmlTemplates[
'history'][
'private'], $aMsg[
'Sender'], $aMsg[
'Recipient'], $iCount) . $sMsgs .
"</private>";
489 $sSndRcp = $aMsg[
'SndRcp'];
495 $sPrivate .=
parseXml(
$aXmlTemplates[
'history'][
'private'], $aMsg[
'Sender'], $aMsg[
'Recipient'], $iCount) . $sMsgs .
"</private>";
501 if(is_uploaded_file($_FILES[
'Filedata'][
'tmp_name'])) {
504 move_uploaded_file($_FILES[
'Filedata'][
'tmp_name'], $sFilePath);
505 @chmod($sFilePath, 0644);
512 if(
empty(
$sSender) || !file_exists($sFilePath) || filesize($sFilePath) == 0)
break;
514 getResult(
"INSERT INTO `" . MODULE_DB_PREFIX .
"Messages`(`Sender`, `Recipient`, `Message`, `Type`, `When`) VALUES('" .
$sSender .
"', '" .
$sRcp .
"', '" .
$sMessage .
"', 'file', '" .
time() .
"')");
516 if(!@rename($sFilePath,
$sFilesPath . $sFileName))
break;
522 $sId = str_replace(
".file",
"",
$sId);
530 if(file_exists($sFileName)) {
531 $rHandle = @fopen($sFileName,
"rt");
532 $sContents = @fread($rHandle, filesize($sFileName)) ;