Cheetah
apiFunctions.inc.php
Go to the documentation of this file.
1 <?php
2 
16 {
17  $iNumArgs = func_num_args();
18  $sContent = $aXmlTemplates[$iNumArgs - 1];
19 
20  for($i=1; $i<$iNumArgs; $i++) {
21  $sValue = func_get_arg($i);
22  $sContent = str_replace("#" . $i. "#", $sValue, $sContent);
23  }
24  return $sContent;
25 }
26 
32 function makeGroup($sXmlContent, $sXmlGroup = "ray")
33 {
34  return "<" . $sXmlGroup . ">" . $sXmlContent . "</" . $sXmlGroup . ">";
35 }
36 
44 {
48 
49  //--- Read file ---//
50  $sWidgetFile = $sWidget . "/xml/" . $sFile . ".xml";
51  $sFileName = $sModulesPath . $sWidgetFile;
52  if(!file_exists($sFileName)) return parseXml($aXmlTemplates['result'], getError($aErrorCodes[1], $sWidgetFile), FAILED_VAL);
53  $sConfigContents = "";
54  if(($rHandle = @fopen($sFileName, "rt")) !== false && filesize($sFileName) > 0) {
55  $sConfigContents = fread($rHandle, filesize($sFileName)) ;
56  fclose($rHandle);
57  }
58 
59  //--- Update info ---//
60  if(is_array($sSettingKey) && is_array($sSettingValue)) {
61  for($i=0; $i<count($sSettingKey); $i++)
62  $sConfigContents = xmlSetValue($sConfigContents, "item", $sSettingKey[$i], $sSettingValue[$i]);
63  } else
64  $sConfigContents = xmlSetValue($sConfigContents, "item", $sSettingKey, $sSettingValue);
65 
66  //--- Save changes in the file---//
67  $bResult = true;
68  if(($rHandle = @fopen($sFileName, "wt")) !== false) {
69  $bResult = (fwrite($rHandle, $sConfigContents) !== false);
70  fclose($rHandle);
71  }
72  $sValue = $bResult && $rHandle ? "" : getError($aErrorCodes[2], $sWidgetFile);
73 
74  return array('value' => $sValue, 'status' => $bResult ? SUCCESS_VAL : FAILED_VAL);
75 }
76 
82 function getSettingValue($sWidget, $sSettingKey, $sFile = "config", $bFullReturn = false, $sFolder = "xml")
83 {
86 
87  //--- Read file ---//
88  $sWidgetFile = $sWidget . "/" . $sFolder . "/" . $sFile . ".xml";
89  $sFileName = $sModulesPath . $sWidgetFile;
90  if(!file_exists($sFileName)) {
91  if($bFullReturn) return array('value' => getError($aErrorCodes[1], $sWidgetFile), 'status' => FAILED_VAL);
92  else return "";
93  }
94  $sConfigContents = makeGroup("", "items");
95  if(($rHandle = @fopen($sFileName, "rt")) !== false && filesize($sFileName) > 0) {
96  $sConfigContents = fread($rHandle, filesize($sFileName));
97  fclose($rHandle);
98  }
99 
100  //--- Update info ---//
101  $sValue = xmlGetValue($sConfigContents, "item", $sSettingKey);
102  if($bFullReturn) return array('value' => $sValue, 'status' => SUCCESS_VAL);
103  else return $sValue;
104 }
105 
106 function getWMode()
107 {
108  return getSettingValue(GLOBAL_MODULE, "opaqueMode") == TRUE_VAL ? "opaque" : "window";
109 }
110 
116 function getRMSUrl($sApplication, $bHttp = false)
117 {
118  $sRMSProtocol = $bHttp ? "http://" : "rtmp://";
119  $sRMSPort = getSettingValue(GLOBAL_MODULE, $bHttp ? "RMSHttpPort" : "RMSPort");
120  $sRMSPort = empty($sRMSPort) ? "" : ":" . $sRMSPort;
121  $sRMSUrl = $sRMSProtocol . getSettingValue(GLOBAL_MODULE, "RMSIP") . $sRMSPort . "/" . $sApplication . "/";
122  return $sRMSUrl;
123 }
124 
129 function useServer()
130 {
131  $sUseServer = getSettingValue(GLOBAL_MODULE, "useRMS");
132  return $sUseServer == TRUE_VAL;
133 }
134 
141 function getOnline($aRange = array(), $bInRange = true)
142 {
143  require_once(CH_DIRECTORY_PATH_INC . "db.inc.php");
144  $iMin = (int)getParam("member_online_time");
145 
146  $sInRange = $bInRange ? "IN" : "NOT IN";
147  $sWhere = " WHERE `UserStatus`!='" . USER_STATUS_OFFLINE . "' AND `DateLastNav`>SUBDATE(NOW(), INTERVAL " . $iMin . " MINUTE) ";
148  if(isset($aRange) && count($aRange) > 0)
149  $sQuery = "SELECT `ID` FROM `Profiles`" . $sWhere . "AND `ID` " . $sInRange . " (" . implode(",", $aRange) . ") ORDER BY `ID`";
150  else $sQuery = "SELECT `ID` FROM `Profiles`" . $sWhere . "ORDER BY `ID`";
151 
152  $rOnline = getResult($sQuery);
153  $aOnline = array();
154  while($aUser = $rOnline->fetch())
155  $aOnline[] = $aUser['ID'];
156  return $aOnline;
157 }
158 
168 function getExtraFiles($sModule, $sFolder = "langs", $bGetUserFile = true, $bGetDate = false)
169 {
171 
172  $sFilesPath = $sModulesPath . $sModule . "/" . $sFolder . "/";
173  $aFiles = Array();
174  $aDates = Array();
175  $sExtension = getFileExtension($sModule, $sFolder);
176 
177  if($bGetDate) clearstatcache();
178 
179  if($sFolder == "langs")
180  $sSysLang = getCurrentLangName(false);
181  else
182  {
183  $aResult = getSettingValue($sModule, FILE_DEFAULT_KEY, $sFolder, true);
184  if($aResult['status'] == FAILED_VAL || empty($aResult['value'])) $sDefaultFile = ($sFolder == "langs") ? "english" : "default";
185  else $sDefaultFile = $aResult['value'];
186  }
187 
188  if($rDirHandle = opendir($sFilesPath))
189  while (false !== ($sFile = readdir($rDirHandle)))
190  if(is_file($sFilesPath . $sFile) && $sFile != "." && $sFile != ".." && $sExtension == substr($sFile, strpos($sFile, ".") + 1)) {
191  $aFiles[] = substr($sFile, 0, strpos($sFile, "."));
192  if($bGetDate) $aDates[] = filectime($sFilesPath . $sFile);
193  if($sFolder == "langs" && $sSysLang == substr($sFile, 0, 2))
194  $sDefaultFile = substr($sFile, 0, strpos($sFile, "."));
195  }
196  closedir($rDirHandle);
197 
198  $sCurrentFile = (in_array($sDefaultFile, $aFiles)) ? $sDefaultFile : $aFiles[0];
199  if($bGetUserFile) {
200  $sCookieValue = $_COOKIE["ray_" . $sFolder . "_" . $sModule];
201  $sCurrentFile = (isset($sCookieValue) && in_array($sCookieValue, $aFiles)) ? $sCookieValue : $sCurrentFile;
202  }
203  return array('files' => $aFiles, 'dates' => $aDates, 'current' => $sCurrentFile, 'extension' => $sExtension);
204 }
205 
212 function setCurrentFile($sModule, $sFile, $sFolder = "langs")
213 {
214  setCookie("ray_" . $sFolder . "_" . $sModule, $sFile, time() + 31536000);
215 }
216 
224 function printFiles($sModule, $sFolder = "langs", $bGetDate = false, $bGetNames = false)
225 {
228  require_once($sIncPath . "xmlTemplates.inc.php");
229 
230  $aFileContents = getFileContents($sModule, "/xml/" . $sFolder . ".xml", true);
231  $aFiles = $aFileContents['contents'];
232  $aEnabledFiles = array();
233  foreach($aFiles as $sFile => $sEnabled)
234  if($sEnabled == TRUE_VAL)
235  $aEnabledFiles[] = $sFile;
236  $sDefault = $aFiles['_default_'];
237 
238  $aResult = getExtraFiles($sModule, $sFolder, true, $bGetDate);
239  $sCurrent = $aResult['current'];
240  $sCurrent = in_array($sCurrent, $aEnabledFiles) ? $sCurrent : $sDefault;
241  $sCurrentFile = $sCurrent . "." . $aResult['extension'];
242 
243  $aRealFiles = array_flip($aResult['files']);
244  $aFileDates = $aResult['dates'];
245  $sContents = "";
246 
247  for($i=0; $i<count($aEnabledFiles); $i++)
248  if(isset($aRealFiles[$aEnabledFiles[$i]])) {
249  $sFile = $aEnabledFiles[$i];
250  if($bGetDate) $sContents .= parseXml($aXmlTemplates['file'], $sFile, $aFileDates[$aRealFiles[$sFile]]);
251  else {
252  if($bGetNames) {
253  $sName = $sFolder == "langs"
254  ? getSettingValue($sModule, "_name_", $sFile, false, "langs")
255  : getSettingValue($sModule, $sFile, "skinsNames");
256  if(empty($sName)) $sName = $sFile;
257  $sContents .= parseXml($aXmlTemplates['file'], $sFile, $sName, "");
258  } else $sContents .= parseXml($aXmlTemplates['file'], $sFile);
259  }
260  }
261 
262  $sContents = makeGroup($sContents, "files");
263  $sContents .= parseXml($aXmlTemplates['current'], $sCurrent, $sModulesUrl . $sModule . "/" . $sFolder . "/" . $sCurrentFile);
264 
265  return $sContents;
266 }
267 
268 function moveMp4Meta($sFilePath)
269 {
270  require_once(CH_DIRECTORY_PATH_PLUGINS . 'moovrelocator/lib/Moovrelocator.class.php');
271 
272  $oMoovrelocator = new Moovrelocator();
273 
274  $mixedRet = $oMoovrelocator->relocateMoovAtom ($sFilePath, null, true);
275  if ($mixedRet !== true)
276  return false;
277 
278  return true;
279 }
getFileExtension
getFileExtension($sWidget, $sFolder)
Definition: functions.inc.php:286
getCurrentLangName
if(!defined('CH_SKIP_INSTALL_CHECK')) getCurrentLangName($isSetCookie=true)
Definition: languages.inc.php:36
getFileContents
getFileContents($sWidget, $sFile, $bArray=false)
Definition: functions.inc.php:264
$sIncPath
$sIncPath
Definition: header.inc.php:64
$aResult
$aResult
Definition: index.php:19
$sModulesUrl
$sModulesUrl
Definition: header.inc.php:52
php
$sModule
if(!file_exists($sRayHeaderPath)) $sModule
Definition: index.php:14
setCurrentFile
setCurrentFile($sModule, $sFile, $sFolder="langs")
Definition: apiFunctions.inc.php:212
getExtraFiles
getExtraFiles($sModule, $sFolder="langs", $bGetUserFile=true, $bGetDate=false)
Definition: apiFunctions.inc.php:168
getError
getError($sError)
Definition: functions.inc.php:18
$sModulesPath
$sModulesPath
Definition: header.inc.php:53
$sWidget
$sWidget
Definition: actions.inc.php:18
$sFile
$sFile
Definition: index.php:20
getRMSUrl
getRMSUrl($sApplication, $bHttp=false)
Definition: apiFunctions.inc.php:116
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
xmlSetValue
xmlSetValue($sXmlContent, $sXmlTagName, $sName, $sValue)
Definition: xml.inc.php:204
$sFolder
$sFolder
Definition: index.php:15
getWMode
getWMode()
Definition: apiFunctions.inc.php:106
xmlGetValue
xmlGetValue($sXmlContent, $sXmlTagName, $sName)
Definition: xml.inc.php:193
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
$bResult
$bResult
Definition: get_file.php:11
$sContent
$sContent
Definition: bottom_menu_compose.php:169
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
$sSettingValue
$sSettingValue
Definition: actions.inc.php:31
$sDefaultFile
$sDefaultFile
Definition: actions.inc.php:24
$aErrorCodes
$aErrorCodes
Definition: constants.inc.php:26
parseXml
parseXml($aXmlTemplates)
Definition: apiFunctions.inc.php:15
useServer
useServer()
Definition: apiFunctions.inc.php:129
makeGroup
makeGroup($sXmlContent, $sXmlGroup="ray")
Definition: apiFunctions.inc.php:32
$aUser
$aUser
Definition: profiles.inc.php:74
$aXmlTemplates
$aXmlTemplates
Definition: xmlTemplates.inc.php:8
moveMp4Meta
moveMp4Meta($sFilePath)
Definition: apiFunctions.inc.php:268
getSettingValue
getSettingValue($sWidget, $sSettingKey, $sFile="config", $bFullReturn=false, $sFolder="xml")
Definition: apiFunctions.inc.php:82
Moovrelocator
Definition: Moovrelocator.class.php:104
$sFilesPath
$sFilesPath
Definition: header.inc.php:10
$sContents
$sContents
Definition: XML.php:38
setSettingValue
setSettingValue($sWidget, $sSettingKey, $sSettingValue, $sFile="config")
Definition: apiFunctions.inc.php:43
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$sName
$sName
Definition: ChWsbAdminTools.php:853
$sSettingKey
$sSettingKey
Definition: actions.inc.php:29
getOnline
getOnline($aRange=array(), $bInRange=true)
Definition: apiFunctions.inc.php:141
printFiles
printFiles($sModule, $sFolder="langs", $bGetDate=false, $bGetNames=false)
Definition: apiFunctions.inc.php:224
getResult
getResult($sQuery)
Definition: db.inc.php:45