PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/sys/plugins/classes/dcms.class.php

https://bitbucket.org/DESURE/dcms
PHP | 168 lines | 121 code | 21 blank | 26 comment | 17 complexity | 2c9cfb6938872ff5d343fe4465495bec MD5 | raw file
  1. <?php
  2. class dcms extends browser {
  3. protected $_counters = array();
  4. protected $_data = array();
  5. var $license;
  6. function __construct() {
  7. parent::__construct();
  8. // ???????? ????????
  9. $this->_load_settings();
  10. }
  11. /**
  12. * ???????? ????????? ?????????
  13. * @param string $mess
  14. * @param integer $group_min
  15. */
  16. public function distribution($mess, $group_min = 2) {
  17. $q = mysql_query("SELECT `id` FROM `users` WHERE `group` >= '" . intval($group_min) . "'");
  18. while ($ank = mysql_fetch_assoc($q)) {
  19. $ank = new user($ank['id']);
  20. $ank->mess($mess);
  21. }
  22. }
  23. /**
  24. * ?????? ???????? ?????????????? ??? ???????
  25. * @global type $user
  26. * @param type $module
  27. * @param type $description
  28. * @param type $is_system
  29. * @return type
  30. */
  31. public function log($module, $description, $is_system = false) {
  32. $id_user = 0;
  33. if (!$is_system) {
  34. global $user;
  35. $id_user = $user->id;
  36. }
  37. return mysql_query("INSERT INTO `action_list_administrators` (`id_user`, `time`, `module`, `description`)
  38. VALUES ('$id_user', '" . TIME . "', '" . my_esc($module) . "', '" . my_esc($description) . "')");
  39. }
  40. public function __call($name, $arg) {
  41. switch ($name) {
  42. case 'count':return $this->_count($arg[0]);
  43. default:return false;
  44. }
  45. }
  46. public function __get($name) {
  47. switch ($name) {
  48. case 'subdomain_main': return $this->_subdomain_main();
  49. break;
  50. case 'browser_type': return $this->_browser_type();
  51. break;
  52. case 'browser_id': return $this->browser_id();
  53. break;
  54. case 'items_per_page': return $this->_data['items_per_page_' . $this->browser_type];
  55. break;
  56. case 'img_max_width':return $this->_data['img_max_width_' . $this->browser_type];
  57. break;
  58. case 'widget_items_count':return $this->_data['widget_items_count_' . $this->browser_type];
  59. break;
  60. case 'theme':return $this->_data['theme_' . $this->browser_type];
  61. break;
  62. default:return empty($this->_data[$name]) ? false : $this->_data[$name];
  63. }
  64. }
  65. public function __set($name, $value) {
  66. switch ($name) {
  67. case 'items_per_page': $name .= '_' . $this->browser_type;
  68. break;
  69. case 'theme': $name .= '_' . $this->browser_type;
  70. break;
  71. case 'img_max_width': $name .= '_' . $this->browser_type;
  72. break;
  73. case 'widget_items_count': $name .= '_' . $this->browser_type;
  74. break;
  75. }
  76. $this->_data[$name] = $value;
  77. return true;
  78. }
  79. protected function _subdomain_main() {
  80. $domain = preg_replace('/^(wap|pda|web|www|i|touch|itouch)\./ui', '', $_SERVER['HTTP_HOST']);
  81. return $domain;
  82. }
  83. protected function _browser_type() {
  84. if ($this->subdomain_wap_enable) {
  85. if (0 === strpos($_SERVER['HTTP_HOST'], $this->subdomain_wap . '.')) {
  86. return 'wap';
  87. }
  88. }
  89. if ($this->subdomain_pda_enable) {
  90. if (0 === strpos($_SERVER['HTTP_HOST'], $this->subdomain_pda . '.')) {
  91. return 'pda';
  92. }
  93. }
  94. if ($this->subdomain_itouch_enable) {
  95. if (0 === strpos($_SERVER['HTTP_HOST'], $this->subdomain_itouch . '.')) {
  96. return 'itouch';
  97. }
  98. }
  99. if ($this->subdomain_web_enable) {
  100. if (0 === strpos($_SERVER['HTTP_HOST'], $this->subdomain_web . '.')) {
  101. return 'web';
  102. }
  103. }
  104. return $this->browser_type_auto;
  105. }
  106. // ????????
  107. protected function _count($item) {
  108. if (!isset($this->_counters[$item])) {
  109. switch ($item) {
  110. // ???-?? ?????????????
  111. case 'users': $this->_counters[$item] = mysql_result(mysql_query("SELECT COUNT(*) FROM `users`"), 0);
  112. break;
  113. // ???????????? ??????
  114. case 'users_online': $this->_counters[$item] = mysql_result(mysql_query("SELECT COUNT(*) FROM `users_online`"), 0);
  115. break;
  116. // ????? ??????
  117. case 'guest_online': $this->_counters[$item] = mysql_result(mysql_query("SELECT COUNT(*) FROM `guest_online` WHERE `conversions` >= '5'"), 0);
  118. break;
  119. default:$this->_counters[$item] = false;
  120. }
  121. }
  122. return $this->_counters[$item];
  123. }
  124. /**
  125. * ???????? ????????
  126. */
  127. protected function _load_settings() {
  128. $settings_default = ini::read(H . '/sys/inc/settings.default.ini', true) OR die('?????????? ????????? ???? ???????? ??-?????????');
  129. if (!$settings = ini::read(H . '/sys/ini/settings.ini')) {
  130. // ???? ????????? ?????? ?????????, ?? ??? ???? ???? ???? ?????????, ?? ???????????? ?? ????
  131. if (file_exists(H . '/install/index.php')) {
  132. header("Location: /install/");
  133. exit;
  134. } else
  135. exit('???? ???????? ?? ????? ???? ????????');
  136. }
  137. $this->_data = array_merge($settings_default['DEFAULT'], $this->_data, $settings, $settings_default['REPLACE']);
  138. }
  139. /**
  140. * ?????????? ????????
  141. * @return boolean
  142. */
  143. public function save_settings() {
  144. return ini::save(H . '/sys/ini/settings.ini', $this->_data);
  145. }
  146. }
  147. ?>