admin.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: admin.php 1139 2012-05-08 09:02:11Z liulanbo $
  6. */
  7. error_reporting(0);
  8. if(function_exists('set_magic_quotes_runtime')) {
  9. set_magic_quotes_runtime(0);
  10. }
  11. $mtime = explode(' ', microtime());
  12. $starttime = $mtime[1] + $mtime[0];
  13. define('IN_UC', TRUE);
  14. define('UC_ROOT', substr(__FILE__, 0, -9));
  15. define('UC_API', strtolower((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))));
  16. define('UC_DATADIR', UC_ROOT.'data/');
  17. define('UC_DATAURL', UC_API.'/data');
  18. define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
  19. unset($GLOBALS, $_ENV, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_ENV_VARS);
  20. $_GET = daddslashes($_GET, 1, TRUE);
  21. $_POST = daddslashes($_POST, 1, TRUE);
  22. $_COOKIE = daddslashes($_COOKIE, 1, TRUE);
  23. $_SERVER = daddslashes($_SERVER);
  24. $_FILES = daddslashes($_FILES);
  25. $_REQUEST = daddslashes($_REQUEST, 1, TRUE);
  26. require UC_ROOT.'./release/release.php';
  27. require UC_DATADIR.'config.inc.php';
  28. require UC_ROOT.'model/base.php';
  29. require UC_ROOT.'model/admin.php';
  30. $m = getgpc('m');
  31. $a = getgpc('a');
  32. $m = empty($m) ? 'frame' : $m;
  33. $a = empty($a) ? 'index' : $a;
  34. define('RELEASE_ROOT', '');
  35. header('Content-Type: text/html; charset='.CHARSET);
  36. if(in_array($m, array('admin', 'app', 'badword', 'cache', 'db', 'domain', 'frame', 'log', 'note', 'feed', 'mail', 'setting', 'user', 'credit', 'seccode', 'tool', 'plugin', 'pm'))) {
  37. include UC_ROOT."control/admin/$m.php";
  38. $control = new control();
  39. $method = 'on'.$a;
  40. if(method_exists($control, $method) && $a{0} != '_') {
  41. $control->$method();
  42. } elseif(method_exists($control, '_call')) {
  43. $control->_call('on'.$a, '');
  44. } else {
  45. exit('Action not found!');
  46. }
  47. } else {
  48. exit('Module not found!');
  49. }
  50. $mtime = explode(' ', microtime());
  51. $endtime = $mtime[1] + $mtime[0];
  52. function daddslashes($string, $force = 0, $strip = FALSE) {
  53. if(!MAGIC_QUOTES_GPC || $force) {
  54. if(is_array($string)) {
  55. foreach($string as $key => $val) {
  56. $string[$key] = daddslashes($val, $force, $strip);
  57. }
  58. } else {
  59. $string = addslashes($strip ? stripslashes($string) : $string);
  60. }
  61. }
  62. return $string;
  63. }
  64. function getgpc($k, $t='R') {
  65. switch($t) {
  66. case 'P': $var = &$_POST; break;
  67. case 'G': $var = &$_GET; break;
  68. case 'C': $var = &$_COOKIE; break;
  69. case 'R': $var = &$_REQUEST; break;
  70. }
  71. return isset($var[$k]) ? (is_array($var[$k]) ? $var[$k] : trim($var[$k])) : NULL;
  72. }
  73. function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) {
  74. $fp = '';
  75. if(function_exists('fsockopen')) {
  76. $fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout);
  77. } elseif(function_exists('pfsockopen')) {
  78. $fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout);
  79. } elseif(function_exists('stream_socket_client')) {
  80. $fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout);
  81. }
  82. return $fp;
  83. }
  84. function dhtmlspecialchars($string, $flags = null) {
  85. if(is_array($string)) {
  86. foreach($string as $key => $val) {
  87. $string[$key] = dhtmlspecialchars($val, $flags);
  88. }
  89. } else {
  90. if($flags === null) {
  91. $string = str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $string);
  92. if(strpos($string, '&amp;#') !== false) {
  93. $string = preg_replace('/&amp;((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string);
  94. }
  95. } else {
  96. if(PHP_VERSION < '5.4.0') {
  97. $string = htmlspecialchars($string, $flags);
  98. } else {
  99. if(strtolower(CHARSET) == 'utf-8') {
  100. $charset = 'UTF-8';
  101. } else {
  102. $charset = 'ISO-8859-1';
  103. }
  104. $string = htmlspecialchars($string, $flags, $charset);
  105. }
  106. }
  107. }
  108. return $string;
  109. }
  110. ?>