frame.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: frame.php 1059 2011-03-01 07:25:09Z monkey $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class control extends adminbase {
  9. var $members;
  10. var $apps;
  11. var $friends;
  12. function __construct() {
  13. $this->control();
  14. }
  15. function control() {
  16. parent::__construct();
  17. }
  18. function onindex() {
  19. $this->view->assign('sid', $this->view->sid);
  20. $mainurl = getgpc('mainurl');
  21. $mainurl = !empty($mainurl) && preg_match("/^admin\.php\?(&*\w+=\w+)*$/i", $mainurl) ? $mainurl : 'admin.php?m=frame&a=main&sid='.$this->view->sid;
  22. $this->view->assign('mainurl', $mainurl);
  23. $this->view->display('admin_frame_index');
  24. }
  25. function onmain() {
  26. $ucinfo = '';
  27. $this->view->assign('ucinfo', $ucinfo);
  28. $members = $this->_get_uc_members();
  29. $applist = $this->_get_uc_apps();
  30. $notes = $this->_get_uc_notes();
  31. $errornotes = $this->_get_uc_errornotes($applist);
  32. $pms = $this->_get_uc_pms();
  33. $apps = count($applist);
  34. $friends = $this->_get_uc_friends();
  35. $this->view->assign('members', $members);
  36. $this->view->assign('applist', $applist);
  37. $this->view->assign('apps', $apps);
  38. $this->view->assign('friends', $friends);
  39. $this->view->assign('notes', $notes);
  40. $this->view->assign('errornotes', $errornotes);
  41. $this->view->assign('pms', $pms);
  42. $this->view->assign('iframe', getgpc('iframe', 'G'));
  43. $serverinfo = PHP_OS.' / PHP v'.PHP_VERSION;
  44. $serverinfo .= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
  45. $dbversion = $this->db->result_first("SELECT VERSION()");
  46. $fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : '<font color="red">'.$lang['no'].'</font>';
  47. $dbsize = 0;
  48. $tablepre = UC_DBTABLEPRE;
  49. $query = $tables = $this->db->fetch_all("SHOW TABLE STATUS LIKE '$tablepre%'");
  50. foreach($tables as $table) {
  51. $dbsize += $table['Data_length'] + $table['Index_length'];
  52. }
  53. $dbsize = $dbsize ? $this->_sizecount($dbsize) : $lang['unknown'];
  54. $magic_quote_gpc = get_magic_quotes_gpc() ? 'On' : 'Off';
  55. $allow_url_fopen = ini_get('allow_url_fopen') ? 'On' : 'Off';
  56. $this->view->assign('serverinfo', $serverinfo);
  57. $this->view->assign('fileupload', $fileupload);
  58. $this->view->assign('dbsize', $dbsize);
  59. $this->view->assign('dbversion', $dbversion);
  60. $this->view->assign('magic_quote_gpc', $magic_quote_gpc);
  61. $this->view->assign('allow_url_fopen', $allow_url_fopen);
  62. $this->view->display('admin_frame_main');
  63. }
  64. function onmenu() {
  65. $this->view->display('admin_frame_menu');
  66. }
  67. function onheader() {
  68. $this->load('app');
  69. $applist = $_ENV['app']->get_apps();
  70. $cparray = array(
  71. 'UCHOME' => 'admincp.php',
  72. 'DISCUZ' => 'admincp.php',
  73. 'SUPESITE' => 'admincp.php',
  74. 'XSPACE' => 'admincp.php',
  75. 'SUPEV' => 'admincp.php',
  76. 'ECSHOP' => 'admin/index.php',
  77. 'ECMALL' => 'admin.php'
  78. );
  79. $admincp = '';
  80. if(is_array($applist)) {
  81. foreach($applist AS $k => $app) {
  82. if(isset($cparray[$app['type']])) {
  83. $admincp .= '<li><a href="'.(substr($app['url'], -1) == '/' ? $app['url'] : $app['url'].'/').$cparray[$app['type']].'" target="_blank">'.$app['name'].'</a></li>';
  84. }
  85. }
  86. }
  87. $this->view->assign('admincp', $admincp);
  88. $this->view->assign('username', $this->user['username']);
  89. $this->view->display('admin_frame_header');
  90. }
  91. function _get_uc_members() {
  92. if(!$this->members) {
  93. $this->members = $this->db->result_first("SELECT COUNT(*) FROM ".UC_DBTABLEPRE."members");
  94. }
  95. return $this->members;
  96. }
  97. function _get_uc_friends() {
  98. $friends = $this->db->result_first("SELECT COUNT(*) FROM ".UC_DBTABLEPRE."friends");
  99. return $friends;
  100. }
  101. function _get_uc_apps() {
  102. if(!$this->apps) {
  103. $this->apps = $this->db->fetch_all("SELECT * FROM ".UC_DBTABLEPRE."applications");
  104. }
  105. return $this->apps;
  106. }
  107. function _get_uc_pms() {
  108. $pms = 0;
  109. for($i = 0; $i < 10; $i++) {
  110. $pms += $this->db->result_first("SELECT COUNT(*) FROM ".UC_DBTABLEPRE."pm_messages_".(string)$i);
  111. }
  112. return $pms;
  113. }
  114. function _get_uc_notes() {
  115. $notes = $this->db->result_first("SELECT COUNT(*) FROM ".UC_DBTABLEPRE."notelist WHERE closed='0'");
  116. return $notes;
  117. }
  118. function _get_uc_errornotes($applist) {
  119. $notelist = $this->db->fetch_all("SELECT * FROM ".UC_DBTABLEPRE."notelist ORDER BY dateline DESC LIMIT 20");
  120. $error = array();
  121. foreach($notelist as $note) {
  122. foreach($applist as $k => $app) {
  123. if($note['app'.$app['appid']] < 0) {
  124. $error[$k]++;
  125. }
  126. }
  127. }
  128. return $error;
  129. }
  130. function _sizecount($filesize) {
  131. if($filesize >= 1073741824) {
  132. $filesize = round($filesize / 1073741824 * 100) / 100 . ' GB';
  133. } elseif($filesize >= 1048576) {
  134. $filesize = round($filesize / 1048576 * 100) / 100 . ' MB';
  135. } elseif($filesize >= 1024) {
  136. $filesize = round($filesize / 1024 * 100) / 100 . ' KB';
  137. } else {
  138. $filesize = $filesize . ' Bytes';
  139. }
  140. return $filesize;
  141. }
  142. function _get_uc_info() {
  143. $update = array('uniqueid' => UC_SITEID, 'version' => UC_SERVER_VERSION, 'release' => UC_SERVER_RELEASE, 'php' => PHP_VERSION, 'mysql' => $this->db->version(), 'charset' => UC_CHARSET);
  144. $updatetime = @filemtime(UC_ROOT.'./data/updatetime.lock');
  145. if(empty($updatetime) || ($this->time - $updatetime > 3600 * 4)) {
  146. @touch(UC_ROOT.'./data/updatetime.lock');
  147. $update['members'] = $this->_get_uc_members();
  148. $update['friends'] = $this->_get_uc_friends();
  149. $apps = $this->_get_uc_apps();
  150. if($apps) {
  151. foreach($apps as $app) {
  152. $update['app_'.$app['appid']] = $app['name']."\t".$app['url']."\t".$app['type'];
  153. }
  154. }
  155. }
  156. $data = '';
  157. foreach($update as $key => $value) {
  158. $data .= $key.'='.rawurlencode($value).'&';
  159. }
  160. return 'update='.rawurlencode(base64_encode($data)).'&md5hash='.substr(md5($_SERVER['HTTP_USER_AGENT'].implode('', $update).$this->time), 8, 8).'&timestamp='.$this->time;
  161. }
  162. }
  163. ?>