index.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: index.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', dirname(__FILE__).'/');
  15. define('UC_API', strtolower(($_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. if(!@include UC_DATADIR.'config.inc.php') {
  28. exit('The file <b>data/config.inc.php</b> does not exist, perhaps because of UCenter has not been installed, <a href="install/index.php"><b>Please click here to install it.</b></a>.');
  29. }
  30. $m = getgpc('m');
  31. $a = getgpc('a');
  32. if(empty($m) && empty($a)) {
  33. header('Location: admin.php');
  34. exit;
  35. }
  36. define('RELEASE_ROOT', '');
  37. if(file_exists(UC_ROOT.RELEASE_ROOT.'model/base.php')) {
  38. require UC_ROOT.RELEASE_ROOT.'model/base.php';
  39. } else {
  40. require UC_ROOT.'model/base.php';
  41. }
  42. if(in_array($m, array('app', 'frame', 'user', 'pm', 'pm_client', 'tag', 'feed', 'friend', 'domain', 'credit', 'mail', 'version'))) {
  43. if(file_exists(UC_ROOT.RELEASE_ROOT."control/$m.php")) {
  44. include UC_ROOT.RELEASE_ROOT."control/$m.php";
  45. } else {
  46. include UC_ROOT."control/$m.php";
  47. }
  48. $classname = $m.'control';
  49. $control = new $classname();
  50. $method = 'on'.$a;
  51. if(method_exists($control, $method) && $a{0} != '_') {
  52. $data = $control->$method();
  53. echo is_array($data) ? $control->serialize($data, 1) : $data;
  54. exit;
  55. } elseif(method_exists($control, '_call')) {
  56. $data = $control->_call('on'.$a, '');
  57. echo is_array($data) ? $control->serialize($data, 1) : $data;
  58. exit;
  59. } else {
  60. exit('Action not found!');
  61. }
  62. } else {
  63. exit('Module not found!');
  64. }
  65. $mtime = explode(' ', microtime());
  66. $endtime = $mtime[1] + $mtime[0];
  67. function daddslashes($string, $force = 0, $strip = FALSE) {
  68. if(!MAGIC_QUOTES_GPC || $force) {
  69. if(is_array($string)) {
  70. foreach($string as $key => $val) {
  71. $string[$key] = daddslashes($val, $force, $strip);
  72. }
  73. } else {
  74. $string = addslashes($strip ? stripslashes($string) : $string);
  75. }
  76. }
  77. return $string;
  78. }
  79. function getgpc($k, $var='R') {
  80. switch($var) {
  81. case 'G': $var = &$_GET; break;
  82. case 'P': $var = &$_POST; break;
  83. case 'C': $var = &$_COOKIE; break;
  84. case 'R': $var = &$_REQUEST; break;
  85. }
  86. return isset($var[$k]) ? $var[$k] : NULL;
  87. }
  88. function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) {
  89. $fp = '';
  90. if(function_exists('fsockopen')) {
  91. $fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout);
  92. } elseif(function_exists('pfsockopen')) {
  93. $fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout);
  94. } elseif(function_exists('stream_socket_client')) {
  95. $fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout);
  96. }
  97. return $fp;
  98. }
  99. function dhtmlspecialchars($string, $flags = null) {
  100. if(is_array($string)) {
  101. foreach($string as $key => $val) {
  102. $string[$key] = dhtmlspecialchars($val, $flags);
  103. }
  104. } else {
  105. if($flags === null) {
  106. $string = str_replace(array('&', '"', '<', '>'), array('&amp;', '&quot;', '&lt;', '&gt;'), $string);
  107. if(strpos($string, '&amp;#') !== false) {
  108. $string = preg_replace('/&amp;((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string);
  109. }
  110. } else {
  111. if(PHP_VERSION < '5.4.0') {
  112. $string = htmlspecialchars($string, $flags);
  113. } else {
  114. if(strtolower(CHARSET) == 'utf-8') {
  115. $charset = 'UTF-8';
  116. } else {
  117. $charset = 'ISO-8859-1';
  118. }
  119. $string = htmlspecialchars($string, $flags, $charset);
  120. }
  121. }
  122. }
  123. return $string;
  124. }
  125. ?>