Cheetah
actions.inc.php
Go to the documentation of this file.
1 <?php
2 
8 $sId = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
9 $sNick = isset($_REQUEST['nick']) ? process_db_input($_REQUEST['nick']) : "";
10 $sPassword = isset($_REQUEST['password']) ? process_db_input($_REQUEST['password']) : "";
11 
12 $iBoardId = isset($_REQUEST['boardId']) ? (int)$_REQUEST['boardId'] : 0;
13 $sTitle = isset($_REQUEST['title']) ? process_db_input(rawurldecode($_REQUEST['title']), CH_TAGS_SPECIAL_CHARS) : "";
14 
15 $sParamName = isset($_REQUEST['param']) ? process_db_input($_REQUEST['param']) : "";
16 $sParamValue = isset($_REQUEST['value']) ? process_db_input($_REQUEST['value']) : "";
17 
18 $sSkin = isset($_REQUEST['skin']) ? process_db_input($_REQUEST['skin']) : "default";
19 $sLanguage = isset($_REQUEST['language']) ? process_db_input($_REQUEST['language']) : "english";
20 
21 switch ($sAction) {
22  case 'getPlugins':
23  $sFolder = "/plugins/";
24  $sContents = "";
25  $sFolderPath = $sModulesPath . $sModule . $sFolder;
26  if(file_exists($sFolderPath) && is_dir($sFolderPath)) {
27  if($rDirHandle = opendir($sModulesPath . $sModule . $sFolder))
28  while(false !== ($sPlugin = readdir($rDirHandle)))
29  if(strpos($sPlugin, ".swf") === strlen($sPlugin)-4)
30  $sContents .= parseXml(array(1 => '<plugin><![CDATA[#1#]]></plugin>'), $sModulesUrl . $sModule . $sFolder . $sPlugin);
31  closedir($rDirHandle);
32  }
33  $sContents = makeGroup($sContents, "plugins");
34  break;
35 
39  case 'getSkins':
40  $sContents = printFiles($sModule, "skins", false, true);
41  break;
42 
46  case 'setSkin':
47  setCurrentFile($sModule, $sSkin, "skins");
48  break;
49 
53  case 'getLanguages':
54  $sContents = printFiles($sModule, "langs", false, true);
55  break;
56 
60  case 'setLanguage':
62  break;
63 
67  case 'config':
68  $sFileName = $sModulesPath . $sModule . "/xml/config.xml";
69  $rHandle = fopen($sFileName, "rt");
70  $sContents = fread($rHandle, filesize($sFileName)) ;
71  fclose($rHandle);
72 
73  $sContents = str_replace("#soundsUrl#", $sSoundsUrl, $sContents);
74  $sContents = str_replace("#filesUrl#", $sFilesUrl, $sContents);
75  $sContents = str_replace("#useServer#", useServer() ? TRUE_VAL : FALSE_VAL, $sContents);
76  $sContents = str_replace("#serverUrl#", getRMSUrl($sServerApp), $sContents);
77  break;
78 
82  case 'userAuthorize':
83  if(loginUser($sId, $sPassword) == TRUE_VAL) {
84  $iCurrentTime = time();
86  $aUser['sex'] = $aUser['sex'] == 'female' ? "F" : "M";
87  getResult("REPLACE `" . MODULE_DB_PREFIX . "CurrentUsers` SET `ID`='" . $sId . "', `Nick`='" . process_db_input($aUser['nick']) . "', `Sex`='" . $aUser['sex'] . "', `Age`='" . $aUser['age'] . "', `Photo`='" . process_db_input($aUser['photo']) . "', `Profile`='" . process_db_input($aUser['profile']) . "', `Desc`='" . process_db_input($aUser['desc']) . "', `When`='" . $iCurrentTime . "', `Status`='" . USER_STATUS_NEW . "'");
88  getResult("DELETE FROM `" . MODULE_DB_PREFIX . "Users` WHERE `User`='" . $sId . "'");
89 
90  $rFiles = getResult("SELECT `ID` FROM `" . MODULE_DB_PREFIX . "Boards` WHERE `OwnerID`='" . $sId . "'");
91  while($aFile = $rFiles->fetch()) @unlink($sFilesPath . $aFile['ID'] . $sFileExtension);
92  getResult("DELETE FROM `" . MODULE_DB_PREFIX . "Boards`, `" . MODULE_DB_PREFIX . "Users` USING `" . MODULE_DB_PREFIX . "Boards` LEFT JOIN `" . MODULE_DB_PREFIX . "Users` ON `" . MODULE_DB_PREFIX . "Boards`.`ID`=`" . MODULE_DB_PREFIX . "Users`.`Board` WHERE `" . MODULE_DB_PREFIX . "Boards`.`OwnerID`='" . $sId . "'");
93 
94  $sContents = parseXml($aXmlTemplates['result'], "", SUCCESS_VAL);
95  $sContents .= parseXml($aXmlTemplates['user'], $sId, USER_STATUS_NEW, $aUser['nick'], $aUser['sex'], $aUser['age'], $aUser['photo'], $aUser['profile'], $aUser['desc']);
96  } else $sContents = parseXml($aXmlTemplates['result'], "msgUserAuthenticationFailure", FAILED_VAL);
97  break;
98 
102  case 'getSounds':
103  $sFileName = $sModulesPath . $sModule . "/xml/sounds.xml";
104  if(file_exists($sFileName)) {
105  $rHandle = fopen($sFileName, "rt");
106  $sContents = fread($rHandle, filesize($sFileName));
107  fclose($rHandle);
108  } else $sContents = makeGroup("", "items");
109  break;
110 
114  case 'getBoards':
115  $sContents = makeGroup(getBoards("all", $sId), "boards");
116  break;
117 
118  case 'createBoard':
119  $iBoardId = doBoard('insert', $sId, 0, $sTitle, $sPassword);
120  if(empty($iBoardId))$sContents = parseXml($aXmlTemplates['result'], "msgErrorCreatingBoard", FAILED_VAL);
121  else $sContents = parseXml($aXmlTemplates['result'], $iBoardId, SUCCESS_VAL);
122  break;
123 
124  case 'editBoard':
125  doBoard('update', 0, $iBoardId, $sTitle, $sPassword);
126  $sContents = parseXml($aXmlTemplates['result'], "", SUCCESS_VAL);
127  break;
128 
133  case 'deleteBoard':
134  doBoard('delete', 0, $iBoardId);
135  $sContents = parseXml($aXmlTemplates['result'], TRUE_VAL);
136  break;
137 
138  case 'enterBoard':
139  doBoard('enter', $sId, $iBoardId);
140  break;
141 
142  case 'exitBoard':
143  doBoard('exit', $sId, $iBoardId);
144  @unlink($sFilesPath . $sId . $sFileExtension);
145  break;
146 
147  case 'checkBoardPassword':
148  $sId = getValue("SELECT `ID` FROM `" . MODULE_DB_PREFIX . "Boards` WHERE `ID`='" . $iBoardId . "' AND `Password`='" . $sPassword . "' LIMIT 1");
149  if(empty($sId)) $sContents = parseXml($aXmlTemplates['result'], "msgWrongRoomPassword", FAILED_VAL);
150  else $sContents = parseXml($aXmlTemplates['result'], "", SUCCESS_VAL);
151  break;
152 
153  case 'getOnlineUsers':
154  //--- Check RayChatMessages table and drop autoincrement if it is possible. ---//
155  $rResult = getResult("SELECT `ID` FROM `" . MODULE_DB_PREFIX . "CurrentUsers`");
156  if($rResult->rowCount() == 0) getResult("TRUNCATE TABLE `" . MODULE_DB_PREFIX . "CurrentUsers`");
157  //--- Update user's info and return info about all online users. ---//
159  break;
160 
161  case 'update':
162  $sContents = "";
163  //--- update user's info ---//
164  $sContents .= refreshUsersInfo($sId, 'update');
165  //--- check for new rooms ---//
166  $sContents .= makeGroup(getBoards('update', $sId), "boards");
167  $sContents .= makeGroup(getBoards('updateUsers', $sId), "boardsUsers");
168  break;
169 
177  case 'transmit':
178  if(!function_exists("imagecreatetruecolor")) {
179  $sContents = parseXml($aXmlTemplates['result'], 'msgErrorGD', FAILED_VAL);
180  break;
181  }
182 
183  //--- Prepare data ---//
184  $bSaveMode = isset($_REQUEST['save']) && $_REQUEST['save'] == TRUE_VAL;
185  $sSavedId = isset($_REQUEST['savedId']) ? (int)$_REQUEST['savedId'] : 0;
186  $iWidth = isset($_REQUEST['width']) ? (int)$_REQUEST['width'] : 0;
187  $iHeight = isset($_REQUEST['height']) ? (int)$_REQUEST['height'] : 0;
188  $iBackColor = isset($_REQUEST['backColor']) && is_numeric($_REQUEST['backColor']) ? (int)$_REQUEST['backColor'] : 16777216;
189  $sData = isset($_REQUEST['data']) ? process_db_input($_REQUEST['data'], CH_TAGS_STRIP) : "";
190  $iQuality = 100;
191 
192  $aData = explode(',', $sData);
193  $aImageData = array();
194  for($i=0; $i<count($aData); $i++) {
195  $aPixel = explode("=", $aData[$i], 2);
196  $aImageData[$aPixel[0]] = base_convert($aPixel[1], 36, 10);
197  }
198 
199  //--- Create Image Resource ---//
200  $rImage = @imagecreatetruecolor($iWidth, $iHeight);
201  for($i=0, $y=0; $y<$iHeight; $y++)
202  for($x=0; $x<$iWidth; $x++, $i++)
203  @imagesetpixel ($rImage, $x, $y, isset($aImageData[$i]) ? $aImageData[$i] : $iBackColor);
204 
205  //--- Save image file ---//
206  $sFileName = $sFilesPath . $iBoardId . $sFileExtension;
207  $bFileCreated = @imagejpeg($rImage, $sFileName, $iQuality);
208  $aResult = $bFileCreated
209  ? array('status' => SUCCESS_VAL, 'value' => "")
210  : array('status' => FAILED_VAL, 'value' => "msgErrorFile");
211  if($bFileCreated && $bSaveMode) {
212  $aResult = save($sSavedId, $sFileName, $sTitle);
213  if(useServer()) @unlink($sFileName);
214  }
215 
216  $sContents = parseXml($aXmlTemplates['result'], $aResult['value'], $aResult['status']);
217  break;
218 
219  case 'getSaved':
220  if(loginUser($sId, $sPassword) == TRUE_VAL)
222  else
223  $sContents = parseXml($aXmlTemplates['result'], "msgUserAuthenticationFailure", FAILED_VAL);
224  break;
225 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
getSavedBoardInfo
getSavedBoardInfo($sId, $iBoardId)
Definition: customFunctions.inc.php:49
$sSoundsUrl
$sSoundsUrl
Definition: header.inc.php:12
refreshUsersInfo
refreshUsersInfo($sId="", $sMode='all')
Definition: functions.inc.php:126
$sFilesUrl
$sFilesUrl
Definition: header.inc.php:11
$aResult
$aResult
Definition: index.php:19
$sModulesUrl
$sModulesUrl
Definition: header.inc.php:52
php
getBoards
getBoards($sMode='new', $sId="")
Definition: functions.inc.php:12
getValue
getValue($sQuery)
Definition: db.inc.php:59
$sModule
if(!file_exists($sRayHeaderPath)) $sModule
Definition: index.php:14
setCurrentFile
setCurrentFile($sModule, $sFile, $sFolder="langs")
Definition: apiFunctions.inc.php:212
$sParamValue
$sParamValue
Definition: actions.inc.php:16
save
save($sSavedId, $sFilePath, $sTitle)
Definition: customFunctions.inc.php:18
$sModulesPath
$sModulesPath
Definition: header.inc.php:53
$sLanguage
$sLanguage
Definition: actions.inc.php:19
doBoard
doBoard($sSwitch, $sUserId="", $iBoardId=0, $sTitle="", $sPassword="")
Definition: functions.inc.php:88
$sPassword
$sPassword
Definition: actions.inc.php:10
$iBoardId
$iBoardId
Definition: actions.inc.php:12
getRMSUrl
getRMSUrl($sApplication, $bHttp=false)
Definition: apiFunctions.inc.php:116
$sParamName
$sParamName
Definition: actions.inc.php:15
$sTitle
$sTitle
Definition: actions.inc.php:13
$sFolder
$sFolder
Definition: index.php:15
$_REQUEST
$_REQUEST['action']
Definition: cmd.php:11
$sFileExtension
$sFileExtension
Definition: header.inc.php:9
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
parseXml
parseXml($aXmlTemplates)
Definition: apiFunctions.inc.php:15
useServer
useServer()
Definition: apiFunctions.inc.php:129
$sServerApp
$sServerApp
Definition: header.inc.php:8
CH_TAGS_SPECIAL_CHARS
const CH_TAGS_SPECIAL_CHARS
Definition: utils.inc.php:23
makeGroup
makeGroup($sXmlContent, $sXmlGroup="ray")
Definition: apiFunctions.inc.php:32
$aUser
$aUser
Definition: profiles.inc.php:74
$aXmlTemplates
$aXmlTemplates
Definition: xmlTemplates.inc.php:8
$sId
$sId
Definition: actions.inc.php:8
$sSkin
$sSkin
Definition: actions.inc.php:18
$sFilesPath
$sFilesPath
Definition: header.inc.php:10
getUserInfo
$f getUserInfo
Definition: callback.php:18
$sContents
$sContents
Definition: XML.php:38
$sAction
$sAction
Definition: categories.php:274
$sNick
$sNick
Definition: actions.inc.php:9
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
loginUser
loginUser($sName, $sPassword, $bLogin=false)
Definition: customFunctions.inc.php:19
printFiles
printFiles($sModule, $sFolder="langs", $bGetDate=false, $bGetNames=false)
Definition: apiFunctions.inc.php:224
getResult
getResult($sQuery)
Definition: db.inc.php:45