<?php /** * 本脚本用于包含PUBLIC_DIR_NAME目录中的公共实体类,减少代码重复 * 可以在本目录中定义本开发成员私有的实体,但要注意实体名不能与公共实体类的相同 */ AiCore::parseXxxFormatFromDirAndAutoIncludeTheir(PUBLIC_DIR_NAME . '/core/' . ENTITY_DIR, 'entity');
/* * 自动包含开发者指定的常量配置目录 * 开发者应该把所需的库文件或目录放置到USER_CONST_DIRS常量所指定的 目录中。 */ AiCore::includePhpWithEveryLayer(USER_CONFIG_DIRS); /* * 自动包含其它库 * 开发者应该把所需的库文件或目录放置到USER_LIB_DIRS常量所指定的 目录中。 * 指定的目录内所有层次目录的*.php都会被包含。 */ AiCore::includePhpWithEveryLayer(USER_LIB_DIRS); /* * 自动包含各种自定义实体类(Entity) */ AiCore::parseXxxFormatFromDirAndAutoIncludeTheir(APPROOT . ENTITY_DIR, 'entity'); /* * 自动包含各种自定义Filter */ // ActionUtil::parseXxxFilterFromFilterDirAndAutoIncludeTheir(); AiCore::parseXxxFormatFromDirAndAutoIncludeTheir(APPROOT . FILTER_DIR, 'filter'); /* * 自动包含各种自定义Action。 * 执行后,将等同于: * require_once APPROOT.PUBLIC_DIR_NAME.'/core/action/IndexAction.class.php'; //默认Action * require_once APPROOT.PUBLIC_DIR_NAME.'/core/action/TestAction.class.php'; //示例Action * ... ... */ // ActionUtil::parseXxxActionFromActionDirAndAutoIncludeTheir(); AiCore::parseXxxFormatFromDirAndAutoIncludeTheir(APPROOT . ACTION_DIR, 'action'); require_once APPROOT . PUBLIC_DIR_NAME . '/core/lib/base/init__.php'; //以上所有文件包含完毕后,最后包含初始化文件,以便执行处理业务前的准备。
<?php /** * 包含公共目录中的扩展库AiSQL */ AiCore::parseXxxFormatFromDirAndAutoIncludeTheir(PUBLIC_DIR_NAME . '/core/' . USER_LIB_DIRS . 'sql/', 'class');
<?php //导入任务群集文件 AiCore::includePhpWithEveryLayer('core/setting/task/'); /* * If you want to simulate a crontask you must call this script once * and it will keep running forever (during server uptime) in the background * while "doing something" every specified seconds (= $interval): */ $file_oncetask = 'core/setting/oncetask.running'; echo "当前会话id:" . session_id() . '<br>'; //已经拿到session id,如何根据id终止其它会话(终止后就顺便把单例任务结束掉了)? //如何停止正在后台执行的脚本 //。。。。。 //如果标志文件存在,则视为已经启动了单例任务;否则,将创建该文件,并启动任务 if (!file_exists($file_oncetask)) { fopen($file_oncetask, 'w'); ai_exec_once(); //启动 } else { echo "该任务只允许单例运行"; } /** * 仅需要被启动一次的任务群集 */ function ai_exec_once() { ignore_user_abort(true); //忽略客户端中断连接 set_time_limit(0); //设置脚本执行时间不限