main.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. date_default_timezone_set("PRC");
  3. require_once __DIR__ . '/../../../globals.php'; # 主项目全局配置
  4. require_once __DIR__ . '/../../../Amfphp/config.php'; # 主项目配置直接预加载
  5. require_once __DIR__ . '/../../../Amfphp/util/UtilInclude.php'; # 一部分Utils直接预加载
  6. require_once __DIR__ . '/Autoloader.php'; # 设置自动加载机制
  7. Autoloader::register();
  8. #
  9. #
  10. // <editor-fold defaultstate="collapsed">
  11. function array_pushs(&$array, $items) {
  12. $array = array_merge($array, $items);
  13. }
  14. function query_paras() {
  15. return \loyalsoft\HttpUtil::getQueryParas();
  16. }
  17. // </editor-fold>
  18. /**
  19. * get dao instance,
  20. * @version 2019年12月23日 经过梦幻星工场2一年多的使用, 未发现特别明显的bug. 决定侧重使用. -- 王刚
  21. * 2017.06.23 第一版 学习自禅道的开源框架. -- 王刚
  22. * @staticvar type $a
  23. * @return \dao 注意: dao并非什么好东西,只是一些改进尝试, 稳定性, 性能, 效率尚未得到证明.-gwang 2017.06.23
  24. */
  25. function daoInst() {
  26. static $a = null;
  27. if (is_null($a)) {
  28. $a = new \loyalsoft\dao(); # 结束请求的时候自动回收,无需主动写关闭代码
  29. $a->connectDB(\loyalsoft\config::Inst()); # 建立链接,传入配置文件
  30. }
  31. return $a;
  32. }
  33. /**
  34. * @return CRedisUtil 获取全局MEM单例
  35. */
  36. function gMem() {
  37. static $cmem = null;
  38. if ($cmem == null) {
  39. $cmem = new \loyalsoft\CRedisUtil();
  40. $nosql = \loyalsoft\config::Inst()->nosql;
  41. $cmem->conn($nosql->host, $nosql->port, $nosql->pwd);
  42. }
  43. return $cmem;
  44. }
  45. /**
  46. * 获取项目根路径(限制条件,本方法所在的文件也必须在项目根路径下wg)
  47. * @author gwang
  48. * @return string
  49. */
  50. function getRootURL() {
  51. $self = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']));
  52. $self = str_replace('\\', '/', $self);
  53. $uri = substr($self, 0, strrpos($self, '/app') + 1);
  54. $url = "http://" . $_SERVER['HTTP_HOST'] . $uri;
  55. return $url;
  56. }
  57. define("ROOT_URL", getRootURL());
  58. function getPageUrl($tag) {
  59. if ($tag == "login" || $tag == "index") {
  60. return ROOT_URL . "home/" . $tag . ".html";
  61. } else {
  62. return ROOT_URL . "home/pages/" . $tag . "/" . $tag . ".html";
  63. }
  64. }