12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- date_default_timezone_set("PRC");
- require_once __DIR__ . '/../../../globals.php'; # 主项目全局配置
- require_once __DIR__ . '/../../../Amfphp/config.php'; # 主项目配置直接预加载
- require_once __DIR__ . '/../../../Amfphp/util/UtilInclude.php'; # 一部分Utils直接预加载
- require_once __DIR__ . '/Autoloader.php'; # 设置自动加载机制
- Autoloader::register();
- #
- #
- // <editor-fold defaultstate="collapsed">
- function array_pushs(&$array, $items) {
- $array = array_merge($array, $items);
- }
- function query_paras() {
- return \loyalsoft\HttpUtil::getQueryParas();
- }
- // </editor-fold>
- /**
- * get dao instance,
- * @version 2019年12月23日 经过梦幻星工场2一年多的使用, 未发现特别明显的bug. 决定侧重使用. -- 王刚
- * 2017.06.23 第一版 学习自禅道的开源框架. -- 王刚
- * @staticvar type $a
- * @return \dao 注意: dao并非什么好东西,只是一些改进尝试, 稳定性, 性能, 效率尚未得到证明.-gwang 2017.06.23
- */
- function daoInst() {
- static $a = null;
- if (is_null($a)) {
- $a = new \loyalsoft\dao(); # 结束请求的时候自动回收,无需主动写关闭代码
- $a->connectDB(\loyalsoft\config::Inst()); # 建立链接,传入配置文件
- }
- return $a;
- }
- /**
- * @return CRedisUtil 获取全局MEM单例
- */
- function gMem() {
- static $cmem = null;
- if ($cmem == null) {
- $cmem = new \loyalsoft\CRedisUtil();
- $nosql = \loyalsoft\config::Inst()->nosql;
- $cmem->conn($nosql->host, $nosql->port, $nosql->pwd);
- }
- return $cmem;
- }
- /**
- * 获取项目根路径(限制条件,本方法所在的文件也必须在项目根路径下wg)
- * @author gwang
- * @return string
- */
- function getRootURL() {
- $self = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']));
- $self = str_replace('\\', '/', $self);
- $uri = substr($self, 0, strrpos($self, '/app') + 1);
- $url = "http://" . $_SERVER['HTTP_HOST'] . $uri;
- return $url;
- }
- define("ROOT_URL", getRootURL());
- function getPageUrl($tag) {
- if ($tag == "login" || $tag == "index") {
- return ROOT_URL . "home/" . $tag . ".html";
- } else {
- return ROOT_URL . "home/pages/" . $tag . "/" . $tag . ".html";
- }
- }
|