PageRenderTime 57ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/freetrix/modules/fileman/classes/general/sticker.php

https://github.com/ivanbogomoloff/open_bx
PHP | 1712 lines | 1473 code | 227 blank | 12 comment | 260 complexity | 6734a31c08580b8af4c6ce01d4e29ab5 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?
  2. IncludeModuleLangFile(__FILE__);
  3. class CSticker
  4. {
  5. static $oParser = null;
  6. static $Params = null;
  7. function GetOperations()
  8. {
  9. global $USER;
  10. static $arOp;
  11. static $arUsers;
  12. $userGroups = $USER->GetUserGroupArray();
  13. $key = implode('-', $userGroups);
  14. if (!is_array($arOp))
  15. $arOp = array();
  16. if (!is_array($arOp[$key]))
  17. {
  18. $res = CSticker::GetAccessPermissions();
  19. $arOp[$key] = array();
  20. $bDefaultTask = false;
  21. $count = 0;
  22. foreach ($res as $group_id => $task_id)
  23. if (in_array($group_id, $userGroups))
  24. {
  25. $arOp[$key] = array_merge($arOp[$key], CTask::GetOperations($task_id, true));
  26. $count++;
  27. }
  28. if ($count < count($userGroups))
  29. {
  30. $defaultAccess = COption::GetOptionString('fileman', 'stickers_default_access', false);
  31. if ($defaultAccess !== false)
  32. $arOp[$key] = array_merge($arOp[$key], CTask::GetOperations($defaultAccess, true));
  33. }
  34. }
  35. return $arOp[$key];
  36. }
  37. function CanDoOperation($operation)
  38. {
  39. if ($GLOBALS["USER"]->IsAdmin())
  40. return true;
  41. $arOp = CSticker::GetOperations();
  42. return in_array($operation, $arOp);
  43. }
  44. function GetAccessPermissions()
  45. {
  46. global $DB;
  47. $strSql = 'SELECT * FROM b_sticker_group_task SGT';
  48. $res = $DB->Query($strSql , false, "File: ".__FILE__."<br>Line: ".__LINE__);
  49. $arResult = array();
  50. while($arRes = $res->Fetch())
  51. $arResult[intVal($arRes['GROUP_ID'])] = intVal($arRes['TASK_ID']);
  52. return $arResult;
  53. }
  54. function SaveAccessPermissions($arTaskPerm)
  55. {
  56. global $DB;
  57. $DB->Query("DELETE FROM b_sticker_group_task WHERE 1=1", false, "FILE: ".__FILE__."<br> LINE: ".__LINE__);
  58. foreach($arTaskPerm as $group_id => $task_id)
  59. {
  60. $arInsert = $DB->PrepareInsert("b_sticker_group_task", array("GROUP_ID" => $group_id, "TASK_ID" => $task_id));
  61. $strSql = "INSERT INTO b_sticker_group_task(".$arInsert[0].") VALUES(".$arInsert[1].")";
  62. $DB->Query($strSql , false, "File: ".__FILE__."<br>Line: ".__LINE__);
  63. }
  64. }
  65. function GetTasks()
  66. {
  67. IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"].FX_ROOT."/modules/fileman/admin/task_description.php");
  68. $arTasks = Array();
  69. $res = CTask::GetList(Array('LETTER' => 'asc'), Array('MODULE_ID' => 'fileman', 'BINDING' => 'stickers'));
  70. while($arRes = $res->Fetch())
  71. {
  72. $name = '';
  73. if ($arRes['SYS'])
  74. $name = GetMessage('TASK_NAME_'.strtoupper($arRes['NAME']));
  75. if (strlen($name) == 0)
  76. $name = $arRes['NAME'];
  77. $arTasks[$arRes['ID']] = Array('title' => $name, 'letter' => $arRes['LETTER']);
  78. }
  79. return $arTasks;
  80. }
  81. function GetList($Params = array())
  82. {
  83. if (!CSticker::CanDoOperation('sticker_view'))
  84. return false;
  85. global $DB, $USER;
  86. $bDBResult = isset($Params['bDBResult'])? $Params['bDBResult']: false;
  87. $arFilter = $Params['arFilter'];
  88. $arOrder = isset($Params['arOrder']) ? $Params['arOrder'] : Array('ID' => 'asc');
  89. // Cache
  90. $cachePath = "stickers/";
  91. $cacheTime = 36000000;
  92. $bCache = true;
  93. static $arFields = array(
  94. "ID" => Array("FIELD_NAME" => "ST.ID", "FIELD_TYPE" => "int"),
  95. "SITE_ID" => Array("FIELD_NAME" => "ST.SITE_ID", "FIELD_TYPE" => "string"),
  96. "PAGE_URL" => Array("FIELD_NAME" => "ST.PAGE_URL", "FIELD_TYPE" => "string"),
  97. "PAGE_TITLE" => Array("FIELD_NAME" => "ST.PAGE_TITLE", "FIELD_TYPE" => "string"),
  98. "DATE_CREATE" => Array("FIELD_NAME" => "ST.DATE_CREATE", "FIELD_TYPE" => "date"),
  99. "DATE_UPDATE" => Array("FIELD_NAME" => "ST.DATE_UPDATE", "FIELD_TYPE" => "date"),
  100. "MODIFIED_BY" => Array("FIELD_NAME" => "ST.MODIFIED_BY", "FIELD_TYPE" => "int"),
  101. "CREATED_BY" => Array("FIELD_NAME" => "ST.CREATED_BY", "FIELD_TYPE" => "int"),
  102. "PERSONAL" => Array("FIELD_NAME" => "ST.PERSONAL", "FIELD_TYPE" => "string"),
  103. "CONTENT" => Array("FIELD_NAME" => "ST.CONTENT ", "FIELD_TYPE" => "string"),
  104. "POS_TOP" => Array("FIELD_NAME" => "ST.POS_TOP", "FIELD_TYPE" => "int"),
  105. "POS_LEFT" => Array("FIELD_NAME" => "ST.POS_LEFT", "FIELD_TYPE" => "int"),
  106. "WIDTH" => Array("FIELD_NAME" => "ST.WIDTH", "FIELD_TYPE" => "int"),
  107. "HEIGHT" => Array("FIELD_NAME" => "ST.HEIGHT", "FIELD_TYPE" => "int"),
  108. "COLOR" => Array("FIELD_NAME" => "ST.COLOR", "FIELD_TYPE" => "int"),
  109. "COLLAPSED" => Array("FIELD_NAME" => "ST.COLLAPSED ", "FIELD_TYPE" => "string"),
  110. "CLOSED" => Array("FIELD_NAME" => "ST.CLOSED ", "FIELD_TYPE" => "string"),
  111. "DELETED" => Array("FIELD_NAME" => "ST.DELETED ", "FIELD_TYPE" => "string"),
  112. "MARKER_TOP" => Array("FIELD_NAME" => "ST.MARKER_TOP", "FIELD_TYPE" => "int"),
  113. "MARKER_LEFT" => Array("FIELD_NAME" => "ST.MARKER_LEFT", "FIELD_TYPE" => "int"),
  114. "MARKER_WIDTH" => Array("FIELD_NAME" => "ST.MARKER_WIDTH", "FIELD_TYPE" => "int"),
  115. "MARKER_HEIGHT" => Array("FIELD_NAME" => "ST.MARKER_HEIGHT", "FIELD_TYPE" => "int"),
  116. "MARKER_ADJUST" => Array("FIELD_NAME" => "ST.MARKER_ADJUST", "FIELD_TYPE" => "string")
  117. );
  118. $err_mess = (CSticker::GetErrorMess())."<br>Function: GetList<br>Line: ";
  119. $arSqlSearch = array();
  120. $strSqlSearch = "";
  121. if ($bCache)
  122. {
  123. $cache = new CPHPCache;
  124. $cacheId = serialize(array($arFilter, $bDBResult));
  125. if(($tzOffset = CTimeZone::GetOffset()) <> 0)
  126. $cacheId .= "_".$tzOffset;
  127. if ($cache->InitCache($cacheTime, $cacheId, $cachePath))
  128. {
  129. $cachedRes = $cache->GetVars();
  130. if (!empty($cachedRes['stickers']))
  131. return $cachedRes['stickers'];
  132. }
  133. }
  134. if(is_array($arFilter))
  135. {
  136. $filter_keys = array_keys($arFilter);
  137. for($i=0, $l = count($filter_keys); $i<$l; $i++)
  138. {
  139. $n = strtoupper($filter_keys[$i]);
  140. $val = $arFilter[$filter_keys[$i]];
  141. if(is_string($val) && strlen($val) <=0)
  142. continue;
  143. if ($n == 'ID')
  144. $arSqlSearch[] = GetFilterQuery("ST.ID", $val, 'N');
  145. if ($n == 'PAGE_URL')
  146. $arSqlSearch[] = GetFilterQuery("ST.PAGE_URL", $val, 'N');
  147. if ($n == 'SITE_ID')
  148. $arSqlSearch[] = GetFilterQuery("ST.SITE_ID", $val, 'N');
  149. elseif(isset($arFields[$n]))
  150. $arSqlSearch[] = GetFilterQuery($arFields[$n]["FIELD_NAME"], $val);
  151. }
  152. }
  153. $strOrderBy = '';
  154. foreach($arOrder as $by=>$order)
  155. if(isset($arFields[strtoupper($by)]))
  156. $strOrderBy .= $arFields[strtoupper($by)]["FIELD_NAME"].' '.(strtolower($order)=='desc'?'desc'.(strtoupper($DB->type)=="ORACLE"?" NULLS LAST":""):'asc'.(strtoupper($DB->type)=="ORACLE"?" NULLS FIRST":"")).',';
  157. if(strlen($strOrderBy) > 0)
  158. $strOrderBy = "ORDER BY ".rtrim($strOrderBy, ",");
  159. $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
  160. if (is_array($arFilter['COLORS']))
  161. {
  162. $strColors = "";
  163. for($i=0; $i < count($arFilter['COLORS']); $i++)
  164. $strColors .= ",".IntVal($arFilter['COLORS'][$i]);
  165. $strSqlSearch .= "\n AND COLOR in (".trim($strColors, ", ").")";
  166. }
  167. $strSql = "
  168. SELECT
  169. ST.*, ".$DB->DateToCharFunction("ST.DATE_UPDATE")." as DATE_UPDATE2,
  170. ".$DB->DateToCharFunction("ST.DATE_CREATE")." as DATE_CREATE2
  171. FROM
  172. b_sticker ST
  173. WHERE
  174. $strSqlSearch
  175. $strOrderBy";
  176. $res = $DB->Query($strSql, false, $err_mess.__LINE__);
  177. if ($arFilter['USER_ID'] > 0 || !$bDBResult)
  178. {
  179. $arResult = Array();
  180. while($arRes = $res->Fetch())
  181. {
  182. if ($arFilter['USER_ID'] > 0 && $arRes['CREATED_BY'] != $arFilter['USER_ID'] &&
  183. ($arRes['PERSONAL'] == 'Y'/* It's another user's personal sticker*/
  184. || $arFilter['ONLY_OWNER'] == 'Y'/* display only owner's stickers*/))
  185. continue;
  186. if (!$bDBResult)
  187. {
  188. $arRes['AUTHOR'] = CSticker::GetUserName($arRes['CREATED_BY']);
  189. $arRes['INFO'] = CSticker::GetStickerInfo($arRes['CREATED_BY'], $arRes['DATE_CREATE2'], $arRes['MODIFIED_BY'], $arRes['DATE_UPDATE2']);
  190. $arRes['HTML_CONTENT'] = CSticker::BBParseToHTML($arRes['CONTENT']);
  191. $arRes['MARKER_ADJUST'] = unserialize($arRes['MARKER_ADJUST']);
  192. }
  193. $arResult[] = $arRes;
  194. }
  195. if ($bDBResult)
  196. $res->InitFromArray($arResult);
  197. }
  198. if ($bDBResult)
  199. $arResult = $res;
  200. if ($bCache)
  201. {
  202. $cache->StartDataCache($cacheTime, $cacheId, $cachePath);
  203. $cache->EndDataCache(array("stickers" => $arResult));
  204. }
  205. return $arResult;
  206. }
  207. function ClearCache()
  208. {
  209. return true;
  210. }
  211. function GetById($id)
  212. {
  213. global $USER;
  214. $res = CSticker::GetList(
  215. array(
  216. 'arFilter' => array(
  217. 'USER_ID' => $USER->GetId(),
  218. 'ID' => intVal($id),
  219. )
  220. ));
  221. if ($res && is_array($res) && count($res) > 0)
  222. return $res[0];
  223. return false;
  224. }
  225. function GetPagesList($site)
  226. {
  227. if (!CSticker::CanDoOperation('sticker_view'))
  228. return false;
  229. global $USER, $DB;
  230. $userId = $USER->GetId();
  231. $cachePath = "stickers/";
  232. $cacheTime = 36000000;
  233. $bCache = true;
  234. if ($bCache)
  235. {
  236. $cache = new CPHPCache;
  237. $cacheId = 'page_list_'.$userId;
  238. if ($cache->InitCache($cacheTime, $cacheId, $cachePath))
  239. {
  240. $cachedRes = $cache->GetVars();
  241. if (!empty($cachedRes['page_list']))
  242. return $cachedRes['page_list'];
  243. }
  244. }
  245. $err_mess = (CSticker::GetErrorMess())."<br>Function: GetPagesList<br>Line: ";
  246. $strSql = "
  247. select PAGE_URL, PAGE_TITLE, max(DATE_UPDATE) as MAX_DATE_UPDATE
  248. from b_sticker
  249. where
  250. DELETED='N'
  251. AND SITE_ID='".$DB->ForSql($site)."'
  252. AND ((PERSONAL='Y' AND CREATED_BY=".intVal($userId).") OR PERSONAL='N')
  253. group by PAGE_URL, PAGE_TITLE
  254. order by MAX_DATE_UPDATE desc";
  255. $strSql = $DB->TopSQL($strSql, 10);
  256. $res = $DB->Query($strSql, false, $err_mess.__LINE__);
  257. $arResult = array();
  258. while($arRes = $res->Fetch())
  259. $arResult[] = $arRes;
  260. if ($bCache)
  261. {
  262. $cache->StartDataCache($cacheTime, $cacheId, $cachePath);
  263. $cache->EndDataCache(array("page_list" => $arResult));
  264. }
  265. return $arResult;
  266. }
  267. function GetCurPageCount()
  268. {
  269. global $APPLICATION;
  270. return CSticker::GetCount(array(
  271. "PAGE_URL" => $APPLICATION->GetCurPage(),
  272. "SITE_ID" => SITE_ID
  273. ));
  274. }
  275. function GetCount($Params)
  276. {
  277. global $DB, $USER;
  278. $userId = $USER->GetId();
  279. $strSqlSearch = "((ST.PERSONAL='Y' AND ST.CREATED_BY=".intVal($userId).") OR ST.PERSONAL='N')";
  280. $strSqlSearch .= "\n AND ST.CLOSED='N' AND ST.DELETED='N' AND ST.SITE_ID='".$DB->ForSql($Params['SITE_ID'])."'";
  281. if ($Params["PAGE_URL"])
  282. $strSqlSearch .= "\n AND ST.PAGE_URL='".$DB->ForSql($Params["PAGE_URL"])."'";
  283. $strSql = "
  284. SELECT
  285. COUNT(ST.ID) as CNT
  286. FROM
  287. b_sticker ST
  288. WHERE
  289. $strSqlSearch";
  290. $err_mess = (CSticker::GetErrorMess())."<br>Function: GetCount<br>Line: ";
  291. $res = $DB->Query($strSql, false, $err_mess.__LINE__);
  292. $count = 0;
  293. if($arRes = $res->Fetch())
  294. $count = $arRes['CNT'];
  295. return $count;
  296. }
  297. function Edit($Params)
  298. {
  299. if (!CSticker::CanDoOperation('sticker_edit'))
  300. return;
  301. global $DB, $USER;
  302. $arFields = $Params['arFields'];
  303. if(!CSticker::CheckFields($arFields))
  304. return false;
  305. $bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0;
  306. if (!isset($arFields['~DATE_UPDATE']))
  307. $arFields['~DATE_UPDATE'] = $DB->CurrentTimeFunction();
  308. if (!isset($arFields['MODIFIED_BY']))
  309. $arFields['MODIFIED_BY'] = $USER->GetId();
  310. if (!isset($arFields['SITE_ID']))
  311. $arFields['SITE_ID'] = $_REQUEST['site_id'];
  312. if ($bNew) // Add
  313. {
  314. if (!isset($arFields['CREATED_BY']))
  315. $arFields['CREATED_BY'] = $arFields['MODIFIED_BY'];
  316. if (!isset($arFields['~DATE_CREATE']))
  317. $arFields['~DATE_CREATE'] = $arFields['~DATE_UPDATE'];
  318. unset($arFields['ID']);
  319. $ID = $DB->Add("b_sticker", $arFields, Array("CONTENT","MARKER_ADJUST"));
  320. }
  321. else // Update
  322. {
  323. $ID = $arFields['ID'];
  324. unset($arFields['ID']);
  325. $strUpdate = $DB->PrepareUpdate("b_sticker", $arFields);
  326. $strSql =
  327. "UPDATE b_sticker SET ".
  328. $strUpdate.
  329. " WHERE ID=".IntVal($ID);
  330. $DB->QueryBind($strSql, Array("CONTENT" => $arFields["CONTENT"], "MARKER_ADJUST" => $arFields["MARKER_ADJUST"]), false, "File: ".__FILE__."<br>Line: ".__LINE__);
  331. }
  332. CSticker::ClearCache();
  333. return $ID;
  334. }
  335. function DeleteAll()
  336. {
  337. if (!CSticker::CanDoOperation('sticker_del'))
  338. return GetMessage('FMST_DEL_ACCESS_ERROR');
  339. global $DB;
  340. if (!$DB->Query("DELETE FROM b_sticker WHERE 1=1", false, "File: ".__FILE__."<br>Line: ".__LINE__))
  341. return GetMessage('FMST_REQ_ERROR');
  342. CSticker::ClearCache();
  343. return true;
  344. }
  345. function Delete($ids = array())
  346. {
  347. if (!is_array($ids))
  348. $ids = array($ids);
  349. if (!CSticker::CanDoOperation('sticker_del'))
  350. return GetMessage('FMST_DEL_ACCESS_ERROR');
  351. if (count($ids) == 0)
  352. return GetMessage('FMST_NO_ITEMS_WARN');
  353. global $DB;
  354. $strIds = "";
  355. for($i=0; $i < count($ids); $i++)
  356. $strIds .= ",".IntVal($ids[$i]);
  357. $strSql = "DELETE FROM b_sticker WHERE ID in (".trim($strIds, ", ").")";
  358. if (!$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__))
  359. return GetMessage('FMST_REQ_ERROR');
  360. CSticker::ClearCache();
  361. return true;
  362. }
  363. function CheckFields()
  364. {
  365. return true;
  366. }
  367. function SetHiden($ids = array(), $bHide)
  368. {
  369. if (!is_array($ids))
  370. $ids = array($ids);
  371. if (!CSticker::CanDoOperation('sticker_edit'))
  372. return GetMessage('FMST_EDIT_ACCESS_ERROR');
  373. if (count($ids) == 0)
  374. return GetMessage('FMST_NO_ITEMS_WARN');
  375. global $DB;
  376. $strIds = "";
  377. for($i=0; $i < count($ids); $i++)
  378. $strIds .= ",".IntVal($ids[$i]);
  379. $arFields = array("CLOSED" => $bHide ? "Y" : "N");
  380. $strUpdate = $DB->PrepareUpdate("b_sticker", $arFields);
  381. $strSql =
  382. "UPDATE b_sticker SET ".
  383. $strUpdate.
  384. " WHERE ID in (".trim($strIds, ", ").")";
  385. if (!$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__))
  386. return GetMessage('FMST_REQ_ERROR');
  387. CSticker::ClearCache();
  388. return true;
  389. }
  390. function InitJS($Params)
  391. {
  392. global $APPLICATION, $USER;
  393. CUtil::InitJSCore(array('window', 'ajax'));
  394. $APPLICATION->AddHeadScript('/freetrix/js/fileman/sticker.js', true);
  395. $APPLICATION->SetAdditionalCSS('/freetrix/js/fileman/sticker.css', true);
  396. $pageUrl = $APPLICATION->GetCurPage();
  397. $pageTitle = $APPLICATION->GetTitle();
  398. if ($pageTitle == '')
  399. $pageTitle = $pageUrl;
  400. $listSize = CUtil::GetPopupSize("bx_sticker_list_resize_id", array("width" => 800, "height" => 450));
  401. $size = explode("_", COption::GetOptionString("fileman", "stickers_start_sizes", "350_200"));
  402. $min_width = 280;
  403. $min_height = 160;
  404. $JSConfig = array(
  405. "access" => CSticker::CanDoOperation('sticker_edit') ? "W" : "R",
  406. "sessid_get" => freetrix_sessid_get(),
  407. "start_width" => $size[0] > $min_width ? $size[0] : $min_width,
  408. "start_height" => $size[1] > $min_height ? $size[1] : $min_height,
  409. "min_width" => $min_width,
  410. "min_height" => $min_height,
  411. "start_color" => CUserOptions::GetOption('fileman', "stickers_last_color", 0),
  412. "zIndex" => 5000,
  413. "curUserName" => CSticker::GetUserName(),
  414. "curUserId" => $USER->GetId(),
  415. "pageUrl" => $pageUrl,
  416. "pageTitle" => $pageTitle,
  417. "bShowStickers" => $Params['bInit'],
  418. "listWidth" => $listSize['width'],
  419. "listHeight" => $listSize['height'],
  420. "listNaviSize" => CUserOptions::GetOption('fileman', "stickers_navi_size", 5),
  421. "useHotkeys" => COption::GetOptionString('fileman', "stickers_use_hotkeys", "Y") == "Y",
  422. "filterParams" => CSticker::GetFilterParams(),
  423. "bHideBottom" => COption::GetOptionString("fileman", "stickers_hide_bottom", "Y") == "Y",
  424. "focusOnSticker" => isset($_GET['show_sticker'])? intVal($_GET['show_sticker']): 0,
  425. "strDate" => FormatDate("j F", time()+CTimeZone::GetOffset()),
  426. "curPageCount" => $Params['curPageCount'],
  427. "site_id" => SITE_ID
  428. );
  429. if (!is_array($Params['stickers']))
  430. $Params['stickers'] = array();
  431. self::$Params = array("JSCONFIG" => $JSConfig, "STICKERS" => $Params['stickers']);
  432. }
  433. function InitJsAfter()
  434. {
  435. if(is_array(self::$Params))
  436. {
  437. return '<script type="text/javascript">BX.ready(function(){'.CSticker::AppendLangMessages()." window.oBXSticker = new BXSticker(".CUtil::PhpToJSObject(self::$Params['JSCONFIG']).", ".CUtil::PhpToJSObject(self::$Params['STICKERS']).", BXST_MESS);});</script>";
  438. }
  439. }
  440. function GetUserName($id = false)
  441. {
  442. global $USER;
  443. static $arUsersCache = array();
  444. if ($id !== false)
  445. {
  446. if (isset($arUsersCache[$id]))
  447. return $arUsersCache[$id];
  448. $rsu = CUser::GetByID($id);
  449. if($arUser = $rsu->Fetch())
  450. $arUsersCache[$id] = htmlspecialcharsback(CUser::FormatName(CSite::GetNameFormat(), $arUser));
  451. else
  452. $arUsersCache[$id] = '- Unknown -';
  453. }
  454. else
  455. {
  456. $id = $USER->GetId();
  457. if (isset($arUsersCache[$id]))
  458. return $arUsersCache[$id];
  459. $arUsersCache[$id] = htmlspecialcharsback($USER->GetFormattedName());
  460. }
  461. return $arUsersCache[$id];
  462. }
  463. function AppendLangMessages()
  464. {
  465. return 'var BXST_MESS =
  466. {
  467. Public : "'.GetMessage('FMST_TYPE_PUBLIC').'",
  468. Personal : "'.GetMessage('FMST_TYPE_PERSONAL').'",
  469. Close : "'.GetMessage('FMST_CLOSE').'",
  470. Collapse : "'.GetMessage('FMST_COLLAPSE').'",
  471. UnCollapse : "'.GetMessage('FMST_UNCOLLAPSE').'",
  472. UnCollapseTitle : "'.GetMessage('FMST_UNCOLLAPSE_TITLE').'",
  473. SetMarkerArea : "'.GetMessage('FMST_SET_MARKER_AREA').'",
  474. SetMarkerEl : "'.GetMessage('FMST_SET_MARKER_ELEMENT').'",
  475. Color : "'.GetMessage('FMST_COLOR').'",
  476. Add : "'.GetMessage('FMST_ADD').'",
  477. PersonalTitle : "'.GetMessage('FMST_TYPE_PERSONAL_TITLE').'",
  478. PublicTitle : "'.GetMessage('FMST_TYPE_PUBLIC_TITLE').'",
  479. CursorHint : "'.GetMessage('FMST_CURSOR_HINT').'",
  480. Yellow : "'.GetMessage('FMST_COL_YELLOW').'",
  481. Green : "'.GetMessage('FMST_COL_GREEN').'",
  482. Blue : "'.GetMessage('FMST_COL_BLUE').'",
  483. Red : "'.GetMessage('FMST_COL_RED').'",
  484. Purple : "'.GetMessage('FMST_COL_PURPLE').'",
  485. Gray : "'.GetMessage('FMST_COL_GREY').'",
  486. StickerListTitle : "'.GetMessage('FMST_PANEL_STICKER_LIST').'",
  487. CompleteLabel : "'.GetMessage('FMST_COMPLETE_LABEL').'",
  488. DelConfirm : "'.GetMessage('FMST_LIST_DEL_CONFIRM').'",
  489. CloseConfirm : "'.GetMessage('FMST_CLOSE_CONFIRM').'",
  490. Complete : "'.GetMessage('FMST_COMPLETE').'",
  491. CloseNotify : "'.GetMessage('FMST_CLOSE_MESSAGE').'"
  492. };';
  493. }
  494. function Init($Params = array())
  495. {
  496. global $APPLICATION, $USER;
  497. if (!CSticker::CanDoOperation('sticker_view'))
  498. return;
  499. // Dectect - show stickers or No
  500. $bGetStickers = CSticker::GetBShowStickers();
  501. $Stickers = array();
  502. if ($bGetStickers)
  503. {
  504. $Stickers = CSticker::GetList(array(
  505. 'arFilter' => array(
  506. 'USER_ID' => $USER->GetId(),
  507. 'PAGE_URL' => $APPLICATION->GetCurPage(),
  508. 'CLOSED' => 'N',
  509. 'DELETED' => 'N',
  510. 'SITE_ID' => SITE_ID
  511. )
  512. ));
  513. }
  514. else
  515. {
  516. $Stickers = array();
  517. }
  518. $curPageCount = isset($Params['curPageCount']) ? $Params['curPageCount'] : CSticker::GetCurPageCount();
  519. CSticker::InitJS(array(
  520. 'bInit' => $bGetStickers,
  521. 'stickers' => $Stickers,
  522. 'curPageCount' => $curPageCount
  523. ));
  524. }
  525. function GetErrorMess()
  526. {
  527. return "Class: CSticker<br>File: ".__FILE__;
  528. }
  529. function GetScriptStr($mode)
  530. {
  531. if ($mode == 'add')
  532. return "if (window.oBXSticker){window.oBXSticker.AddSticker();}";
  533. elseif($mode == 'list_cur')
  534. return "if (window.oBXSticker){window.oBXSticker.ShowList('current');}";
  535. elseif($mode == 'list_all')
  536. return "if (window.oBXSticker){window.oBXSticker.ShowList('all');}";
  537. elseif($mode == 'show')
  538. return "if (window.oBXSticker){window.oBXSticker.ShowAll();}";
  539. return '';
  540. }
  541. function GetBShowStickers()
  542. {
  543. if (isset($_SESSION["SESS_SHOW_STICKERS"]) && $_SESSION["SESS_SHOW_STICKERS"] == "Y")
  544. return true;
  545. if (isset($_GET['show_sticker']) && intVal($_GET['show_sticker']) > 0)
  546. return true;
  547. return false;
  548. }
  549. function SetBShowStickers($bShow = false)
  550. {
  551. $_SESSION["SESS_SHOW_STICKERS"] = $bShow ? "Y" : "N";
  552. return $bShow;
  553. }
  554. function BBParseToHTML($str, $bForList = false)
  555. {
  556. if (!$oParser)
  557. $oParser = new blogTextParser1();
  558. $html = $oParser->convert($str, false, array(), array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "Y", "LIST" => "Y", "SMILES" => "N", "NL2BR" => "N", "VIDEO" => "N", "TABLE" => "N"));
  559. if ($bForList)
  560. {
  561. $html = preg_replace(array(
  562. "/\[st_title\](.+?)\[\/st_title\]/is".FX_UTF_PCRE_MODIFIER,
  563. "/<br(.+?)>/is".FX_UTF_PCRE_MODIFIER,
  564. "/<\/??ol(.+?)>/is".FX_UTF_PCRE_MODIFIER,
  565. "/<\/??ul(.+?)>/is".FX_UTF_PCRE_MODIFIER,
  566. "/<\/??li(.+?)>/is".FX_UTF_PCRE_MODIFIER,
  567. "/<\/??w+(.+?)>/is".FX_UTF_PCRE_MODIFIER
  568. ), " ", $html);
  569. $html = preg_replace(
  570. array(
  571. "/\[st_title\]/is".FX_UTF_PCRE_MODIFIER,
  572. "/\[\/st_title\]/is".FX_UTF_PCRE_MODIFIER,
  573. ),
  574. "",
  575. $html
  576. );
  577. if (strlen($html) > 40)
  578. $html = substr($html, 0, 40)."...";
  579. }
  580. else
  581. {
  582. $html = preg_replace(
  583. "/\[st_title\](.*?)\[\/st_title\]/is".FX_UTF_PCRE_MODIFIER,
  584. "<span class=\"bxst-title\">\\1</span> ",
  585. $html
  586. );
  587. // ?
  588. $html = preg_replace(
  589. array(
  590. "/\[st_title\]/is".FX_UTF_PCRE_MODIFIER,
  591. "/\[\/st_title\]/is".FX_UTF_PCRE_MODIFIER,
  592. ),
  593. "",
  594. $html
  595. );
  596. }
  597. return $html;
  598. }
  599. function GetStickerInfo($createdBy, $dateCreate, $modBy, $dateMod)
  600. {
  601. $str = GetMessage("FMST_CREATED").": <b>".htmlspecialcharsEx(CSticker::GetUserName($createdBy))."</b> ".CSticker::GetUsableDate($dateCreate).
  602. "<br/>".
  603. GetMessage("FMST_UPDATED").": <b>".htmlspecialcharsEx(CSticker::GetUserName($modBy))."</b> ".CSticker::GetUsableDate($dateMod);
  604. return $str;
  605. }
  606. function GetUsableDate($d)
  607. {
  608. $ts = MakeTimeStamp(ConvertDateTime($d, "DD.MM.YYYY HH:MI"), "DD.MM.YYYY HH:MI");
  609. if (date("Y") == date("Y", $ts)) // Same year
  610. $date = FormatDate("j F G:i", $ts);
  611. else
  612. $date = FormatDate("j.m.Y", $ts);
  613. return $date;
  614. }
  615. function SetFilterParams($Filter)
  616. {
  617. CUserOptions::SetOption('fileman', "stickers_list_filter", serialize($Filter));
  618. }
  619. function GetFilterParams()
  620. {
  621. $result = array(
  622. 'type' => 'all',
  623. 'colors' => 'all',
  624. 'status' => 'opened',
  625. 'page' => 'all'
  626. );
  627. $res = CUserOptions::GetOption('fileman', "stickers_list_filter", false);
  628. if ($res !== false)
  629. {
  630. $Filter = unserialize($res);
  631. if (is_array($Filter))
  632. {
  633. if ($Filter['type'])
  634. $result['type'] = $Filter['type'] == 'my' ? 'my' : 'all';
  635. if ($Filter['status'] && in_array($Filter['status'], array('all', 'opened', 'closed')))
  636. $result['status'] = $Filter['status'];
  637. if ($Filter['page'])
  638. $result['page'] = $Filter['page'];
  639. if ($Filter['colors'])
  640. $result['colors'] = $Filter['colors'];
  641. }
  642. }
  643. return $result;
  644. }
  645. }
  646. // Class from /freetrix/modules/blog/general/functions.php
  647. // TODO: Remove this class after including BB-parser class to the core
  648. class blogTextParser1
  649. {
  650. var $smiles = array();
  651. var $arFontSize = array(
  652. 1 => 40, //"xx-small"
  653. 2 => 60, //"x-small"
  654. 3 => 80, //"small"
  655. 4 => 100, //"medium"
  656. 5 => 120, //"large"
  657. 6 => 140, //"x-large"
  658. 7 => 160); //"xx-large"
  659. var $word_separator = "\s.,;:!?\#\-\*\|\[\]\(\)\{\}";
  660. function blogTextParser1($strLang = False, $pathToSmile = false)
  661. {
  662. global $DB;
  663. if ($strLang===False)
  664. $strLang = LANGUAGE_ID;
  665. $this->path_to_smile = $pathToSmile;
  666. $this->imageWidth = COption::GetOptionString("blog", "image_max_width", 600);
  667. $this->imageHeight = COption::GetOptionString("blog", "image_max_height", 600);
  668. $this->smiles = array();
  669. }
  670. function convert($text, $bPreview = True, $arImages = array(), $allow = array("HTML" => "N", "ANCHOR" => "Y", "BIU" => "Y", "IMG" => "Y", "QUOTE" => "Y", "CODE" => "Y", "FONT" => "Y", "LIST" => "Y", "SMILES" => "Y", "NL2BR" => "N", "VIDEO" => "Y", "TABLE" => "Y", "CUT_ANCHOR" => "N"), $arParams = Array())
  671. {
  672. global $DB;
  673. $text = preg_replace("#([?&;])PHPSESSID=([0-9a-zA-Z]{32})#is", "\\1PHPSESSID1=", $text);
  674. if(!is_array($arParams) && strlen($arParams) > 0)
  675. $type = $arParams;
  676. elseif(is_array($arParams))
  677. $type = $arParams["type"];
  678. if(IntVal($arParams["imageWidth"]) > 0)
  679. $this->imageWidth = IntVal($arParams["imageWidth"]);
  680. if(IntVal($arParams["imageHeight"]) > 0)
  681. $this->imageHeight = IntVal($arParams["imageHeight"]);
  682. $type = ($type == "rss" ? "rss" : "html");
  683. $serverName = "";
  684. if($type == "rss")
  685. {
  686. $dbSite = CSite::GetByID(SITE_ID);
  687. $arSite = $dbSite->Fetch();
  688. $serverName = $arSite["SERVER_NAME"];
  689. if (strLen($serverName) <=0)
  690. {
  691. if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME)>0)
  692. $serverName = SITE_SERVER_NAME;
  693. else
  694. $serverName = COption::GetOptionString("main", "server_name", "www.freetrixsoft.com");
  695. }
  696. $serverName = "http://".$serverName;
  697. }
  698. $this->quote_error = 0;
  699. $this->quote_open = 0;
  700. $this->quote_closed = 0;
  701. $this->code_error = 0;
  702. $this->code_open = 0;
  703. $this->code_closed = 0;
  704. $this->MaxStringLen = 60;
  705. $this->preg = array("counter" => 0, "pattern" => array(), "replace" => array());
  706. $this->allow_img_ext = "gif|jpg|jpeg|png";
  707. $allow = array(
  708. "HTML" => ($allow["HTML"] == "Y" ? "Y" : "N"),
  709. "NL2BR" => ($allow["NL2BR"] == "Y" ? "Y" : "N"),
  710. "CODE" => ($allow["CODE"] == "N" ? "N" : "Y"),
  711. "VIDEO" => ($allow["VIDEO"] == "N" ? "N" : "Y"),
  712. "ANCHOR" => ($allow["ANCHOR"] == "N" ? "N" : "Y"),
  713. "BIU" => ($allow["BIU"] == "N" ? "N" : "Y"),
  714. "IMG" => ($allow["IMG"] == "N" ? "N" : "Y"),
  715. "QUOTE" => ($allow["QUOTE"] == "N" ? "N" : "Y"),
  716. "FONT" => ($allow["FONT"] == "N" ? "N" : "Y"),
  717. "LIST" => ($allow["LIST"] == "N" ? "N" : "Y"),
  718. "SMILES" => ($allow["SMILES"] == "N" ? "N" : "Y"),
  719. "TABLE" => ($allow["TABLE"] == "N" ? "N" : "Y"),
  720. "ALIGN" => ($allow["ALIGN"] == "N" ? "N" : "Y"),
  721. "CUT_ANCHOR" => ($allow["CUT_ANCHOR"] == "Y" ? "Y" : "N"),
  722. );
  723. $this->arImages = $arImages;
  724. $text = str_replace(array("\001", "\002", chr(11), chr(12), chr(34), chr(39)), array("", "", "", "", chr(11), chr(12)), $text);
  725. if ($bPreview)
  726. {
  727. $text = preg_replace("#^(.*?)<cut[\s]*(/>|>).*?$#is", "\\1", $text);
  728. $text = preg_replace("#^(.*?)\[cut[\s]*(/\]|\]).*?$#is", "\\1", $text);
  729. }
  730. else
  731. {
  732. $text = preg_replace("#<cut[\s]*(/>|>)#is", "[cut]", $text);
  733. }
  734. if ($allow["CODE"]=="Y")
  735. {
  736. $text = preg_replace(
  737. array(
  738. "#<code(\s+[^>]*>|>)(.+?)</code(\s+[^>]*>|>)#is".FX_UTF_PCRE_MODIFIER,
  739. "/\[code([^\]])*\]/is".FX_UTF_PCRE_MODIFIER,
  740. "/\[\/code([^\]])*\]/is".FX_UTF_PCRE_MODIFIER,
  741. "/(?<=[\001])(([^\002]+))(?=([\002]))/ise".FX_UTF_PCRE_MODIFIER,
  742. "/\001/",
  743. "/\002/"),
  744. array(
  745. "[code]\\2[/code]",
  746. "\001",
  747. "\002",
  748. "\$this->pre_convert_code_tag('\\2')",
  749. "[code]",
  750. "[/code]"), $text);
  751. }
  752. if ($allow["HTML"] != "Y")
  753. {
  754. if ($allow["ANCHOR"]=="Y")
  755. {
  756. $text = preg_replace(
  757. array(
  758. "#<a[^>]+href\s*=\s*[\011]+(([^\011])+)[\011]+[^>]*>(.*?)</a[^>]*>#is".FX_UTF_PCRE_MODIFIER,
  759. "#<a[^>]+href\s*=\s*[\012]+(([^\012])+)[\012]+[^>]*>(.*?)</a[^>]*>#is".FX_UTF_PCRE_MODIFIER,
  760. "#<a[^>]+href\s*=\s*(([^\012\011\>])+)>(.*?)</a[^>]*>#is".FX_UTF_PCRE_MODIFIER),
  761. "[url=\\1]\\3[/url]", $text);
  762. }
  763. if ($allow["BIU"]=="Y")
  764. {
  765. $text = preg_replace(
  766. array(
  767. "/\<b([^>]*)\>(.+?)\<\/b([^>]*)>/is".FX_UTF_PCRE_MODIFIER,
  768. "/\<u([^>]*)\>(.+?)\<\/u([^>]*)>/is".FX_UTF_PCRE_MODIFIER,
  769. "/\<s([^>a-z]*)\>(.+?)\<\/s([^>a-z]*)>/is".FX_UTF_PCRE_MODIFIER,
  770. "/\<i([^>]*)\>(.+?)\<\/i([^>]*)>/is".FX_UTF_PCRE_MODIFIER),
  771. array(
  772. "[b]\\2[/b]",
  773. "[u]\\2[/u]",
  774. "[s]\\2[/s]",
  775. "[i]\\2[/i]"),
  776. $text);
  777. }
  778. if ($allow["IMG"]=="Y")
  779. {
  780. $text = preg_replace(
  781. "#<img[^>]+src\s*=[\s\011\012]*(((http|https|ftp)://[.-_:a-z0-9@]+)*(\/[-_/=:.a-z0-9@{}&?%]+)+)[\s\011\012]*[^>]*>#is".FX_UTF_PCRE_MODIFIER,
  782. "[img]\\1[/img]", $text);
  783. }
  784. if ($allow["FONT"]=="Y")
  785. {
  786. $text = preg_replace(
  787. array(
  788. "/\<font[^>]+size\s*=[\s\011\012]*([0-9]+)[\s\011\012]*[^>]*\>(.+?)\<\/font[^>]*\>/is".FX_UTF_PCRE_MODIFIER,
  789. "/\<font[^>]+color\s*=[\s\011\012]*(\#[a-f0-9]{6})[^>]*\>(.+?)\<\/font[^>]*>/is".FX_UTF_PCRE_MODIFIER,
  790. "/\<font[^>]+face\s*=[\s\011\012]*([a-z\s\-]+)[\s\011\012]*[^>]*>(.+?)\<\/font[^>]*>/is".FX_UTF_PCRE_MODIFIER),
  791. array(
  792. "[size=\\1]\\2[/size]",
  793. "[color=\\1]\\2[/color]",
  794. "[font=\\1]\\2[/font]"),
  795. $text);
  796. }
  797. if ($allow["LIST"]=="Y")
  798. {
  799. $text = preg_replace(
  800. array(
  801. "/\<ul((\s[^>]*)|(\s*))\>(.+?)<\/ul([^>]*)\>/is".FX_UTF_PCRE_MODIFIER,
  802. "/\<ol((\s[^>]*)|(\s*))\>(.+?)<\/ol([^>]*)\>/is".FX_UTF_PCRE_MODIFIER,
  803. "/\<li((\s[^>]*)|(\s*))\>/is".FX_UTF_PCRE_MODIFIER,
  804. ),
  805. array(
  806. "[list]\\4[/list]",
  807. "[list=1]\\4[/list]",
  808. "[*]",
  809. ),
  810. $text);
  811. }
  812. if ($allow["TABLE"]=="Y")
  813. {
  814. $text = preg_replace(
  815. array(
  816. "/\<table((\s[^>]*)|(\s*))\>(.+?)<\/table([^>]*)\>/is".FX_UTF_PCRE_MODIFIER,
  817. "/\<tr((\s[^>]*)|(\s*))\>(.*?)<\/tr([^>]*)\>/is".FX_UTF_PCRE_MODIFIER,
  818. "/\<td((\s[^>]*)|(\s*))\>(.*?)<\/td([^>]*)\>/is".FX_UTF_PCRE_MODIFIER,
  819. ),
  820. array(
  821. "[table]\\4[/table]",
  822. "[tr]\\4[/tr]",
  823. "[td]\\4[/td]",
  824. ),
  825. $text);
  826. }
  827. if ($allow["QUOTE"]=="Y")
  828. {
  829. $text = preg_replace("#<(/?)quote(.*?)>#is", "[\\1quote]", $text);
  830. }
  831. if (strLen($text)>0)
  832. {
  833. $text = str_replace(
  834. array("<", ">", chr(34)),
  835. array("&lt;", "&gt;", "&quot;"),
  836. $text);
  837. }
  838. }
  839. if ($allow["ANCHOR"]=="Y")
  840. {
  841. $word_separator = str_replace("\]", "", $this->word_separator);
  842. $text = preg_replace("'(?<=^|[".$word_separator."]|\s)((http|https|news|ftp|aim|mailto)://[\.\-\_\:a-z0-9\@]([^\011\s\'\012\[\]\{\}])*)'is",
  843. "[url]\\1[/url]", $text);
  844. }
  845. foreach ($allow as $tag => $val)
  846. {
  847. if ($val != "Y")
  848. continue;
  849. if (strpos($text, "<nomodify>") !== false):
  850. $text = preg_replace(
  851. array(
  852. "/\001/", "/\002/",
  853. "/\<nomodify\>/is".FX_UTF_PCRE_MODIFIER, "/\<\/nomodify\>/is".FX_UTF_PCRE_MODIFIER,
  854. "/(\001([^\002]+)\002)/ies".FX_UTF_PCRE_MODIFIER,
  855. "/\001/", "/\002/"
  856. ),
  857. array(
  858. "", "",
  859. "\001", "\002",
  860. "\$this->defended_tags('\\2', 'replace')",
  861. "<nomodify>", "</nomodify>"),
  862. $text);
  863. endif;
  864. switch ($tag)
  865. {
  866. case "CODE":
  867. $bHTML = false;
  868. if($allow["HTML"] == "Y")
  869. $bHTML = true;
  870. $text = preg_replace(
  871. array( "/\[code([^\]])*\]/is".FX_UTF_PCRE_MODIFIER,
  872. "/\[\/code([^\]])*\]/is".FX_UTF_PCRE_MODIFIER,
  873. "/(\001([^\002]+)\002)/ies".FX_UTF_PCRE_MODIFIER,
  874. "/\001/",
  875. "/\002/"
  876. ),
  877. array( "\001",
  878. "\002",
  879. "\$this->convert_code_tag('\\2', \$type, \$bHTML)",
  880. "[code]",
  881. "[/code]"),
  882. $text);
  883. break;
  884. case "VIDEO":
  885. $text = preg_replace("/\[video([^\]]*)\](.+?)\[\/video[\s]*\]/ies".FX_UTF_PCRE_MODIFIER, "\$this->convert_video('\\1', '\\2')", $text);
  886. break;
  887. case "IMG":
  888. $text = preg_replace("/\[img([^\]]*)id\s*=\s*([0-9]+)([^\]]*)\]/ies".FX_UTF_PCRE_MODIFIER, "\$this->convert_blog_image('\\1', '\\2', '\\3', \$type, \$serverName)", $text);
  889. $text = preg_replace("/\[img([^\]]*)\](.+?)\[\/img\]/ies".FX_UTF_PCRE_MODIFIER, "\$this->convert_image_tag('\\2', \$type, \$serverName, '\\1')", $text);
  890. break;
  891. case "ANCHOR":
  892. if($allow["CUT_ANCHOR"] != "Y")
  893. {
  894. $text = preg_replace(
  895. array( "/\[url\]([^\]]*?)\[\/url\]/ies".FX_UTF_PCRE_MODIFIER,
  896. "/\[url\s*=\s*([^\]]+?)\s*\](.*?)\[\/url\]/ies".FX_UTF_PCRE_MODIFIER),
  897. array( "\$this->convert_anchor_tag('\\1', '\\1', '')",
  898. "\$this->convert_anchor_tag('\\1', '\\2', '')"
  899. ),
  900. $text);
  901. break;
  902. }
  903. else
  904. {
  905. $text = preg_replace(
  906. array( "/\[url\]([^\]]*?)\[\/url\]/ies".FX_UTF_PCRE_MODIFIER,
  907. "/\[url\s*=\s*([^\]]+?)\s*\](.*?)\[\/url\]/ies".FX_UTF_PCRE_MODIFIER),
  908. "",
  909. $text);
  910. break;
  911. }
  912. case "BIU":
  913. $text = preg_replace(
  914. array(
  915. "/\[b\](.+?)\[\/b\]/is".FX_UTF_PCRE_MODIFIER,
  916. "/\[i\](.+?)\[\/i\]/is".FX_UTF_PCRE_MODIFIER,
  917. "/\[s\](.+?)\[\/s\]/is".FX_UTF_PCRE_MODIFIER,
  918. "/\[u\](.+?)\[\/u\]/is".FX_UTF_PCRE_MODIFIER),
  919. array(
  920. "<b>\\1</b>",
  921. "<i>\\1</i>",
  922. "<s>\\1</s>",
  923. "<u>\\1</u>"),
  924. $text);
  925. break;
  926. case "LIST":
  927. while (preg_match("/\[list\s*=\s*([^\]]+?)\s*\](.+?)\[\/list\]/is".FX_UTF_PCRE_MODIFIER, $text))
  928. $text = preg_replace(
  929. array(
  930. "/\[list\s*=\s*1\](\s*\\n*)(.+?)\[\/list\]/is".FX_UTF_PCRE_MODIFIER,
  931. "/\[list\s*=\s*a\](\s*\\n*)(.+?)\[\/list\]/is".FX_UTF_PCRE_MODIFIER,
  932. "/\[\*\]/".FX_UTF_PCRE_MODIFIER,
  933. ),
  934. array(
  935. "<ol>\\2</ol>",
  936. "<ol type=\"a\">\\2</ol>",
  937. "<li>",
  938. ),
  939. $text);
  940. while (preg_match("/\[list\](.+?)\[\/list\]/is".FX_UTF_PCRE_MODIFIER, $text))
  941. $text = preg_replace(
  942. array(
  943. "/\[list\](\s*\\n*)(.+?)\[\/list\]/is".FX_UTF_PCRE_MODIFIER,
  944. "/\[\*\]/".FX_UTF_PCRE_MODIFIER,
  945. ),
  946. array(
  947. "<ul>\\2</ul>",
  948. "<li>",
  949. ),
  950. $text);
  951. break;
  952. case "FONT":
  953. while (preg_match("/\[size\s*=\s*([^\]]+)\](.+?)\[\/size\]/is".FX_UTF_PCRE_MODIFIER, $text))
  954. $text = preg_replace("/\[size\s*=\s*([^\]]+)\](.+?)\[\/size\]/ies".FX_UTF_PCRE_MODIFIER, "\$this->convert_font_attr('size', '\\1', '\\2')", $text);
  955. while (preg_match("/\[font\s*=\s*([^\]]+)\](.*?)\[\/font\]/is".FX_UTF_PCRE_MODIFIER, $text))
  956. $text = preg_replace("/\[font\s*=\s*([^\]]+)\](.*?)\[\/font\]/ies".FX_UTF_PCRE_MODIFIER, "\$this->convert_font_attr('font', '\\1', '\\2')", $text);
  957. while (preg_match("/\[color\s*=\s*([^\]]+)\](.+?)\[\/color\]/is".FX_UTF_PCRE_MODIFIER, $text))
  958. $text = preg_replace("/\[color\s*=\s*([^\]]+)\](.+?)\[\/color\]/ies".FX_UTF_PCRE_MODIFIER, "\$this->convert_font_attr('color', '\\1', '\\2')", $text);
  959. break;
  960. case "QUOTE":
  961. $text = preg_replace("#(\[quote([^\]\<\>])*\](.*)\[/quote([^\]\<\>])*\])#ies", "\$this->convert_quote_tag('\\1', \$type)", $text);
  962. break;
  963. case "TABLE":
  964. while (preg_match("/\[table\](.+?)\[\/table\]/is".FX_UTF_PCRE_MODIFIER, $text))
  965. {
  966. $text = preg_replace(
  967. array(
  968. "/\[table\](\s*\\n*)(.*?)\[\/table\]/is".FX_UTF_PCRE_MODIFIER,
  969. "/\[tr\](.*?)\[\/tr\](\s*\\n*)/is".FX_UTF_PCRE_MODIFIER,
  970. "/\[td\](.*?)\[\/td\]/is".FX_UTF_PCRE_MODIFIER,
  971. ),
  972. array(
  973. "<table class=\"data-table\">\\2</table>",
  974. "<tr>\\1</tr>",
  975. "<td>\\1</td>",
  976. ),
  977. $text);
  978. }
  979. break;
  980. case "ALIGN":
  981. $text = preg_replace(
  982. array(
  983. "/\[left\]([^\]]+?)\[\/left\]/is".FX_UTF_PCRE_MODIFIER,
  984. "/\[right\]([^\]]+?)\[\/right\]/is".FX_UTF_PCRE_MODIFIER,
  985. "/\[center\]([^\]]+?)\[\/center\]/is".FX_UTF_PCRE_MODIFIER,
  986. ),
  987. array(
  988. "<div align=\"left\">\\1</div>",
  989. "<div align=\"right\">\\1</div>",
  990. "<div align=\"center\">\\1</div>",
  991. ),
  992. $text);
  993. break;
  994. }
  995. $text = str_replace(array(chr(34), chr(39)), array(chr(11), chr(12)), $text);
  996. }
  997. if ($allow["HTML"] != "Y")
  998. $text = str_replace("\n", "<br />", $text);
  999. $text = str_replace(
  1000. array(
  1001. "(c)", "(C)",
  1002. "(tm)", "(TM)", "(Tm)", "(tM)",
  1003. "(r)", "(R)"),
  1004. array(
  1005. "&#169;", "&#169;",
  1006. "&#153;", "&#153;", "&#153;", "&#153;",
  1007. "&#174;", "&#174;"),
  1008. $text);
  1009. if ($this->MaxStringLen > 0)
  1010. {
  1011. $text = preg_replace(
  1012. array(
  1013. "/(\&\#\d{1,3}\;)/is".FX_UTF_PCRE_MODIFIER,
  1014. "/(?<=^|\>)([^\<]+)(?=\<|$)/ies".FX_UTF_PCRE_MODIFIER,
  1015. "/(\<\019((\&\#\d{1,3}\;))\>)/is".FX_UTF_PCRE_MODIFIER,),
  1016. array(
  1017. "<\019\\1>",
  1018. "\$this->part_long_words('\\1')",
  1019. "\\2"),
  1020. $text);
  1021. }
  1022. if (strpos($text, "<nosmile>") !== false)
  1023. {
  1024. $text = preg_replace(
  1025. array(
  1026. "/\001/", "/\002/",
  1027. "/\<nosmile\>/is".FX_UTF_PCRE_MODIFIER, "/\<\/nosmile\>/is".FX_UTF_PCRE_MODIFIER,
  1028. "/(\001([^\002]+)\002)/ies".FX_UTF_PCRE_MODIFIER,
  1029. "/\001/is", "/\002/is"
  1030. ),
  1031. array(
  1032. "", "",
  1033. "\001", "\002",
  1034. "\$this->defended_tags('\\2', 'replace')",
  1035. "<nosmile>", "</nosmile>"),
  1036. $text);
  1037. }
  1038. if (!$bPreview)
  1039. {
  1040. $text = preg_replace("#\[cut[\s]*(/\]|\])#is", "<a name=\"cut\"></a>", $text);
  1041. }
  1042. if ($allow["SMILES"]=="Y")
  1043. {
  1044. if (count($this->smiles) > 0)
  1045. {
  1046. $arPattern = array();
  1047. $arReplace = array();
  1048. foreach ($this->smiles as $a_id => $row)
  1049. {
  1050. //$code = str_replace(array(chr(34), chr(39)), array(chr(11), chr(12)), $row["TYPING"]);
  1051. //$image = str_replace(array(chr(34), chr(39)), array(chr(11), chr(12)), $row["IMAGE"]);
  1052. $code = str_replace(Array("'", "<", ">"), Array("\\'", "&lt;", "&gt;"), $row["TYPING"]);
  1053. $patt = preg_quote($code, "/");
  1054. $code = preg_quote(str_replace(array("\x5C"), array("&#092;"), $code));
  1055. $image = preg_quote(str_replace("'", "\\'", $row["IMAGE"]));
  1056. $description = preg_quote(htmlspecialcharsbx($row["DESCRIPTION"], ENT_QUOTES), "/");
  1057. $arPattern[] = "/(?<=[^\w&])$patt(?=.\W|\W.|\W$)/ei".FX_UTF_PCRE_MODIFIER;
  1058. $arReplace[] = "\$this->convert_emoticon('$code', '$image', '$description', '$serverName')";
  1059. }
  1060. if (!empty($arPattern))
  1061. $text = preg_replace($arPattern, $arReplace, ' '.$text.' ');
  1062. }
  1063. }
  1064. if ($this->preg["counter"] > 0)
  1065. $text = str_replace($this->preg["pattern"], $this->preg["replace"], $text);
  1066. $text = str_replace(array(chr(11), chr(12)), array(chr(34), chr(39)), $text);
  1067. return trim($text);
  1068. }
  1069. function defended_tags($text, $tag = 'replace')
  1070. {
  1071. switch ($tag) {
  1072. case "replace":
  1073. $this->preg["pattern"][] = "<\017#".$this->preg["counter"].">";
  1074. $this->preg["replace"][] = $text;
  1075. $text = "<\017#".$this->preg["counter"].">";
  1076. $this->preg["counter"]++;
  1077. break;
  1078. }
  1079. return $text;
  1080. }
  1081. function killAllTags($text)
  1082. {
  1083. $text = strip_tags($text);
  1084. $text = preg_replace(
  1085. array(
  1086. "/\<(\/?)(quote|code|font|color|video|td|tr|table)([^\>]*)\>/is".FX_UTF_PCRE_MODIFIER,
  1087. "/\[(\/?)(b|u|i|s|list|code|quote|font|color|url|img|video|td|tr|table)([^\]]*)\]/is".FX_UTF_PCRE_MODIFIER),
  1088. "",
  1089. $text);
  1090. return $text;
  1091. }
  1092. function convert4mail($text, $arImages = Array())
  1093. {
  1094. $text = Trim($text);
  1095. if (strlen($text)<=0) return "";
  1096. $arPattern = array();
  1097. $arReplace = array();
  1098. $arPattern[] = "/\[(code|quote)(.*?)\]/is".FX_UTF_PCRE_MODIFIER;
  1099. $arReplace[] = "\n>================== \\1 ===================\n";
  1100. $arPattern[] = "/\[\/(code|quote)(.*?)\]/is".FX_UTF_PCRE_MODIFIER;
  1101. $arReplace[] = "\n>===========================================\n";
  1102. $arPattern[] = "/\<WBR[\s\/]?\>/is".FX_UTF_PCRE_MODIFIER;
  1103. $arReplace[] = "";
  1104. $arPattern[] = "/^(\r|\n)+?(.*)$/";
  1105. $arReplace[] = "\\2";
  1106. $arPattern[] = "/\[b\](.+?)\[\/b\]/is".FX_UTF_PCRE_MODIFIER;
  1107. $arReplace[] = "\\1";
  1108. $arPattern[] = "/\[i\](.+?)\[\/i\]/is".FX_UTF_PCRE_MODIFIER;
  1109. $arReplace[] = "\\1";
  1110. $arPattern[] = "/\[u\](.+?)\[\/u\]/is".FX_UTF_PCRE_MODIFIER;
  1111. $arReplace[] = "_\\1_";
  1112. $arPattern[] = "/\[s\](.+?)\[\/s\]/is".FX_UTF_PCRE_MODIFIER;
  1113. $arReplace[] = "_\\1_";
  1114. $arPattern[] = "/\[(\/?)(color|font|size)([^\]]*)\]/is".FX_UTF_PCRE_MODIFIER;
  1115. $arReplace[] = "";
  1116. $arPattern[] = "/\[url\](\S+?)\[\/url\]/is".FX_UTF_PCRE_MODIFIER;
  1117. $arReplace[] = "(URL: \\1)";
  1118. $arPattern[] = "/\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]/is".FX_UTF_PCRE_MODIFIER;
  1119. $arReplace[] = "\\2 (URL: \\1)";
  1120. $arPattern[] = "/\[img\](.+?)\[\/img\]/is".FX_UTF_PCRE_MODIFIER;
  1121. $arReplace[] = "(IMAGE: \\1)";
  1122. $arPattern[] = "/\[video([^\]]*)\](.+?)\[\/video[\s]*\]/is".FX_UTF_PCRE_MODIFIER;
  1123. $arReplace[] = "(VIDEO: \\2)";
  1124. $arPattern[] = "/\[(\/?)list\]/is".FX_UTF_PCRE_MODIFIER;
  1125. $arReplace[] = "\n";
  1126. $text = preg_replace($arPattern, $arReplace, $text);
  1127. $text = str_replace("&shy;", "", $text);
  1128. $dbSite = CSite::GetByID(SITE_ID);
  1129. $arSite = $dbSite -> Fetch();
  1130. $serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]);
  1131. if (strlen($serverName) <=0)
  1132. {
  1133. if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME)>0)
  1134. $serverName = SITE_SERVER_NAME;
  1135. else
  1136. $serverName = COption::GetOptionString("main", "server_name", "www.freetrixsoft.com");
  1137. }
  1138. while (is_array($arImages) && list($IMAGE_ID, $FILE_ID)=each($arImages))
  1139. {
  1140. $f = CBlogImage::GetByID($IMAGE_ID);
  1141. if($arS = CFile::GetFileArray($FILE_ID))
  1142. {
  1143. if(substr($arS["SRC"], 0, 1) == "/")
  1144. $fileSrc = "http://".$serverName.$arS["SRC"];
  1145. else
  1146. $fileSrc = $arS["SRC"];
  1147. $text = str_replace("[IMG ID=$IMAGE_ID]", htmlspecialcharsbx($f["TITLE"])." (IMG: ".$fileSrc." )", $text);
  1148. $text = str_replace("[img id=$IMAGE_ID]", htmlspecialcharsbx($f["TITLE"])." (IMG: ".$fileSrc." )", $text);
  1149. }
  1150. }
  1151. return $text;
  1152. }
  1153. function convert_video($params, $path)
  1154. {
  1155. if (strLen($path) <= 0)
  1156. return "";
  1157. $width = ""; $height = ""; $preview = "";
  1158. preg_match("/width\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $params, $width);
  1159. preg_match("/height\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $params, $height);
  1160. $params = str_replace(array(chr(11), chr(12)), array("\001", "\002"), $params);
  1161. preg_match("/preview\=\002([^\002]+)\002/is".FX_UTF_PCRE_MODIFIER, $params, $preview);
  1162. if (empty($preview))
  1163. preg_match("/preview\=\001([^\001]+)\001/is".FX_UTF_PCRE_MODIFIER, $params, $preview);
  1164. $width = intval($width[1]);
  1165. $width = ($width > 0 ? $width : 400);
  1166. $height = intval($height[1]);
  1167. $height = ($height > 0 ? $height : 300);
  1168. $preview = trim($preview[1]);
  1169. $preview = (strLen($preview) > 0 ? $preview : "");
  1170. $arFields = Array(
  1171. "PATH" => $path,
  1172. "WIDTH" => $width,
  1173. "HEIGHT" => $height,
  1174. "PREVIEW" => $preview,
  1175. );
  1176. $db_events = GetModuleEvents("blog", "videoConvert");
  1177. if ($arEvent = $db_events->Fetch())
  1178. $video = ExecuteModuleEventEx($arEvent, Array($arFields));
  1179. if(strlen($video) > 0)
  1180. return "<nomodify>".$video."</nomodify>";
  1181. return false;
  1182. }
  1183. function convert_emoticon($code = "", $image = "", $description = "", $servername = "")
  1184. {
  1185. if (strlen($code)<=0 || strlen($image)<=0) return;
  1186. $code = stripslashes($code);
  1187. $description = stripslashes($description);
  1188. $image = stripslashes($image);
  1189. $alt = "<\018#".$this->preg["counter"].">";
  1190. $this->preg["pattern"][] = $alt;
  1191. $this->preg["replace"][] = 'alt="smile'.$code.'" title="'.$description.'"';
  1192. $this->preg["counter"]++;
  1193. if ($this->path_to_smile !== false)
  1194. return '<img src="'.$servername.$this->path_to_smile.$image.'" border="0" '.$alt.' />';
  1195. return '<img src="'.$servername.'/freetrix/images/blog/smile/'.$image.'" border="0" '.$alt.' />';
  1196. }
  1197. function pre_convert_code_tag ($text = "")
  1198. {
  1199. if (strLen($text)<=0) return;
  1200. $text = str_replace(
  1201. array("&", "<", ">", "[", "]", "\001", "\002"),
  1202. array("&#38;", "&#60;", "&#62;", "&#91;", "&#93;", "&#91;code&#93;", "&#91;/code&#93;"), $text);
  1203. $word_separator = str_replace("\]", "", $this->word_separator);
  1204. $text = preg_replace("'(?<=^|[".$word_separator."]|\s)((http|https|news|ftp|aim|mailto)://[\.\-\_\:a-z0-9\@]([^\011\s\'\012\[\]\{\}])*)'is",
  1205. "[nomodify]\\1[/nomodify]", $text);
  1206. return $text;
  1207. }
  1208. function convert_code_tag($text = "", $type = "html", $allowHTML = false)
  1209. {
  1210. if (strLen($text)<=0) return;
  1211. $type = ($type == "rss" ? "rss" : "html");
  1212. $text = str_replace(Array("[nomodify]", "[/nomodify]"), Array("", ""), $text);
  1213. //if(!$allowHTML)
  1214. //{
  1215. $text = str_replace(
  1216. array("<", ">", "\\r", "\\n", "\\", "[", "]", "\001", "\002", " ", "\t"),
  1217. array("&#60;", "&#62;", "&#92;r", "&#92;n", "&#92;", "&#91;", "&#93;", "&#91;code&#93;", "&#91;/code&#93;", "&nbsp;&nbsp;", "&nbsp;&nbsp;&nbsp;"), $text);
  1218. $text = stripslashes($text);
  1219. //}
  1220. if ($this->code_open == $this->code_closed && $this->code_error == 0)
  1221. {
  1222. $this->preg["pattern"][] = "<\017#".$this->preg["counter"].">";
  1223. $this->preg["replace"][] = $this->convert_open_tag('code', $type).$text.$this->convert_close_tag('code', $type);
  1224. $text = "<\017#".$this->preg["counter"].">";
  1225. $this->preg["counter"]++;
  1226. }
  1227. return $text;
  1228. }
  1229. function convert_quote_tag($text = "", $type = "html")
  1230. {
  1231. if (strlen($text)<=0) return;
  1232. $txt = $text;
  1233. $type = ($type == "rss" ? "rss" : "html");
  1234. $txt = preg_replace(
  1235. array(
  1236. "/\[quote([^\]\<\>])*\]/ie".FX_UTF_PCRE_MODIFIER,
  1237. "/\[\/quote([^\]\<\>])*\]/ie".FX_UTF_PCRE_MODIFIER),
  1238. array(
  1239. "\$this->convert_open_tag('quote', \$type)",
  1240. "\$this->convert_close_tag('quote', \$type)"), $txt);
  1241. if (($this->quote_open==$this->quote_closed) && ($this->quote_error==0))
  1242. return $txt;
  1243. return $text;
  1244. }
  1245. function convert_open_tag($marker = "quote", $type = "html")
  1246. {
  1247. $marker = (strToLower($marker) == "code" ? "code" : "quote");
  1248. $type = ($type == "rss" ? "rss" : "html");
  1249. $this->{$marker."_open"}++;
  1250. if ($type == "rss")
  1251. return "\n====".$marker."====\n";
  1252. return "<div class='blog-post-".$marker."'><span>".GetMessage("BLOG_".ToUpper($marker))."</span><table class='blog".$marker."'><tr><td>".$text;
  1253. }
  1254. function convert_close_tag($marker = "quote", $type = "html")
  1255. {
  1256. $marker = (strToLower($marker) == "code" ? "code" : "quote");
  1257. $type = ($type == "rss" ? "rss" : "html");
  1258. if ($this->{$marker."_open"} == 0)
  1259. {
  1260. $this->{$marker."_error"}++;
  1261. return;
  1262. }
  1263. $this->{$marker."_closed"}++;
  1264. if ($type == "rss")
  1265. return "\n=============\n";
  1266. return "</td></tr></tbody></table></div>";
  1267. }
  1268. function convert_image_tag($url = "", $type = "html", $serverName="", $params = "")
  1269. {
  1270. $url = trim($url);
  1271. if (strlen($url)<=0) return;
  1272. $type = (strToLower($type) == "rss" ? "rss" : "html");
  1273. $extension = preg_replace("/^.*\.(\S+)$/".FX_UTF_PCRE_MODIFIER, "\\1", $url);
  1274. $extension = strtolower($extension);
  1275. $extension = preg_quote($extension, "/");
  1276. preg_match("/width\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $params, $width);
  1277. preg_match("/height\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $params, $height);
  1278. $width = intval($width[1]);
  1279. $height = intval($height[1]);
  1280. $bErrorIMG = False;
  1281. if (preg_match("/[?&;]/".FX_UTF_PCRE_MODIFIER, $url))
  1282. $bErrorIMG = True;
  1283. if (!$bErrorIMG && !preg_match("/$extension(\||\$)/".FX_UTF_PCRE_MODIFIER, $this->allow_img_ext))
  1284. $bErrorIMG = True;
  1285. if (!$bErrorIMG && !preg_match("/^(http|https|ftp|\/)/i".FX_UTF_PCRE_MODIFIER, $url))
  1286. $bErrorIMG = True;
  1287. if ($bErrorIMG)
  1288. return "[img]".$url."[/img]";
  1289. $strPar = "";
  1290. if($width > 0)
  1291. {
  1292. if($width > $this->imageWidth)
  1293. {
  1294. $height = IntVal($height * ($this->imageWidth / $width));
  1295. $width = $this->imageWidth;
  1296. }
  1297. }
  1298. if($height > 0)
  1299. {
  1300. if($height > $this->imageHeight)
  1301. {
  1302. $width = IntVal($width * ($this->imageHeight / $height));
  1303. $height = $this->imageHeight;
  1304. }
  1305. }
  1306. if($width > 0)
  1307. $strPar = " width=\"".$width."\"";
  1308. if($height > 0)
  1309. $strPar .= " height=\"".$height."\"";
  1310. if(strlen($serverName) <= 0 || preg_match("/^(http|https|ftp)\:\/\//i".FX_UTF_PCRE_MODIFIER, $url))
  1311. return '<img src="'.$url.'" border="0"'.$strPar.' />';
  1312. else
  1313. return '<img src="'.$serverName.$url.'" border="0"'.$strPar.' />';
  1314. }
  1315. function convert_blog_image($p1 = "", $imageId = "", $p2 = "", $type = "html", $serverName="")
  1316. {
  1317. $imageId = IntVal($imageId);
  1318. if($imageId <= 0)
  1319. return;
  1320. $res = "";
  1321. if(IntVal($this->arImages[$imageId]) > 0)
  1322. {
  1323. if($f = CBlogImage::GetByID($imageId))
  1324. {
  1325. if($db_img_arr = CFile::GetFileArray($this->arImages[$imageId]))
  1326. {
  1327. $strImage = $db_img_arr["SRC"];
  1328. $strPar = "";
  1329. preg_match("/width\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $p1, $width);
  1330. preg_match("/height\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $p1, $height);
  1331. $width = intval($width[1]);
  1332. $height = intval($height[1]);
  1333. if($width <= 0)
  1334. {
  1335. preg_match("/width\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $p2, $width);
  1336. $width = intval($width[1]);
  1337. }
  1338. if($height <= 0)
  1339. {
  1340. preg_match("/height\=([0-9]+)/is".FX_UTF_PCRE_MODIFIER, $p2, $height);
  1341. $height = intval($height[1]);
  1342. }
  1343. if(IntVal($width) <= 0)
  1344. $width = $db_img_arr["WIDTH"];
  1345. if(IntVal($height) <= 0)
  1346. $height= $db_img_arr["HEIGHT"];
  1347. if($width > $this->imageWidth || $height > $this->imageHeight)
  1348. {
  1349. $arFileTmp = CFile::ResizeImageGet(
  1350. $db_img_arr,
  1351. array("width" => $this->imageWidth, "height" => $this->imageHeight),
  1352. FX_RESIZE_IMAGE_PROPORTIONAL,
  1353. true
  1354. );
  1355. if(substr($arFileTmp["src"], 0, 1) == "/")
  1356. $strImage = $serverName.$arFileTmp["src"];
  1357. else
  1358. $strImage = $arFileTmp["src"];
  1359. $width = $arFileTmp["width"];
  1360. $height = $arFileTmp["height"];
  1361. }
  1362. $strPar = ' width="'.$width.'" height="'.$height.'"';
  1363. $res = '<img src="'.$strImage.'" title="'.$f["TITLE"].'" border="0"'.$strPar.'/>';
  1364. }
  1365. }
  1366. }
  1367. return $res;
  1368. }
  1369. function convert_font_attr($attr, $value = "", $text = "")
  1370. {
  1371. if (strlen($text)<=0) return "";
  1372. if (strlen($value)<=0) return $text;
  1373. if ($attr == "size")
  1374. {
  1375. $count = count($this->arFontSize);
  1376. if ($count <= 0)
  1377. return $text;
  1378. $value = intVal($value >= $count ? ($count - 1) : $value);
  1379. return '<span style="font-size:'.$this->arFontSize[$value].'%;">'.$text.'</span>';
  1380. }
  1381. else if ($attr == 'color')
  1382. {
  1383. $value = preg_replace("/[^\w#]/", "" , $value);
  1384. return '<span style="color:'.$value.'">'.$text.'</span>';
  1385. }
  1386. else if ($attr == 'font')
  1387. {
  1388. $value = preg_replace("/[^\w]/", "" , $value);
  1389. return '<span style="font-family:'.$value.'">'.$text.'</span>';
  1390. }
  1391. }
  1392. // Only for public using
  1393. function wrap_long_words($text="")
  1394. {
  1395. if ($this->MaxStringLen > 0 && !empty($text))
  1396. {
  1397. $text = str_replace(array(chr(11), chr(12), chr(34), chr(39)), array("", "", chr(11), chr(12)), $text);
  1398. $text = preg_replace("/(?<=^|\>)([^\<]+)(?=\<|$)/ies".FX_UTF_PCRE_MODIFIER, "\$this->part_long_words('\\1')", $text);
  1399. $text = str_replace(array(chr(11), chr(12)), array(chr(34), chr(39)), $text);
  1400. }
  1401. return $text;
  1402. }
  1403. function part_long_words($str)
  1404. {
  1405. $word_separator = $this->word_separator;
  1406. if (($this->MaxStringLen > 0) && (strLen(trim($str)) > 0))
  1407. {
  1408. $str = str_replace(
  1409. array(chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7), chr(8),
  1410. "&amp;", "&lt;", "&gt;", "&quot;", "&nbsp;", "&copy;", "&reg;", "&trade;",
  1411. chr(34), chr(39)),
  1412. array("", "", "", "", "", "", "", "",
  1413. chr(1), "<", ">", chr(2), chr(3), chr(4), chr(5), chr

Large files files are truncated, but you can click here to view the full file