BxDolInstallerUtils.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. /**
  3. * @package Dolphin Core
  4. * @copyright Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  5. * @license CC-BY - http://creativecommons.org/licenses/by/3.0/
  6. */
  7. defined('BX_DOL') or die('hack attempt');
  8. bx_import('BxDolIO');
  9. class BxDolInstallerUtils extends BxDolIO {
  10. function BxDolInstallerUtils() {
  11. parent::BxDolIO();
  12. }
  13. function isXsltEnabled() {
  14. if (((int)phpversion()) >= 5) {
  15. if (class_exists ('DOMDocument') && class_exists ('XsltProcessor'))
  16. return true;
  17. } else {
  18. if (function_exists('domxml_xslt_stylesheet_file'))
  19. return true;
  20. elseif (function_exists ('xslt_create'))
  21. return true;
  22. }
  23. return false;
  24. }
  25. function isAllowUrlInclude() {
  26. if (version_compare(phpversion(), "5.2", ">") == 1) {
  27. $sAllowUrlInclude = ini_get('allow_url_include');
  28. return !($sAllowUrlInclude == 0);
  29. };
  30. return false;
  31. }
  32. function isModuleInstalled($sUri) {
  33. bx_import('BxDolModuleQuery');
  34. return BxDolModuleQuery::getInstance()->isModule($sUri);
  35. }
  36. function addHtmlFields ($a) {
  37. $this->_addFields ('html', $a);
  38. }
  39. function removeHtmlFields () {
  40. $this->_removeFields('html');
  41. }
  42. function addJsonFields ($a) {
  43. $this->_addFields ('json', $a);
  44. }
  45. function removeJsonFields () {
  46. $this->_removeFields('json');
  47. }
  48. function addExceptionsFields ($a) {
  49. $this->_addFields ('exceptions', $a);
  50. }
  51. function removeExceptionsFields () {
  52. $this->_removeFields('exceptions');
  53. }
  54. function updateSystemExceptions () {
  55. $s = getParam('sys_exceptions_fields');
  56. if (!$s) {
  57. $a = array ();
  58. } else {
  59. $a = unserialize($s);
  60. unset($a['system']);
  61. }
  62. $a['system'] = array(
  63. 'COOKIE.memberSession',
  64. );
  65. $s = serialize ($a);
  66. setParam ('sys_exceptions_fields', $s);
  67. // recreate cache
  68. $GLOBALS['MySQL']->cleanCache ('sys_exceptions_fields');
  69. $GLOBALS['MySQL']->fromCache ('sys_exceptions_fields', 'getOne', "SELECT `VALUE` FROM `sys_options` WHERE `Name` = 'sys_exceptions_fields' LIMIT 1");
  70. }
  71. function updateEmailTemplatesExceptions () {
  72. $s = getParam('sys_exceptions_fields');
  73. if (!$s) {
  74. $a = array ();
  75. } else {
  76. $a = unserialize($s);
  77. unset($a['system_email_templates']);
  78. }
  79. $a['system_email_templates'] = $this->_getEmailTemplatesHtmlFields();
  80. $s = serialize ($a);
  81. setParam ('sys_exceptions_fields', $s);
  82. // recreate cache
  83. $oDb = BxDolDb::getInstance();
  84. $oDb->cleanCache ('sys_exceptions_fields');
  85. $oDb->fromCache ('sys_exceptions_fields', 'getOne', "SELECT `VALUE` FROM `sys_options` WHERE `Name` = 'sys_exceptions_fields' LIMIT 1");
  86. }
  87. function updateProfileFieldsHtml () {
  88. $s = getParam('sys_html_fields');
  89. if (!$s) {
  90. $a = array ();
  91. } else {
  92. $a = unserialize($s);
  93. unset($a['system_profile_html']);
  94. }
  95. $a['system_profile_html'] = $this->_getSystemProfileHtmlFields();
  96. $s = serialize ($a);
  97. setParam ('sys_html_fields', $s);
  98. // recreate cache
  99. $oDb = BxDolDb::getInstance();
  100. $oDb->cleanCache ('sys_html_fields');
  101. $oDb->fromCache ('sys_html_fields', 'getOne', "SELECT `VALUE` FROM `sys_options` WHERE `Name` = 'sys_html_fields' LIMIT 1");
  102. }
  103. //--- Protected methods ---//
  104. function _getEmailTemplatesHtmlFields () {
  105. $oDb = BxDolDb::getInstance();
  106. $aRet = array ();
  107. $a = $oDb->getAll ("SELECT `Name` FROM `sys_email_templates`");
  108. foreach ($a as $r) {
  109. $aRet[] = 'POST.' . $r['Name'] . '_Body';
  110. $aRet[] = 'REQUEST.' . $r['Name'] . '_Body';
  111. $aRet[] = 'POST.' . $r['Name'] . '_Subject';
  112. $aRet[] = 'REQUEST.' . $r['Name'] . '_Subject';
  113. }
  114. return $aRet;
  115. }
  116. function _getSystemProfileHtmlFields () {
  117. $oDb = BxDolDb::getInstance();
  118. $aRet = array ();
  119. $a = $oDb->getAll ("SELECT `Name` FROM `sys_profile_fields` WHERE `Type` = 'html_area'");
  120. foreach ($a as $r) {
  121. $aRet[] = 'POST.' . $r['Name'];
  122. $aRet[] = 'REQUEST.' . $r['Name'];
  123. }
  124. return $aRet;
  125. }
  126. function _addFields ($sType, $a) {
  127. switch ($sType) {
  128. case 'html':
  129. case 'json':
  130. case 'exceptions':
  131. break;
  132. default:
  133. return array();
  134. }
  135. $s = getParam("sys_{$sType}_fields");
  136. if (!$s) {
  137. $a = array ($this->_aConfig['home_uri'] => $a);
  138. } else {
  139. $a = array_merge (unserialize($s), array ($this->_aConfig['home_uri'] => $a));
  140. }
  141. $s = serialize ($a);
  142. setParam ("sys_{$sType}_fields", $s);
  143. }
  144. function _removeFields ($sType) {
  145. switch ($sType) {
  146. case 'html':
  147. case 'json':
  148. case 'exceptions':
  149. break;
  150. default:
  151. return array();
  152. }
  153. $s = getParam("sys_{$sType}_fields");
  154. if (!$s) {
  155. return;
  156. }
  157. $a = unserialize($s);
  158. unset ($a[$this->_aConfig['home_uri']]);
  159. $s = serialize ($a);
  160. setParam ("sys_{$sType}_fields", $s);
  161. }
  162. }