runtime.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. header("Access-Control-Allow-Origin: *");
  3. include "define.php";
  4. /***
  5. * @param $classname
  6. */
  7. function anshee_autoload($classname)
  8. {
  9. $class_file = strtolower($classname) . ".php";
  10. require(LIBDIR . $class_file);
  11. if (class_exists('log_message')) {
  12. log_message::info("****function anshee_autoload::", LIBDIR . '/' . $class_file);
  13. }
  14. if (file_exists($class_file)) {
  15. require($class_file);
  16. // .mod require_once(LIBDIR_TWO.$class_file);
  17. } else {
  18. }
  19. }
  20. /***
  21. * @param $object
  22. * @return bool
  23. */
  24. function isBlank($object)
  25. {
  26. if (is_null($object) || '' === $object || (is_array($object) && count($object) < 1) || !isset($object)) {
  27. return true;
  28. }
  29. return empty($object);
  30. }
  31. /***
  32. * @param $object
  33. * @param null $key
  34. * @return bool
  35. */
  36. function isDatas($object, $key = null)
  37. {
  38. if (is_string($object) && !empty($object)) {
  39. return $object;
  40. log_message::info("is Data string ");
  41. }
  42. if (is_array($object) && !empty($object) && count($object) > ZERO && empty($key)) {
  43. log_message::info("is Data array ");
  44. return $object;
  45. }
  46. if (is_array($object) && !empty($key) && isset($object[$key]) && !empty($object[$key])) {
  47. log_message::info("is Data array key ");
  48. return $object[$key];
  49. }
  50. log_message::info("data is null", $key);
  51. return false;
  52. }
  53. function isPrimary($object)
  54. {
  55. return is_null($object) || is_bool($object) || is_string($object) || is_numeric($object);
  56. }
  57. function isSetData()
  58. {
  59. }
  60. function get_server_ip()
  61. {
  62. if (!empty($_SERVER['SERVER_ADDR']))
  63. return $_SERVER['SERVER_ADDR'];
  64. $result = shell_exec("/sbin/ifconfig");
  65. if (preg_match_all("/addr:(\d+\.\d+\.\d+\.\d+)/", $result, $match) !== 0) {
  66. foreach ($match[0] as $k => $v) {
  67. if ($match[1][$k] != "127.0.0.1")
  68. return $match[1][$k];
  69. }
  70. }
  71. return false;
  72. }
  73. function getIp()
  74. {
  75. if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
  76. $ip = getHostByName(php_uname('n'));
  77. return $ip;
  78. } else {
  79. return get_server_ip();
  80. }
  81. }
  82. //
  83. spl_autoload_register("anshee_autoload");