├── app ├── static │ ├── test.txt │ ├── test │ │ └── test.txt │ ├── img │ │ ├── a.png │ │ ├── b.png │ │ ├── c.jpg │ │ ├── d.png │ │ └── f.png │ └── favicon.ico ├── task │ └── MyTask.php ├── filter │ ├── MyFilter.php │ └── MysFilter.php ├── view │ └── index.html └── action │ └── index.php ├── vendor ├── smarty │ ├── libs - Verknüpfung.lnk │ ├── sysplugins │ │ ├── smartyexception.php │ │ ├── smarty_internal_compile_continue.php │ │ ├── smarty_internal_compile_block_child.php │ │ ├── smarty_internal_compile_parent.php │ │ ├── smarty_undefined_variable.php │ │ ├── smarty_internal_compile_block_parent.php │ │ ├── smarty_internal_method_getdebugtemplate.php │ │ ├── smarty_internal_method_getdefaultmodifiers.php │ │ ├── smarty_internal_method_clearallassign.php │ │ ├── smartycompilerexception.php │ │ ├── smarty_internal_parsetree_text.php │ │ ├── smarty_internal_compile_rdelim.php │ │ ├── smarty_internal_method_getconfigvariable.php │ │ ├── smarty_internal_parsetree_code.php │ │ ├── smarty_internal_method_compileallconfig.php │ │ ├── smarty_variable.php │ │ ├── smarty_internal_parsetree_dqcontent.php │ │ ├── smarty_internal_parsetree.php │ │ ├── smarty_internal_method_clearconfig.php │ │ ├── smarty_internal_method_clearallcache.php │ │ ├── smarty_internal_method_setdefaultmodifiers.php │ │ ├── smarty_internal_method_setdebugtemplate.php │ │ ├── smarty_internal_compile_ldelim.php │ │ ├── smarty_internal_method_unregisterobject.php │ │ ├── smarty_internal_method_unregisterresource.php │ │ ├── smarty_internal_method_clearassign.php │ │ ├── smarty_internal_method_unregistercacheresource.php │ │ ├── smarty_internal_compile_debug.php │ │ ├── smarty_internal_method_getglobal.php │ │ ├── smarty_internal_method_unregisterplugin.php │ │ ├── smarty_internal_method_assignbyref.php │ │ ├── smarty_internal_method_adddefaultmodifiers.php │ │ ├── smarty_internal_method_registercacheresource.php │ │ ├── smarty_internal_method_registerdefaultconfighandler.php │ │ ├── smarty_internal_method_clearcache.php │ │ ├── smarty_internal_method_registerdefaultpluginhandler.php │ │ ├── smarty_internal_method_getstreamvariable.php │ │ ├── smarty_internal_method_assignglobal.php │ │ ├── smarty_internal_method_getautoloadfilters.php │ │ ├── smarty_internal_method_createdata.php │ │ ├── smarty_internal_method_getregisteredobject.php │ │ ├── smarty_internal_compile_private_object_block_function.php │ │ ├── smarty_internal_method_registerclass.php │ │ ├── smarty_internal_method_unloadfilter.php │ │ ├── smarty_resource_uncompiled.php │ │ ├── smarty_internal_method_unregisterfilter.php │ │ ├── smarty_internal_method_registerresource.php │ │ ├── smarty_internal_method_getconfigvars.php │ │ ├── smarty_internal_compile_make_nocache.php │ │ ├── smarty_internal_nocache_insert.php │ │ ├── smarty_data.php │ │ ├── smarty_internal_method_mustcompile.php │ │ ├── smarty_internal_undefined.php │ │ ├── smarty_internal_compile_append.php │ │ ├── smarty_internal_method_appendbyref.php │ │ ├── smarty_internal_block.php │ │ ├── smarty_internal_compile_shared_inheritance.php │ │ ├── smarty_internal_parsetree_tag.php │ │ ├── smarty_internal_compile_eval.php │ │ ├── smarty_internal_method_registerplugin.php │ │ ├── smarty_internal_runtime_make_nocache.php │ │ ├── smarty_internal_method_gettags.php │ │ ├── smarty_internal_method_addautoloadfilters.php │ │ ├── smarty_internal_compile_nocache.php │ │ ├── smarty_internal_compile_setfilter.php │ │ ├── smarty_internal_method_setautoloadfilters.php │ │ ├── smarty_internal_method_loadfilter.php │ │ ├── smarty_internal_compile_child.php │ │ ├── smarty_resource_recompiled.php │ │ ├── smarty_internal_compile_private_function_plugin.php │ │ ├── smarty_internal_resource_stream.php │ │ ├── smarty_internal_method_registerfilter.php │ │ ├── smarty_internal_runtime_cachemodify.php │ │ └── smarty_internal_method_append.php │ ├── plugins │ │ ├── modifiercompiler.noprint.php │ │ ├── variablefilter.htmlspecialchars.php │ │ ├── modifiercompiler.string_format.php │ │ ├── modifiercompiler.cat.php │ │ ├── modifiercompiler.count_paragraphs.php │ │ ├── modifiercompiler.upper.php │ │ ├── modifiercompiler.strip_tags.php │ │ ├── modifiercompiler.indent.php │ │ ├── modifiercompiler.lower.php │ │ ├── modifier.spacify.php │ │ ├── modifiercompiler.count_sentences.php │ │ ├── modifiercompiler.to_charset.php │ │ ├── modifiercompiler.from_charset.php │ │ ├── modifiercompiler.default.php │ │ ├── modifiercompiler.strip.php │ │ ├── modifiercompiler.count_characters.php │ │ ├── modifiercompiler.count_words.php │ │ ├── shared.escape_special_chars.php │ │ ├── modifier.replace.php │ │ ├── shared.literal_compiler_param.php │ │ ├── modifiercompiler.wordwrap.php │ │ ├── modifiercompiler.unescape.php │ │ ├── shared.make_timestamp.php │ │ ├── shared.mb_unicode.php │ │ ├── modifier.regex_replace.php │ │ ├── shared.mb_str_replace.php │ │ ├── function.counter.php │ │ ├── modifier.truncate.php │ │ ├── modifier.mb_wordwrap.php │ │ └── modifier.date_format.php │ └── bootstrap.php ├── wokerman │ └── workerman │ │ ├── .gitignore │ │ ├── Events │ │ ├── React │ │ │ ├── ExtEventLoop.php │ │ │ ├── StreamSelectLoop.php │ │ │ └── ExtLibEventLoop.php │ │ └── EventInterface.php │ │ ├── composer.json │ │ ├── Lib │ │ └── Constants.php │ │ ├── MIT-LICENSE.txt │ │ ├── Protocols │ │ ├── Frame.php │ │ ├── ProtocolInterface.php │ │ └── Text.php │ │ ├── Autoloader.php │ │ └── Connection │ │ └── ConnectionInterface.php └── autoload.php ├── start_for_win.bat ├── .idea ├── misc.xml ├── vcs.xml ├── modules.xml └── HServer.iml ├── HServer ├── core │ ├── http │ │ ├── HServerFilter.php │ │ ├── Response.php │ │ └── Link.php │ ├── db │ │ ├── HServerDB.php │ │ ├── HDb.php │ │ └── HRedis.php │ ├── task │ │ └── HServerTask.php │ ├── ioc │ │ └── Container.php │ └── view │ │ ├── HActionView.php │ │ └── Dispatcher.php ├── init │ ├── start_task.php │ └── start_web.php ├── load.php ├── config │ └── Config.php ├── util │ └── Autoloader.php ├── HWebServer.php └── TimeWorker.php ├── start.php ├── CHANGELOG.md └── README.md /app/static/test.txt: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /app/static/test/test.txt: -------------------------------------------------------------------------------- 1 | test2 -------------------------------------------------------------------------------- /vendor/smarty/libs - Verknüpfung.lnk: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /start_for_win.bat: -------------------------------------------------------------------------------- 1 | php HServer\init\start_web.php HServer\init\start_task.php 2 | pause -------------------------------------------------------------------------------- /app/static/img/a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heixiaoma/HServer-For-PHP/master/app/static/img/a.png -------------------------------------------------------------------------------- /app/static/img/b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heixiaoma/HServer-For-PHP/master/app/static/img/b.png -------------------------------------------------------------------------------- /app/static/img/c.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heixiaoma/HServer-For-PHP/master/app/static/img/c.jpg -------------------------------------------------------------------------------- /app/static/img/d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heixiaoma/HServer-For-PHP/master/app/static/img/d.png -------------------------------------------------------------------------------- /app/static/img/f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heixiaoma/HServer-For-PHP/master/app/static/img/f.png -------------------------------------------------------------------------------- /app/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heixiaoma/HServer-For-PHP/master/app/static/favicon.ico -------------------------------------------------------------------------------- /vendor/wokerman/workerman/.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | .buildpath 3 | .project 4 | .settings 5 | .idea 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /vendor/autoload.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/HServer.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/task/MyTask.php: -------------------------------------------------------------------------------- 1 | Request->getIp()."\n"; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /app/filter/MysFilter.php: -------------------------------------------------------------------------------- 1 | Request->getFullUri() . "\n"; 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /HServer/core/db/HServerDB.php: -------------------------------------------------------------------------------- 1 | db = HDb::getInstance(); 20 | $this->redis = HRedis::getInstance(); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /HServer/init/start_task.php: -------------------------------------------------------------------------------- 1 | name = "定时器业务"; 19 | 20 | if (!defined('GLOBAL_START')) { 21 | Worker::runAll(); 22 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smartyexception.php: -------------------------------------------------------------------------------- 1 | Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.noprint.php: -------------------------------------------------------------------------------- 1 | name = "HServer->WEB服务器"; 18 | $web->count = 4; 19 | 20 | if (!defined('GLOBAL_START')) { 21 | Worker::runAll(); 22 | } 23 | -------------------------------------------------------------------------------- /HServer/core/task/HServerTask.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | /* 12 | * Load and register Smarty Autoloader 13 | */ 14 | if (!class_exists('Smarty_Autoloader')) { 15 | require dirname(__FILE__) . '/Autoloader.php'; 16 | } 17 | Smarty_Autoloader::register(true); 18 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/variablefilter.htmlspecialchars.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class Smarty_Internal_Compile_Block_Child extends Smarty_Internal_Compile_Child 17 | { 18 | /** 19 | * Tag name 20 | * 21 | * @var string 22 | */ 23 | public $tag = 'block_child'; 24 | } -------------------------------------------------------------------------------- /app/view/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | HServer 7 | 8 | 27 | 28 |
欢迎使用:{$content}
29 | 30 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.string_format.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child 17 | { 18 | 19 | /** 20 | * Tag name 21 | * 22 | * @var string 23 | */ 24 | public $tag = 'parent'; 25 | 26 | /** 27 | * Block type 28 | * 29 | * @var string 30 | */ 31 | public $blockType = 'Parent'; 32 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_undefined_variable.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Child 17 | { 18 | /** 19 | * Tag name 20 | * 21 | * @var string 22 | */ 23 | public $tag = 'block_parent'; 24 | 25 | /** 26 | * Block type 27 | * 28 | * @var string 29 | */ 30 | public $blockType = 'Parent'; 31 | } -------------------------------------------------------------------------------- /start.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Events\React; 15 | 16 | /** 17 | * Class ExtEventLoop 18 | * @package Workerman\Events\React 19 | */ 20 | class ExtEventLoop extends Base 21 | { 22 | 23 | public function __construct() 24 | { 25 | $this->_eventLoop = new \React\EventLoop\ExtEventLoop(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/action/index.php: -------------------------------------------------------------------------------- 1 | Response->json(array("a" => 1)); 18 | } 19 | 20 | public function html() 21 | { 22 | $this->assign("content", "HServer"); 23 | $html = $this->fetch("index.html"); 24 | $this->Response->send($html); 25 | } 26 | 27 | 28 | // /** 29 | // * db操作,记得开启配置 30 | // * @return string 31 | // */ 32 | // public function db() 33 | // { 34 | // $this->redis->get("user"); 35 | // print_r($this->db->query("select * from movies limit 1")); 36 | // $this->Response->send("完成"); 37 | // } 38 | 39 | 40 | } -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Events/React/StreamSelectLoop.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Events\React; 15 | 16 | /** 17 | * Class StreamSelectLoop 18 | * @package Workerman\Events\React 19 | */ 20 | class StreamSelectLoop extends Base 21 | { 22 | public function __construct() 23 | { 24 | $this->_eventLoop = new \React\EventLoop\StreamSelectLoop(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /HServer/load.php: -------------------------------------------------------------------------------- 1 | ]*?>!', ' ', {$params[0]})"; 26 | } else { 27 | return 'strip_tags(' . $params[ 0 ] . ')'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Events/React/ExtLibEventLoop.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Events\React; 15 | use Workerman\Events\EventInterface; 16 | 17 | /** 18 | * Class ExtLibEventLoop 19 | * @package Workerman\Events\React 20 | */ 21 | class ExtLibEventLoop extends Base 22 | { 23 | public function __construct() 24 | { 25 | $this->_eventLoop = new \React\EventLoop\ExtLibeventLoop(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.indent.php: -------------------------------------------------------------------------------- 1 | 17 | * @author Uwe Tews 18 | * 19 | * @param array $params parameters 20 | * 21 | * @return string with compiled code 22 | */ 23 | 24 | function smarty_modifiercompiler_lower($params) 25 | { 26 | if (Smarty::$_MBSTRING) { 27 | return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; 28 | } 29 | // no MBString fallback 30 | return 'strtolower(' . $params[ 0 ] . ')'; 31 | } 32 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifier.spacify.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * @param string $string input string 19 | * @param string $spacify_char string to insert between characters. 20 | * 21 | * @return string 22 | */ 23 | function smarty_modifier_spacify($string, $spacify_char = ' ') 24 | { 25 | // well… what about charsets besides latin and UTF-8? 26 | return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY)); 27 | } 28 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.count_sentences.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 33 | return $smarty->debug_tpl; 34 | } 35 | } -------------------------------------------------------------------------------- /HServer/core/db/HRedis.php: -------------------------------------------------------------------------------- 1 | connect($re["host"], $re["port"]); 29 | if (strlen($re["password"]) > 0) { 30 | $redis->auth($re["password"]); 31 | } 32 | self::$_instance = $redis; 33 | } 34 | return self::$_instance; 35 | } 36 | } 37 | 38 | 39 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.to_charset.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 33 | return $smarty->default_modifiers; 34 | } 35 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.default.php: -------------------------------------------------------------------------------- 1 | tpl_vars = array(); 34 | 35 | return $data; 36 | } 37 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smartycompilerexception.php: -------------------------------------------------------------------------------- 1 | Smarty Compiler: ' . $this->message . ' <-- '; 16 | } 17 | 18 | /** 19 | * The line number of the template error 20 | * 21 | * @type int|null 22 | */ 23 | public $line = null; 24 | 25 | /** 26 | * The template source snippet relating to the error 27 | * 28 | * @type string|null 29 | */ 30 | public $source = null; 31 | 32 | /** 33 | * The raw text of the error message 34 | * 35 | * @type string|null 36 | */ 37 | public $desc = null; 38 | 39 | /** 40 | * The resource identifier or template name 41 | * 42 | * @type string|null 43 | */ 44 | public $template = null; 45 | } 46 | -------------------------------------------------------------------------------- /HServer/config/Config.php: -------------------------------------------------------------------------------- 1 | data = $data; 27 | } 28 | 29 | /** 30 | * Return buffer content 31 | * 32 | * @param \Smarty_Internal_Templateparser $parser 33 | * 34 | * @return string text 35 | */ 36 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 37 | { 38 | return $this->data; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # HServer 更新日志 2 | 3 | #### 2019-9-20 4 | 5 | - 对文件进行优化 6 | - 正在处理定时器任务工具的封装 7 | - 定时任务文件存放在app 8 | - 拦截器存放在App 9 | - 静态文件存在在App 10 | - action存在App 11 | - view模板文件存在App里面 12 | - Task任务继承,HServerTask,父类封装了DB和Redis相关的操作 13 | - 由于Task是单独woker,所以启动方式Linux不变,win请点击start_for_win.bat 14 | - 下次预计更新,错误日志定位监控 15 | 16 | #### 2019-8-4 17 | 18 | - 对 Req 和 Resp 优化 19 | - 对自动加载目录优化 20 | 21 | #### 2019-7-31 22 | 23 | - 添加实例容器,不用每次再去反射 24 | - 第一次反射进容器,第二次走容器拿数据 25 | - 相比以前每次反射,调用性能提高58% 26 | 27 | #### 2019-5-20 28 | 29 | 添加文件上传功能: 30 | 31 | ```php 32 | $file=$this->Request->file("file"); 33 | $file->save("路径"); 34 | $file->save("路径","别名"); 35 | ``` 36 | 37 | #### 2019-4-12 38 | 39 | 修复自动加载加载机制 40 | 41 | #### 2019-4-10 42 | 43 | - 修改,HActionView 添加req,和resp 44 | - 添加拦截器:HServerFilter,继承并实现auth方法,重写Level属性,设置优先级,越大,越先 45 | 46 | #### 2019-7-30 47 | 48 | ab压测截图如下,吞吐率 7w+ 测试机:Centos event扩展 4核,2G, 49 | 50 | ![AB测试](https://gitee.com/heixiaomas/HServer/raw/master/app/static/img/d.png) 51 | 52 | ![运行截图](https://gitee.com/heixiaomas/HServer/raw/master/app/static/img/b.png) 53 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.count_characters.php: -------------------------------------------------------------------------------- 1 | smarty->right_delimiter; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_getconfigvariable.php: -------------------------------------------------------------------------------- 1 | ext->configLoad->_getConfigVariable($data, $varName, $errorEnable); 33 | } 34 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_parsetree_code.php: -------------------------------------------------------------------------------- 1 | data = $data; 29 | } 30 | 31 | /** 32 | * Return buffer content in parentheses 33 | * 34 | * @param \Smarty_Internal_Templateparser $parser 35 | * 36 | * @return string content 37 | */ 38 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 39 | { 40 | return sprintf('(%s)', $this->data); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_compileallconfig.php: -------------------------------------------------------------------------------- 1 | compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors, true); 32 | } 33 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.count_words.php: -------------------------------------------------------------------------------- 1 | value = $value; 35 | $this->nocache = $nocache; 36 | } 37 | 38 | /** 39 | * <> String conversion 40 | * 41 | * @return string 42 | */ 43 | public function __toString() 44 | { 45 | return (string) $this->value; 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/shared.escape_special_chars.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @param string $string text that should by escaped 18 | * 19 | * @return string 20 | */ 21 | function smarty_function_escape_special_chars($string) 22 | { 23 | if (!is_array($string)) { 24 | if (version_compare(PHP_VERSION, '5.2.3', '>=')) { 25 | $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); 26 | } else { 27 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); 28 | $string = htmlspecialchars($string); 29 | $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); 30 | } 31 | } 32 | 33 | return $string; 34 | } 35 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_parsetree_dqcontent.php: -------------------------------------------------------------------------------- 1 | data = $data; 29 | } 30 | 31 | /** 32 | * Return content as double quoted string 33 | * 34 | * @param \Smarty_Internal_Templateparser $parser 35 | * 36 | * @return string doubled quoted string 37 | */ 38 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 39 | { 40 | return '"' . $this->data . '"'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_parsetree.php: -------------------------------------------------------------------------------- 1 | data = null; 49 | $this->subtrees = null; 50 | } 51 | 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifier.replace.php: -------------------------------------------------------------------------------- 1 | 17 | * @author Uwe Tews 18 | * 19 | * @param string $string input string 20 | * @param string $search text to search for 21 | * @param string $replace replacement text 22 | * 23 | * @return string 24 | */ 25 | function smarty_modifier_replace($string, $search, $replace) 26 | { 27 | static $is_loaded = false; 28 | if (Smarty::$_MBSTRING) { 29 | if (!$is_loaded) { 30 | if (!is_callable('smarty_mb_str_replace')) { 31 | require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); 32 | } 33 | $is_loaded = true; 34 | } 35 | return smarty_mb_str_replace($search, $replace, $string); 36 | } 37 | 38 | return str_replace($search, $replace, $string); 39 | } 40 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_clearconfig.php: -------------------------------------------------------------------------------- 1 | config_vars[ $name ]); 36 | } else { 37 | $data->config_vars = array(); 38 | } 39 | return $data; 40 | } 41 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_clearallcache.php: -------------------------------------------------------------------------------- 1 | _clearTemplateCache(); 37 | // load cache resource and call clearAll 38 | $_cache_resource = Smarty_CacheResource::load($smarty, $type); 39 | return $_cache_resource->clearAll($smarty, $exp_time); 40 | } 41 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_setdefaultmodifiers.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | $smarty->default_modifiers = (array) $modifiers; 36 | return $obj; 37 | } 38 | } -------------------------------------------------------------------------------- /vendor/wokerman/workerman/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "workerman/workerman", 3 | "type": "library", 4 | "keywords": [ 5 | "event-loop", 6 | "asynchronous" 7 | ], 8 | "homepage": "http://www.workerman.net", 9 | "license": "MIT", 10 | "description": "An asynchronous event driven PHP framework for easily building fast, scalable network applications.", 11 | "authors": [ 12 | { 13 | "name": "walkor", 14 | "email": "walkor@workerman.net", 15 | "homepage": "http://www.workerman.net", 16 | "role": "Developer" 17 | } 18 | ], 19 | "support": { 20 | "email": "walkor@workerman.net", 21 | "issues": "https://github.com/walkor/workerman/issues", 22 | "forum": "http://wenda.workerman.net/", 23 | "wiki": "http://doc3.workerman.net/index.html", 24 | "source": "https://github.com/walkor/workerman" 25 | }, 26 | "require": { 27 | "php": ">=5.3" 28 | }, 29 | "suggest": { 30 | "ext-event": "For better performance. " 31 | }, 32 | "autoload": { 33 | "psr-4": { 34 | "Workerman\\": "./" 35 | } 36 | }, 37 | "minimum-stability": "dev" 38 | } 39 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/shared.literal_compiler_param.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | if (!is_readable($tpl_name)) { 36 | throw new SmartyException("Unknown file '{$tpl_name}'"); 37 | } 38 | $smarty->debug_tpl = $tpl_name; 39 | return $obj; 40 | } 41 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_ldelim.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 32 | if ($_attr[ 'nocache' ] === true) { 33 | $compiler->trigger_template_error('nocache option not allowed', null, true); 34 | } 35 | return $compiler->smarty->left_delimiter; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Lib/Constants.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | 15 | // Date.timezone 16 | if (!ini_get('date.timezone')) { 17 | date_default_timezone_set('Asia/Shanghai'); 18 | } 19 | // Display errors. 20 | ini_set('display_errors', 'on'); 21 | // Reporting all. 22 | error_reporting(E_ALL); 23 | 24 | // Reset opcache. 25 | if (function_exists('opcache_reset')) { 26 | opcache_reset(); 27 | } 28 | 29 | // For onError callback. 30 | define('WORKERMAN_CONNECT_FAIL', 1); 31 | // For onError callback. 32 | define('WORKERMAN_SEND_FAIL', 2); 33 | 34 | // Define OS Type 35 | define('OS_TYPE_LINUX', 'linux'); 36 | define('OS_TYPE_WINDOWS', 'windows'); 37 | 38 | // Compatible with php7 39 | if(!class_exists('Error')) 40 | { 41 | class Error extends Exception 42 | { 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/wokerman/workerman/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2009-2015 walkor and contributors (see https://github.com/walkor/workerman/contributors) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_unregisterobject.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | if (isset($smarty->registered_objects[ $object_name ])) { 36 | unset($smarty->registered_objects[ $object_name ]); 37 | } 38 | return $obj; 39 | } 40 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_unregisterresource.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | if (isset($smarty->registered_resources[ $type ])) { 36 | unset($smarty->registered_resources[ $type ]); 37 | } 38 | return $obj; 39 | } 40 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_clearassign.php: -------------------------------------------------------------------------------- 1 | tpl_vars[ $curr_var ]); 37 | } 38 | } else { 39 | unset($data->tpl_vars[ $tpl_var ]); 40 | } 41 | 42 | return $data; 43 | } 44 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_unregistercacheresource.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | if (isset($smarty->registered_cache_resources[ $name ])) { 36 | unset($smarty->registered_cache_resources[ $name ]); 37 | } 38 | return $obj; 39 | } 40 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.wordwrap.php: -------------------------------------------------------------------------------- 1 | getPlugin('mb_wordwrap','modifier'); 37 | } 38 | return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')'; 39 | } 40 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_debug.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 32 | 33 | // compile always as nocache 34 | $compiler->tag_nocache = true; 35 | 36 | // display debug template 37 | $_output = 38 | "display_debug(\$_smarty_tpl);\n"; 39 | $_output .= "unset(\$_smarty_debug);\n?>"; 40 | return $_output; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_getglobal.php: -------------------------------------------------------------------------------- 1 | value; 36 | } else { 37 | return ''; 38 | } 39 | } else { 40 | $_result = array(); 41 | foreach (Smarty::$global_tpl_vars AS $key => $var) { 42 | $_result[ $key ] = $var->value; 43 | } 44 | return $_result; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_unregisterplugin.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 36 | if (isset($smarty->registered_plugins[ $type ][ $name ])) { 37 | unset($smarty->registered_plugins[ $type ][ $name ]); 38 | } 39 | return $obj; 40 | } 41 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_assignbyref.php: -------------------------------------------------------------------------------- 1 | tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); 29 | $data->tpl_vars[ $tpl_var ]->value = &$value; 30 | if ($data->_isTplObj() && $data->scope) { 31 | $data->ext->_updateScope->_updateScope($data, $tpl_var); 32 | } 33 | } 34 | return $data; 35 | } 36 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_adddefaultmodifiers.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | if (is_array($modifiers)) { 36 | $smarty->default_modifiers = array_merge($smarty->default_modifiers, $modifiers); 37 | } else { 38 | $smarty->default_modifiers[] = $modifiers; 39 | } 40 | return $obj; 41 | } 42 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_registercacheresource.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 37 | $smarty->registered_cache_resources[ $name ] = $resource_handler; 38 | return $obj; 39 | } 40 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_registerdefaultconfighandler.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | if (is_callable($callback)) { 36 | $smarty->default_config_handler_func = $callback; 37 | } else { 38 | throw new SmartyException('Default config handler not callable'); 39 | } 40 | return $obj; 41 | } 42 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifiercompiler.unescape.php: -------------------------------------------------------------------------------- 1 | _clearTemplateCache(); 41 | // load cache resource and call clear 42 | $_cache_resource = Smarty_CacheResource::load($smarty, $type); 43 | return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); 44 | } 45 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 36 | if (is_callable($callback)) { 37 | $smarty->default_plugin_handler_func = $callback; 38 | } else { 39 | throw new SmartyException("Default plugin handler '$callback' not callable"); 40 | } 41 | return $obj; 42 | } 43 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_getstreamvariable.php: -------------------------------------------------------------------------------- 1 | smarty) ? $data->smarty : $data; 45 | if ($smarty->error_unassigned) { 46 | throw new SmartyException('Undefined stream variable "' . $variable . '"'); 47 | } else { 48 | return null; 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_assignglobal.php: -------------------------------------------------------------------------------- 1 | _isTplObj()) { 37 | $ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ]; 38 | $ptr = $ptr->parent; 39 | } 40 | } 41 | return $data; 42 | } 43 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_getautoloadfilters.php: -------------------------------------------------------------------------------- 1 | array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type 25 | * was specified 26 | * @throws \SmartyException 27 | */ 28 | public function getAutoloadFilters(Smarty_Internal_TemplateBase $obj, $type = null) 29 | { 30 | $smarty = $obj->_getSmartyObj(); 31 | if ($type !== null) { 32 | $this->_checkFilterType($type); 33 | return isset($smarty->autoload_filters[ $type ]) ? $smarty->autoload_filters[ $type ] : array(); 34 | } 35 | return $smarty->autoload_filters; 36 | } 37 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_createdata.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 38 | $dataObj = new Smarty_Data($parent, $smarty, $name); 39 | if ($smarty->debugging) { 40 | Smarty_Internal_Debug::register_data($dataObj); 41 | } 42 | return $dataObj; 43 | } 44 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_getregisteredobject.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 36 | if (!isset($smarty->registered_objects[ $object_name ])) { 37 | throw new SmartyException("'$object_name' is not a registered object"); 38 | } 39 | if (!is_object($smarty->registered_objects[ $object_name ][ 0 ])) { 40 | throw new SmartyException("registered '$object_name' is not an object"); 41 | } 42 | return $smarty->registered_objects[ $object_name ][ 0 ]; 43 | } 44 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_private_object_block_function.php: -------------------------------------------------------------------------------- 1 | $_value) { 33 | if (is_int($_key)) { 34 | $_paramsArray[] = "$_key=>$_value"; 35 | } else { 36 | $_paramsArray[] = "'$_key'=>$_value"; 37 | } 38 | } 39 | $callback = array("\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]", "->{$method}"); 40 | return array($callback, $_paramsArray, "array(\$_block_plugin{$this->nesting}, '{$method}')"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /HServer/core/view/HActionView.php: -------------------------------------------------------------------------------- 1 | view = new \Smarty(); 43 | } 44 | 45 | 46 | /** 47 | * @param mixed $Response 48 | */ 49 | public function setResponse($Response) 50 | { 51 | $this->Response = $Response; 52 | } 53 | 54 | /** 55 | * @param mixed $Request 56 | */ 57 | public function setRequest(Request $Request) 58 | { 59 | $this->Request = $Request; 60 | } 61 | 62 | 63 | protected function assign($key, $value) 64 | { 65 | $this->view->assign($key, $value); 66 | } 67 | 68 | protected function fetch($tpl, $path = "app/view") 69 | { 70 | if ($path != "app/view") { 71 | $path = "app/view" . $path; 72 | } 73 | $this->view->setTemplateDir($path); 74 | return $this->view->fetch($tpl); 75 | 76 | } 77 | 78 | 79 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/shared.make_timestamp.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime() 16 | * 17 | * @return int 18 | */ 19 | function smarty_make_timestamp($string) 20 | { 21 | if (empty($string)) { 22 | // use "now": 23 | return time(); 24 | } elseif ($string instanceof DateTime || 25 | (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface) 26 | ) { 27 | return (int) $string->format('U'); // PHP 5.2 BC 28 | } elseif (strlen($string) === 14 && ctype_digit($string)) { 29 | // it is mysql timestamp format of YYYYMMDDHHMMSS? 30 | return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2), 31 | substr($string, 6, 2), substr($string, 0, 4)); 32 | } elseif (is_numeric($string)) { 33 | // it is a numeric string, we handle it as timestamp 34 | return (int) $string; 35 | } else { 36 | // strtotime should handle it 37 | $time = strtotime($string); 38 | if ($time === - 1 || $time === false) { 39 | // strtotime() was not able to parse $string, use "now": 40 | return time(); 41 | } 42 | 43 | return $time; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_registerclass.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 38 | // test if exists 39 | if (!class_exists($class_impl)) { 40 | throw new SmartyException("Undefined class '$class_impl' in register template class"); 41 | } 42 | // register the class 43 | $smarty->registered_classes[ $class_name ] = $class_impl; 44 | return $obj; 45 | } 46 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_unloadfilter.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 31 | $this->_checkFilterType($type); 32 | if (isset($smarty->registered_filters[ $type ])) { 33 | $_filter_name = "smarty_{$type}filter_{$name}"; 34 | if (isset($smarty->registered_filters[ $type ][ $_filter_name ])) { 35 | unset ($smarty->registered_filters[ $type ][ $_filter_name ]); 36 | if (empty($smarty->registered_filters[ $type ])) { 37 | unset($smarty->registered_filters[ $type ]); 38 | } 39 | } 40 | } 41 | return $obj; 42 | } 43 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_resource_uncompiled.php: -------------------------------------------------------------------------------- 1 | filepath = $_template->source->filepath; 42 | $compiled->timestamp = $_template->source->timestamp; 43 | $compiled->exists = $_template->source->exists; 44 | if ($_template->smarty->merge_compiled_includes || $_template->source->handler->checkTimestamps()) { 45 | $compiled->file_dependency[ $_template->source->uid ] = 46 | array($compiled->filepath, $compiled->timestamp, $_template->source->type,); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Protocols/Frame.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Protocols; 15 | 16 | use Workerman\Connection\TcpConnection; 17 | 18 | /** 19 | * Frame Protocol. 20 | */ 21 | class Frame 22 | { 23 | /** 24 | * Check the integrity of the package. 25 | * 26 | * @param string $buffer 27 | * @param TcpConnection $connection 28 | * @return int 29 | */ 30 | public static function input($buffer, TcpConnection $connection) 31 | { 32 | if (strlen($buffer) < 4) { 33 | return 0; 34 | } 35 | $unpack_data = unpack('Ntotal_length', $buffer); 36 | return $unpack_data['total_length']; 37 | } 38 | 39 | /** 40 | * Decode. 41 | * 42 | * @param string $buffer 43 | * @return string 44 | */ 45 | public static function decode($buffer) 46 | { 47 | return substr($buffer, 4); 48 | } 49 | 50 | /** 51 | * Encode. 52 | * 53 | * @param string $buffer 54 | * @return string 55 | */ 56 | public static function encode($buffer) 57 | { 58 | $total_length = 4 + strlen($buffer); 59 | return pack('N', $total_length) . $buffer; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_unregisterfilter.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 31 | $this->_checkFilterType($type); 32 | if (isset($smarty->registered_filters[ $type ])) { 33 | $name = is_string($callback) ? $callback : $this->_getFilterName($callback); 34 | if (isset($smarty->registered_filters[ $type ][ $name ])) { 35 | unset($smarty->registered_filters[ $type ][ $name ]); 36 | if (empty($smarty->registered_filters[ $type ])) { 37 | unset($smarty->registered_filters[ $type ]); 38 | } 39 | } 40 | } 41 | return $obj; 42 | } 43 | } -------------------------------------------------------------------------------- /HServer/util/Autoloader.php: -------------------------------------------------------------------------------- 1 | 10000) { 35 | // 请求数达到10000后退出当前进程,主进程会自动重启一个新的进程 36 | parent::stopAll(); 37 | } 38 | 39 | /** 40 | * 构造Req,resp 41 | */ 42 | $req = new Request($data); 43 | $resp = new Response($connection); 44 | 45 | /** 46 | * 检查静态文件,是否存在 47 | */ 48 | $temp = new StaticFiles($connection); 49 | if ($temp->invoke()) { 50 | return false; 51 | } 52 | /** 53 | * 检查Filter是否存在 54 | */ 55 | 56 | Link::invoke($req, $resp); 57 | 58 | /** 59 | * 检查控制器是否存在,进行分发 60 | */ 61 | Dispatcher::display($resp, $req); 62 | } 63 | 64 | public function run() 65 | { 66 | Worker::$logFile = __DIR__ . '/../log/web.log'; 67 | Worker::$stdoutFile = __DIR__ . '/../log/web_stdout.log'; 68 | $this->reusePort = true; 69 | $this->onMessage = array($this, 'onClientMessage'); 70 | parent::run(); 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_registerresource.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 40 | $smarty->registered_resources[ $name ] = 41 | $resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false); 42 | return $obj; 43 | } 44 | } -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Protocols/ProtocolInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Protocols; 15 | 16 | use Workerman\Connection\ConnectionInterface; 17 | 18 | /** 19 | * Protocol interface 20 | */ 21 | interface ProtocolInterface 22 | { 23 | /** 24 | * Check the integrity of the package. 25 | * Please return the length of package. 26 | * If length is unknow please return 0 that mean wating more data. 27 | * If the package has something wrong please return false the connection will be closed. 28 | * 29 | * @param ConnectionInterface $connection 30 | * @param string $recv_buffer 31 | * @return int|false 32 | */ 33 | public static function input($recv_buffer, ConnectionInterface $connection); 34 | 35 | /** 36 | * Decode package and emit onMessage($message) callback, $message is the result that decode returned. 37 | * 38 | * @param ConnectionInterface $connection 39 | * @param string $recv_buffer 40 | * @return mixed 41 | */ 42 | public static function decode($recv_buffer, ConnectionInterface $connection); 43 | 44 | /** 45 | * Encode package brefore sending to client. 46 | * 47 | * @param ConnectionInterface $connection 48 | * @param mixed $data 49 | * @return string 50 | */ 51 | public static function encode($data, ConnectionInterface $connection); 52 | } 53 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_getconfigvars.php: -------------------------------------------------------------------------------- 1 | config_vars[ $varname ])) { 40 | return $_ptr->config_vars[ $varname ]; 41 | } 42 | } else { 43 | $var_array = array_merge($_ptr->config_vars, $var_array); 44 | } 45 | // not found, try at parent 46 | if ($search_parents) { 47 | $_ptr = $_ptr->parent; 48 | } else { 49 | $_ptr = null; 50 | } 51 | } 52 | if (isset($varname)) { 53 | return ''; 54 | } else { 55 | return $var_array; 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /HServer/TimeWorker.php: -------------------------------------------------------------------------------- 1 | newInstanceArgs(); 33 | if ($class->hasMethod("run")) { 34 | $time = $class->getProperty('time'); 35 | $time->setAccessible(true); 36 | $timeout = $time->getValue($timeTask); 37 | $run = $class->getMethod("run"); 38 | $run->setAccessible(true); 39 | Timer::add($timeout, function () use ($run, $timeTask) { 40 | $run->invoke($timeTask); 41 | }); 42 | } else { 43 | echo "无定时器"; 44 | } 45 | } 46 | } 47 | } 48 | 49 | public function run() 50 | { 51 | Worker::$logFile = __DIR__ . '/../log/task.log'; 52 | Worker::$stdoutFile = __DIR__ . '/../log/task_stdout.log'; 53 | $this->onWorkerStart = array($this, 'onClientStart'); 54 | parent::run(); 55 | } 56 | 57 | 58 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifier.regex_replace.php: -------------------------------------------------------------------------------- 1 | 18 | * 19 | * @param string $string input string 20 | * @param string|array $search regular expression(s) to search for 21 | * @param string|array $replace string(s) that should be replaced 22 | * @param int $limit the maximum number of replacements 23 | * 24 | * @return string 25 | */ 26 | function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1) 27 | { 28 | if (is_array($search)) { 29 | foreach ($search as $idx => $s) { 30 | $search[ $idx ] = _smarty_regex_replace_check($s); 31 | } 32 | } else { 33 | $search = _smarty_regex_replace_check($search); 34 | } 35 | 36 | return preg_replace($search, $replace, $string, $limit); 37 | } 38 | 39 | /** 40 | * @param string $search string(s) that should be replaced 41 | * 42 | * @return string 43 | * @ignore 44 | */ 45 | function _smarty_regex_replace_check($search) 46 | { 47 | // null-byte injection detection 48 | // anything behind the first null-byte is ignored 49 | if (($pos = strpos($search, "\0")) !== false) { 50 | $search = substr($search, 0, $pos); 51 | } 52 | // remove eval-modifier from $search 53 | if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) { 54 | $search = substr($search, 0, - strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]); 55 | } 56 | 57 | return $search; 58 | } 59 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_make_nocache.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 53 | if ($compiler->template->caching) { 54 | $output = "smarty->ext->_make_nocache->save(\$_smarty_tpl, {$_attr[ 'var' ]});\n?>\n"; 55 | $compiler->template->compiled->has_nocache_code = true; 56 | $compiler->suppressNocacheProcessing = true; 57 | return $output; 58 | } else { 59 | return true; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_nocache_insert.php: -------------------------------------------------------------------------------- 1 | assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . 41 | ',\$_smarty_tpl), true);?>'; 42 | } else { 43 | $_output .= "echo {$_function}(" . var_export($_attr, true) . ',$_smarty_tpl);?>'; 44 | } 45 | $_tpl = $_template; 46 | while ($_tpl->_isSubTpl()) { 47 | $_tpl = $_tpl->parent; 48 | } 49 | 50 | return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_data.php: -------------------------------------------------------------------------------- 1 | dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count); 55 | $this->smarty = $smarty; 56 | if (is_object($_parent)) { 57 | // when object set up back pointer 58 | $this->parent = $_parent; 59 | } elseif (is_array($_parent)) { 60 | // set up variable values 61 | foreach ($_parent as $_key => $_val) { 62 | $this->tpl_vars[ $_key ] = new Smarty_Variable($_val); 63 | } 64 | } elseif ($_parent !== null) { 65 | throw new SmartyException('Wrong type for template variables'); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Protocols/Text.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Protocols; 15 | 16 | use Workerman\Connection\TcpConnection; 17 | 18 | /** 19 | * Text Protocol. 20 | */ 21 | class Text 22 | { 23 | /** 24 | * Check the integrity of the package. 25 | * 26 | * @param string $buffer 27 | * @param TcpConnection $connection 28 | * @return int 29 | */ 30 | public static function input($buffer, TcpConnection $connection) 31 | { 32 | // Judge whether the package length exceeds the limit. 33 | if (strlen($buffer) >= $connection::$maxPackageSize) { 34 | $connection->close(); 35 | return 0; 36 | } 37 | // Find the position of "\n". 38 | $pos = strpos($buffer, "\n"); 39 | // No "\n", packet length is unknown, continue to wait for the data so return 0. 40 | if ($pos === false) { 41 | return 0; 42 | } 43 | // Return the current package length. 44 | return $pos + 1; 45 | } 46 | 47 | /** 48 | * Encode. 49 | * 50 | * @param string $buffer 51 | * @return string 52 | */ 53 | public static function encode($buffer) 54 | { 55 | // Add "\n" 56 | return $buffer . "\n"; 57 | } 58 | 59 | /** 60 | * Decode. 61 | * 62 | * @param string $buffer 63 | * @return string 64 | */ 65 | public static function decode($buffer) 66 | { 67 | // Remove "\n" 68 | return trim($buffer); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_mustcompile.php: -------------------------------------------------------------------------------- 1 | source->exists) { 34 | if ($_template->_isSubTpl()) { 35 | $parent_resource = " in '$_template->parent->template_resource}'"; 36 | } else { 37 | $parent_resource = ''; 38 | } 39 | throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}"); 40 | } 41 | if ($_template->mustCompile === null) { 42 | $_template->mustCompile = (!$_template->source->handler->uncompiled && 43 | ($_template->smarty->force_compile || $_template->source->handler->recompiled || 44 | !$_template->compiled->exists || ($_template->compile_check && 45 | $_template->compiled->getTimeStamp() < 46 | $_template->source->getTimeStamp()))); 47 | } 48 | 49 | return $_template->mustCompile; 50 | } 51 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_undefined.php: -------------------------------------------------------------------------------- 1 | class = $class; 30 | } 31 | 32 | /** 33 | * Wrapper for obsolete class Smarty_Internal_Runtime_ValidateCompiled 34 | * 35 | * @param \Smarty_Internal_Template $tpl 36 | * @param array $properties special template properties 37 | * @param bool $cache flag if called from cache file 38 | * 39 | * @return bool false 40 | */ 41 | public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) 42 | { 43 | if ($cache) { 44 | $tpl->cached->valid = false; 45 | } else { 46 | $tpl->mustCompile = true; 47 | } 48 | return false; 49 | } 50 | 51 | /** 52 | * Call error handler for undefined method 53 | * 54 | * @param string $name unknown method-name 55 | * @param array $args argument array 56 | * 57 | * @return mixed 58 | * @throws SmartyException 59 | */ 60 | public function __call($name, $args) 61 | { 62 | if (isset($this->class)) { 63 | throw new SmartyException("undefined extension class '{$this->class}'"); 64 | } else { 65 | throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method"); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/shared.mb_str_replace.php: -------------------------------------------------------------------------------- 1 | required_attributes = array('var', 'value'); 33 | $this->shorttag_order = array('var', 'value'); 34 | $this->optional_attributes = array('scope', 'index'); 35 | $this->mapCache = array(); 36 | // check and get attributes 37 | $_attr = $this->getAttributes($compiler, $args); 38 | // map to compile assign attributes 39 | if (isset($_attr[ 'index' ])) { 40 | $_params[ 'smarty_internal_index' ] = '[' . $_attr[ 'index' ] . ']'; 41 | unset($_attr[ 'index' ]); 42 | } else { 43 | $_params[ 'smarty_internal_index' ] = '[]'; 44 | } 45 | $_new_attr = array(); 46 | foreach ($_attr as $key => $value) { 47 | $_new_attr[] = array($key => $value); 48 | } 49 | // call compile assign 50 | return parent::compile($_new_attr, $compiler, $_params); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_appendbyref.php: -------------------------------------------------------------------------------- 1 | tpl_vars[ $tpl_var ])) { 32 | $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(); 33 | } 34 | if (!is_array($data->tpl_vars[ $tpl_var ]->value)) { 35 | settype($data->tpl_vars[ $tpl_var ]->value, 'array'); 36 | } 37 | if ($merge && is_array($value)) { 38 | foreach ($value as $_key => $_val) { 39 | $data->tpl_vars[ $tpl_var ]->value[ $_key ] = &$value[ $_key ]; 40 | } 41 | } else { 42 | $data->tpl_vars[ $tpl_var ]->value[] = &$value; 43 | } 44 | if ($data->_isTplObj() && $data->scope) { 45 | $data->ext->_updateScope->_updateScope($data, $tpl_var); 46 | } 47 | } 48 | return $data; 49 | } 50 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_block.php: -------------------------------------------------------------------------------- 1 | name = $name; 79 | $this->tplIndex = $tplIndex; 80 | } 81 | 82 | /** 83 | * Compiled block code overloaded by {block} class 84 | * 85 | * @param \Smarty_Internal_Template $tpl 86 | */ 87 | public function callBlock(Smarty_Internal_Template $tpl) 88 | { 89 | } 90 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_shared_inheritance.php: -------------------------------------------------------------------------------- 1 | prefixCompiledCode .= "_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " . 28 | var_export($initChildSequence, true) . ");\n?>\n"; 29 | } 30 | 31 | /** 32 | * Register post compile callback to compile inheritance initialization code 33 | * 34 | * @param \Smarty_Internal_TemplateCompilerBase $compiler 35 | * @param bool|false $initChildSequence if true force child template 36 | */ 37 | public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) 38 | { 39 | if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) { 40 | $compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'), 41 | array($initChildSequence), 42 | 'inheritanceInit', 43 | $initChildSequence); 44 | 45 | $compiler->_cache['inheritanceInit'] = true; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_parsetree_tag.php: -------------------------------------------------------------------------------- 1 | data = $data; 38 | $this->saved_block_nesting = $parser->block_nesting_level; 39 | } 40 | 41 | /** 42 | * Return buffer content 43 | * 44 | * @param \Smarty_Internal_Templateparser $parser 45 | * 46 | * @return string content 47 | */ 48 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 49 | { 50 | return $this->data; 51 | } 52 | 53 | /** 54 | * Return complied code that loads the evaluated output of buffer content into a temporary variable 55 | * 56 | * @param \Smarty_Internal_Templateparser $parser 57 | * 58 | * @return string template code 59 | */ 60 | public function assign_to_var(Smarty_Internal_Templateparser $parser) 61 | { 62 | $var = $parser->compiler->getNewPrefixVariable(); 63 | $tmp = $parser->compiler->appendCode('', $this->data); 64 | $tmp = $parser->compiler->appendCode($tmp, ""); 65 | $parser->compiler->prefix_code[] = sprintf('%s', $tmp); 66 | 67 | return $var; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /HServer/core/http/Response.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | namespace HServer\core\http; 10 | 11 | use Workerman\Connection\TcpConnection; 12 | use Workerman\Protocols\Http; 13 | 14 | class Response 15 | { 16 | /** 17 | * @var TcpConnection 18 | */ 19 | protected $connection; 20 | 21 | /** 22 | * @var bool 23 | */ 24 | private $sent; 25 | 26 | /** 27 | * Response constructor. 28 | * @param $connection 29 | */ 30 | public function __construct($connection) 31 | { 32 | $this->connection = $connection; 33 | $this->sent = false; 34 | } 35 | 36 | public function setHeader($content, $replace = true, $statusCode = 0) 37 | { 38 | return Http::header($content, $replace, $statusCode); 39 | } 40 | 41 | 42 | public function rmHeader($name) 43 | { 44 | Http::headerRemove($name); 45 | return true; 46 | } 47 | 48 | public function setContentType($type, $charset = "utf-8") 49 | { 50 | return Http::header("Content-Type: " . $type . ";charset=" . $charset); 51 | } 52 | 53 | /** 54 | * 发送静态文件 55 | * @param $data 56 | */ 57 | public function sendStaticFile($head, $data) 58 | { 59 | 60 | $this->setContentType($head); 61 | $this->send($data); 62 | } 63 | 64 | 65 | public function send($body = "") 66 | { 67 | $this->connection->send($body); 68 | $this->sent = true; 69 | } 70 | 71 | 72 | public function json($data) 73 | { 74 | $this->setContentType("application/json"); 75 | $data = json_encode($data, JSON_UNESCAPED_UNICODE); 76 | $this->send($data); 77 | } 78 | 79 | public function redirect($url, $statusCode = 302) 80 | { 81 | $this->setHeader("HTTP", true, $statusCode); 82 | $this->setHeader("Location: " . $url); 83 | $this->send(); 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Autoloader.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman; 15 | 16 | /** 17 | * Autoload. 18 | */ 19 | class Autoloader 20 | { 21 | /** 22 | * Autoload root path. 23 | * 24 | * @var string 25 | */ 26 | protected static $_autoloadRootPath = ''; 27 | 28 | /** 29 | * Set autoload root path. 30 | * 31 | * @param string $root_path 32 | * @return void 33 | */ 34 | public static function setRootPath($root_path) 35 | { 36 | self::$_autoloadRootPath = $root_path; 37 | } 38 | 39 | /** 40 | * Load files by namespace. 41 | * 42 | * @param string $name 43 | * @return boolean 44 | */ 45 | public static function loadByNamespace($name) 46 | { 47 | $class_path = str_replace('\\', DIRECTORY_SEPARATOR, $name); 48 | if (strpos($name, 'Workerman\\') === 0) { 49 | $class_file = __DIR__ . substr($class_path, strlen('Workerman')) . '.php'; 50 | } else { 51 | if (self::$_autoloadRootPath) { 52 | $class_file = self::$_autoloadRootPath . DIRECTORY_SEPARATOR . $class_path . '.php'; 53 | } 54 | if (empty($class_file) || !is_file($class_file)) { 55 | $class_file = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . "$class_path.php"; 56 | } 57 | } 58 | 59 | if (is_file($class_file)) { 60 | require_once($class_file); 61 | if (class_exists($name, false)) { 62 | return true; 63 | } 64 | } 65 | return false; 66 | } 67 | } 68 | 69 | spl_autoload_register('\Workerman\Autoloader::loadByNamespace'); -------------------------------------------------------------------------------- /vendor/smarty/plugins/function.counter.php: -------------------------------------------------------------------------------- 1 | 16 | * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} 17 | * (Smarty online manual) 18 | * 19 | * @param array $params parameters 20 | * @param Smarty_Internal_Template $template template object 21 | * 22 | * @return string|null 23 | */ 24 | function smarty_function_counter($params, $template) 25 | { 26 | static $counters = array(); 27 | 28 | $name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default'; 29 | if (!isset($counters[ $name ])) { 30 | $counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1); 31 | } 32 | $counter =& $counters[ $name ]; 33 | 34 | if (isset($params[ 'start' ])) { 35 | $counter[ 'start' ] = $counter[ 'count' ] = (int) $params[ 'start' ]; 36 | } 37 | 38 | if (!empty($params[ 'assign' ])) { 39 | $counter[ 'assign' ] = $params[ 'assign' ]; 40 | } 41 | 42 | if (isset($counter[ 'assign' ])) { 43 | $template->assign($counter[ 'assign' ], $counter[ 'count' ]); 44 | } 45 | 46 | if (isset($params[ 'print' ])) { 47 | $print = (bool) $params[ 'print' ]; 48 | } else { 49 | $print = empty($counter[ 'assign' ]); 50 | } 51 | 52 | if ($print) { 53 | $retval = $counter[ 'count' ]; 54 | } else { 55 | $retval = null; 56 | } 57 | 58 | if (isset($params[ 'skip' ])) { 59 | $counter[ 'skip' ] = $params[ 'skip' ]; 60 | } 61 | 62 | if (isset($params[ 'direction' ])) { 63 | $counter[ 'direction' ] = $params[ 'direction' ]; 64 | } 65 | 66 | if ($counter[ 'direction' ] === 'down') { 67 | $counter[ 'count' ] -= $counter[ 'skip' ]; 68 | } else { 69 | $counter[ 'count' ] += $counter[ 'skip' ]; 70 | } 71 | 72 | return $retval; 73 | } 74 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_eval.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 55 | if (isset($_attr[ 'assign' ])) { 56 | // output will be stored in a smarty variable instead of being displayed 57 | $_assign = $_attr[ 'assign' ]; 58 | } 59 | 60 | // create template object 61 | $_output = "\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);"; 62 | //was there an assign attribute? 63 | if (isset($_assign)) { 64 | $_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());"; 65 | } else { 66 | $_output .= 'echo $_template->fetch();'; 67 | } 68 | 69 | return ""; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_registerplugin.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 42 | if (isset($smarty->registered_plugins[ $type ][ $name ])) { 43 | throw new SmartyException("Plugin tag '{$name}' already registered"); 44 | } elseif (!is_callable($callback)) { 45 | throw new SmartyException("Plugin '{$name}' not callable"); 46 | } else { 47 | $smarty->registered_plugins[ $type ][ $name ] = array($callback, (bool) $cacheable, (array) $cache_attr); 48 | } 49 | return $obj; 50 | } 51 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HServer 2 | 3 | #### 介绍 4 | 5 | 基于 Workerman 而做的一款高并发 WebServer。单机2G 4核 7W+QPS 6 | 用他我们能干啥,做一个最求性能切功能简单的程序。麻雀虽小,但是以为我公司,完成短视频接口后台,口令后台的基本业务的程序支撑 7 | 如果你是一个Javaer或者喜欢java,可以关注下 8 | [![黑小马/HServer](https://gitee.com/heixiaomas_admin/HServer/widgets/widget_card.svg?colors=4183c4,ffffff,ffffff,e3e9ed,666666,9b9b9b)](https://gitee.com/heixiaomas_admin/HServer) 9 | 10 | #### 运行方式 11 | 12 | ```shell 13 | # 启动 14 | php start.php start 15 | 16 | # 停止 17 | php start.php stop 18 | 19 | # 状态查询 20 | php start.php status 21 | 22 | # 重启 23 | php start.php restart 24 | 25 | # 平滑重启 26 | php start.php reload 27 | ``` 28 | 29 | #### 配置文件 30 | 31 | 关于 redis 和 mysql 在 [Hserver/config/config.php](HServer/config/Config.php),配置好后开启就可以在控制器中使用了。 32 | 33 | #### 编写代码 34 | 35 | ##### 1.目录介绍和启动测试 36 | ``` 37 | ├─app #app是我们开发用最多的文件夹 38 | │ ├─action #控制器编写目录 39 | │ ├─filter #拦截器目录 40 | │ ├─static #静态文件目录 41 | │ ├─task #定时任务目录 42 | │ └─view #smart模板目录 43 | ├─HServer #HServer核心逻辑 44 | ├─log #程序跑飞时产生的日志文件 45 | ├─templates_c #模板生成的缓存目录 46 | └─vendor #框架库 47 | 48 | ``` 49 | - 更具平台对应启动HServer 50 | - 访问测试地址: 51 | http://127.0.0.1:8800/index/main 52 | http://127.0.0.1:8800/index/html 53 | - 你将看到最基本的HelloWord 54 | 55 | ##### 2.项目架构 56 | 57 | ![AB测试](https://gitee.com/heixiaomas/HServer/raw/master/app/static/img/f.png) 58 | 59 | ##### 3.路由规则 60 | 从app/action/开始进行规制计算 61 | 例子1: 62 | app/action/index.php 63 | index.php 里面有一个show()方法 64 | url: 65 | http://127.0.0.1/index/show 66 | ##### 4.控制器Action编写规则 67 | 68 | 1,文件必须必须放在/app/action/目录里面 69 | 2,该文件必须是一个类,同时继承HActionView类 70 | 3, 父类有很多方法封装,可以直接使用 71 | $Response,$Request,$DB,等等,具体看文件配置 72 | 73 | ##### 5.拦截器Filter编写规则 74 | 1,文件必须必须放在/app/filter/目录里面 75 | 2,该文件必须是一个类,同时继承HServerFilter类 76 | 4 $level级别定义 设置优先级,数字,越大,越先 77 | 5, 父类有很多方法封装,可以直接使用 78 | $Response,$Request,$DB,等等,具体看文件配置 79 | 80 | ##### 6.定时器task编写规则 81 | 1,文件必须必须放在/app/task/目录里面 82 | 2,该文件必须是一个类,同时继承HServerTask类 83 | 4 ,$time 延时定义单位秒 84 | 5,父类有很多方法封装,可以直接使用 85 | $DB,等等,具体看文件配置 86 | 87 | #### 更新日志 88 | 89 | 请查看 [CHANGELOG.md](CHANGELOG.md) 了解近期更新情况。 90 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_runtime_make_nocache.php: -------------------------------------------------------------------------------- 1 | tpl_vars[ $var ])) { 26 | $export = 27 | preg_replace('/^Smarty_Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true)); 28 | if (preg_match('/(\w+)::__set_state/', $export, $match)) { 29 | throw new SmartyException("{make_nocache \${$var}} in template '{$tpl->source->name}': variable does contain object '{$match[1]}' not implementing method '__set_state'"); 30 | } 31 | echo "/*%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/smarty->ext->_make_nocache->store(\$_smarty_tpl, '{$var}', ", '\\') . 33 | $export . ");?>\n/*/%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/"; 34 | } 35 | } 36 | 37 | /** 38 | * Store variable value saved while rendering compiled template in cached template context 39 | * 40 | * @param \Smarty_Internal_Template $tpl 41 | * @param string $var variable name 42 | * @param array $properties 43 | */ 44 | public function store(Smarty_Internal_Template $tpl, $var, $properties) 45 | { 46 | // do not overwrite existing nocache variables 47 | if (!isset($tpl->tpl_vars[ $var ]) || !$tpl->tpl_vars[ $var ]->nocache) { 48 | $newVar = new Smarty_Variable(); 49 | unset($properties[ 'nocache' ]); 50 | foreach ($properties as $k => $v) { 51 | $newVar->$k = $v; 52 | } 53 | $tpl->tpl_vars[ $var ] = $newVar; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_gettags.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 38 | if ($obj->_isTplObj() && !isset($template)) { 39 | $tpl = clone $obj; 40 | } elseif (isset($template) && $template->_isTplObj()) { 41 | $tpl = clone $template; 42 | } elseif (isset($template) && is_string($template)) { 43 | /* @var Smarty_Internal_Template $tpl */ 44 | $tpl = new $smarty->template_class($template, $smarty); 45 | // checks if template exists 46 | if (!$tpl->source->exists) { 47 | throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'"); 48 | } 49 | } 50 | if (isset($tpl)) { 51 | $tpl->smarty = clone $tpl->smarty; 52 | $tpl->smarty->_cache[ 'get_used_tags' ] = true; 53 | $tpl->_cache[ 'used_tags' ] = array(); 54 | $tpl->smarty->merge_compiled_includes = false; 55 | $tpl->smarty->disableSecurity(); 56 | $tpl->caching = Smarty::CACHING_OFF; 57 | $tpl->loadCompiler(); 58 | $tpl->compiler->compileTemplate($tpl); 59 | return $tpl->_cache[ 'used_tags' ]; 60 | } 61 | throw new SmartyException('Missing template specification'); 62 | } 63 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_addautoloadfilters.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 32 | if ($type !== null) { 33 | $this->_checkFilterType($type); 34 | if (!empty($smarty->autoload_filters[ $type ])) { 35 | $smarty->autoload_filters[ $type ] = array_merge($smarty->autoload_filters[ $type ], (array) $filters); 36 | } else { 37 | $smarty->autoload_filters[ $type ] = (array) $filters; 38 | } 39 | } else { 40 | foreach ((array) $filters as $type => $value) { 41 | $this->_checkFilterType($type); 42 | if (!empty($smarty->autoload_filters[ $type ])) { 43 | $smarty->autoload_filters[ $type ] = 44 | array_merge($smarty->autoload_filters[ $type ], (array) $value); 45 | } else { 46 | $smarty->autoload_filters[ $type ] = (array) $value; 47 | } 48 | } 49 | } 50 | return $obj; 51 | } 52 | } -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Events/EventInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Events; 15 | 16 | interface EventInterface 17 | { 18 | /** 19 | * Read event. 20 | * 21 | * @var int 22 | */ 23 | const EV_READ = 1; 24 | 25 | /** 26 | * Write event. 27 | * 28 | * @var int 29 | */ 30 | const EV_WRITE = 2; 31 | 32 | /** 33 | * Except event 34 | * 35 | * @var int 36 | */ 37 | const EV_EXCEPT = 3; 38 | 39 | /** 40 | * Signal event. 41 | * 42 | * @var int 43 | */ 44 | const EV_SIGNAL = 4; 45 | 46 | /** 47 | * Timer event. 48 | * 49 | * @var int 50 | */ 51 | const EV_TIMER = 8; 52 | 53 | /** 54 | * Timer once event. 55 | * 56 | * @var int 57 | */ 58 | const EV_TIMER_ONCE = 16; 59 | 60 | /** 61 | * Add event listener to event loop. 62 | * 63 | * @param mixed $fd 64 | * @param int $flag 65 | * @param callable $func 66 | * @param mixed $args 67 | * @return bool 68 | */ 69 | public function add($fd, $flag, $func, $args = null); 70 | 71 | /** 72 | * Remove event listener from event loop. 73 | * 74 | * @param mixed $fd 75 | * @param int $flag 76 | * @return bool 77 | */ 78 | public function del($fd, $flag); 79 | 80 | /** 81 | * Remove all timers. 82 | * 83 | * @return void 84 | */ 85 | public function clearAllTimer(); 86 | 87 | /** 88 | * Main loop. 89 | * 90 | * @return void 91 | */ 92 | public function loop(); 93 | 94 | /** 95 | * Destroy loop. 96 | * 97 | * @return mixed 98 | */ 99 | public function destroy(); 100 | 101 | /** 102 | * Get Timer count. 103 | * 104 | * @return mixed 105 | */ 106 | public function getTimerCount(); 107 | } 108 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifier.truncate.php: -------------------------------------------------------------------------------- 1 | 19 | * 20 | * @param string $string input string 21 | * @param integer $length length of truncated text 22 | * @param string $etc end string 23 | * @param boolean $break_words truncate at word boundary 24 | * @param boolean $middle truncate in the middle of text 25 | * 26 | * @return string truncated string 27 | */ 28 | function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) 29 | { 30 | if ($length === 0) { 31 | return ''; 32 | } 33 | 34 | if (Smarty::$_MBSTRING) { 35 | if (mb_strlen($string, Smarty::$_CHARSET) > $length) { 36 | $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); 37 | if (!$break_words && !$middle) { 38 | $string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', 39 | mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)); 40 | } 41 | if (!$middle) { 42 | return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; 43 | } 44 | 45 | return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . 46 | mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET); 47 | } 48 | 49 | return $string; 50 | } 51 | 52 | // no MBString fallback 53 | if (isset($string[ $length ])) { 54 | $length -= min($length, strlen($etc)); 55 | if (!$break_words && !$middle) { 56 | $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); 57 | } 58 | if (!$middle) { 59 | return substr($string, 0, $length) . $etc; 60 | } 61 | 62 | return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); 63 | } 64 | 65 | return $string; 66 | } 67 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_nocache.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 38 | $this->openTag($compiler, 'nocache', array($compiler->nocache)); 39 | // enter nocache mode 40 | $compiler->nocache = true; 41 | // this tag does not return compiled code 42 | $compiler->has_code = false; 43 | 44 | return true; 45 | } 46 | } 47 | 48 | /** 49 | * Smarty Internal Plugin Compile Nocacheclose Class 50 | * 51 | * @package Smarty 52 | * @subpackage Compiler 53 | */ 54 | class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase 55 | { 56 | /** 57 | * Compiles code for the {/nocache} tag 58 | * This tag does not generate compiled output. It only sets a compiler flag. 59 | * 60 | * @param array $args array with attributes from parser 61 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object 62 | * 63 | * @return bool 64 | */ 65 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) 66 | { 67 | $_attr = $this->getAttributes($compiler, $args); 68 | // leave nocache mode 69 | list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); 70 | // this tag does not return compiled code 71 | $compiler->has_code = false; 72 | 73 | return true; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_setfilter.php: -------------------------------------------------------------------------------- 1 | variable_filter_stack[] = $compiler->variable_filters; 31 | $compiler->variable_filters = $parameter[ 'modifier_list' ]; 32 | // this tag does not return compiled code 33 | $compiler->has_code = false; 34 | 35 | return true; 36 | } 37 | } 38 | 39 | /** 40 | * Smarty Internal Plugin Compile Setfilterclose Class 41 | * 42 | * @package Smarty 43 | * @subpackage Compiler 44 | */ 45 | class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase 46 | { 47 | /** 48 | * Compiles code for the {/setfilter} tag 49 | * This tag does not generate compiled output. It resets variable filter. 50 | * 51 | * @param array $args array with attributes from parser 52 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object 53 | * 54 | * @return string compiled code 55 | */ 56 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) 57 | { 58 | $_attr = $this->getAttributes($compiler, $args); 59 | // reset variable filter to previous state 60 | if (count($compiler->variable_filter_stack)) { 61 | $compiler->variable_filters = array_pop($compiler->variable_filter_stack); 62 | } else { 63 | $compiler->variable_filters = array(); 64 | } 65 | // this tag does not return compiled code 66 | $compiler->has_code = false; 67 | 68 | return true; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_setautoloadfilters.php: -------------------------------------------------------------------------------- 1 | true, 'post' => true, 'output' => true, 'variable' => true); 27 | 28 | /** 29 | * Set autoload filters 30 | * 31 | * @api Smarty::setAutoloadFilters() 32 | * 33 | * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj 34 | * @param array $filters filters to load automatically 35 | * @param string $type "pre", "output", … specify the 36 | * filter type to set. Defaults to 37 | * none treating $filters' keys as 38 | * the appropriate types 39 | * 40 | * @return \Smarty|\Smarty_Internal_Template 41 | * @throws \SmartyException 42 | */ 43 | public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null) 44 | { 45 | $smarty = $obj->_getSmartyObj(); 46 | if ($type !== null) { 47 | $this->_checkFilterType($type); 48 | $smarty->autoload_filters[ $type ] = (array) $filters; 49 | } else { 50 | foreach ((array) $filters as $type => $value) { 51 | $this->_checkFilterType($type); 52 | } 53 | $smarty->autoload_filters = (array) $filters; 54 | } 55 | return $obj; 56 | } 57 | 58 | /** 59 | * Check if filter type is valid 60 | * 61 | * @param string $type 62 | * 63 | * @throws \SmartyException 64 | */ 65 | public function _checkFilterType($type) 66 | { 67 | if (!isset($this->filterTypes[ $type ])) { 68 | throw new SmartyException("Illegal filter type '{$type}'"); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_loadfilter.php: -------------------------------------------------------------------------------- 1 | true, 'post' => true, 'output' => true, 'variable' => true); 27 | 28 | /** 29 | * load a filter of specified type and name 30 | * 31 | * @api Smarty::loadFilter() 32 | * 33 | * @link http://www.smarty.net/docs/en/api.load.filter.tpl 34 | * 35 | * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj 36 | * @param string $type filter type 37 | * @param string $name filter name 38 | * 39 | * @return bool 40 | * @throws SmartyException if filter could not be loaded 41 | */ 42 | public function loadFilter(Smarty_Internal_TemplateBase $obj, $type, $name) 43 | { 44 | $smarty = $obj->_getSmartyObj(); 45 | $this->_checkFilterType($type); 46 | $_plugin = "smarty_{$type}filter_{$name}"; 47 | $_filter_name = $_plugin; 48 | if (is_callable($_plugin)) { 49 | $smarty->registered_filters[ $type ][ $_filter_name ] = $_plugin; 50 | return true; 51 | } 52 | if ($smarty->loadPlugin($_plugin)) { 53 | if (class_exists($_plugin, false)) { 54 | $_plugin = array($_plugin, 'execute'); 55 | } 56 | if (is_callable($_plugin)) { 57 | $smarty->registered_filters[ $type ][ $_filter_name ] = $_plugin; 58 | return true; 59 | } 60 | } 61 | throw new SmartyException("{$type}filter '{$name}' not found or callable"); 62 | } 63 | 64 | /** 65 | * Check if filter type is valid 66 | * 67 | * @param string $type 68 | * 69 | * @throws \SmartyException 70 | */ 71 | public function _checkFilterType($type) 72 | { 73 | if (!isset($this->filterTypes[ $type ])) { 74 | throw new SmartyException("Illegal filter type '{$type}'"); 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifier.mb_wordwrap.php: -------------------------------------------------------------------------------- 1 | $width) { 38 | if ($cut) { 39 | $_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, 40 | $_token, 41 | -1, 42 | PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); 43 | } 44 | } 45 | 46 | foreach ($_tokens as $token) { 47 | $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); 48 | $token_length = mb_strlen($token, Smarty::$_CHARSET); 49 | $length += $token_length; 50 | 51 | if ($length > $width) { 52 | // remove space before inserted break 53 | if ($_previous) { 54 | $t = mb_substr($t, 0, -1, Smarty::$_CHARSET); 55 | } 56 | 57 | if (!$_space) { 58 | // add the break before the token 59 | if (!empty($t)) { 60 | $t .= $break; 61 | } 62 | $length = $token_length; 63 | } 64 | } else if ($token === "\n") { 65 | // hard break must reset counters 66 | $length = 0; 67 | } 68 | $_previous = $_space; 69 | // add the token 70 | $t .= $token; 71 | } 72 | } 73 | 74 | return $t; 75 | } 76 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_child.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase 17 | { 18 | /** 19 | * Attribute definition: Overwrites base class. 20 | * 21 | * @var array 22 | * @see Smarty_Internal_CompileBase 23 | */ 24 | public $optional_attributes = array('assign'); 25 | 26 | /** 27 | * Tag name 28 | * 29 | * @var string 30 | */ 31 | public $tag = 'child'; 32 | 33 | /** 34 | * Block type 35 | * 36 | * @var string 37 | */ 38 | public $blockType = 'Child'; 39 | 40 | /** 41 | * Compiles code for the {child} tag 42 | * 43 | * @param array $args array with attributes from parser 44 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object 45 | * @param array $parameter array with compilation parameter 46 | * 47 | * @return string compiled code 48 | * @throws \SmartyCompilerException 49 | */ 50 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) 51 | { 52 | // check and get attributes 53 | $_attr = $this->getAttributes($compiler, $args); 54 | $tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'"; 55 | if (!isset($compiler->_cache[ 'blockNesting' ])) { 56 | $compiler->trigger_template_error("{$tag} used outside {block} tags ", 57 | $compiler->parser->lex->taglineno); 58 | } 59 | $compiler->has_code = true; 60 | $compiler->suppressNocacheProcessing = true; 61 | if ($this->blockType === 'Child') { 62 | $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true'; 63 | } 64 | $_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null; 65 | $output = "inheritance->call' . $this->blockType . '($_smarty_tpl, $this' . 70 | ($this->blockType === 'Child' ? '' : ", {$tag}"). ");\n"; 71 | if (isset($_assign)) { 72 | $output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; 73 | } 74 | $output .="?>\n"; 75 | return $output; 76 | } 77 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_resource_recompiled.php: -------------------------------------------------------------------------------- 1 | compiled; 43 | $compiled->file_dependency = array(); 44 | $compiled->includes = array(); 45 | $compiled->nocache_hash = null; 46 | $compiled->unifunc = null; 47 | $level = ob_get_level(); 48 | ob_start(); 49 | $_smarty_tpl->loadCompiler(); 50 | // call compiler 51 | try { 52 | eval('?>' . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl)); 53 | } 54 | catch (Exception $e) { 55 | unset($_smarty_tpl->compiler); 56 | while (ob_get_level() > $level) { 57 | ob_end_clean(); 58 | } 59 | throw $e; 60 | } 61 | // release compiler object to free memory 62 | unset($_smarty_tpl->compiler); 63 | ob_get_clean(); 64 | $compiled->timestamp = time(); 65 | $compiled->exists = true; 66 | } 67 | 68 | /** 69 | * populate Compiled Object with compiled filepath 70 | * 71 | * @param Smarty_Template_Compiled $compiled compiled object 72 | * @param Smarty_Internal_Template $_template template object 73 | * 74 | * @return void 75 | */ 76 | public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template) 77 | { 78 | $compiled->filepath = false; 79 | $compiled->timestamp = false; 80 | $compiled->exists = false; 81 | } 82 | 83 | /* 84 | * Disable timestamp checks for recompiled resource. 85 | * 86 | * @return bool 87 | */ 88 | /** 89 | * @return bool 90 | */ 91 | public function checkTimestamps() 92 | { 93 | return false; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_compile_private_function_plugin.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 52 | 53 | unset($_attr[ 'nocache' ]); 54 | // convert attributes into parameter array string 55 | $_paramsArray = array(); 56 | foreach ($_attr as $_key => $_value) { 57 | if (is_int($_key)) { 58 | $_paramsArray[] = "$_key=>$_value"; 59 | } else { 60 | $_paramsArray[] = "'$_key'=>$_value"; 61 | } 62 | } 63 | $_params = 'array(' . implode(',', $_paramsArray) . ')'; 64 | // compile code 65 | $output = "{$function}({$_params},\$_smarty_tpl)"; 66 | if (!empty($parameter[ 'modifierlist' ])) { 67 | $output = $compiler->compileTag('private_modifier', array(), 68 | array('modifierlist' => $parameter[ 'modifierlist' ], 69 | 'value' => $output)); 70 | } 71 | $output = "\n"; 72 | return $output; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_resource_stream.php: -------------------------------------------------------------------------------- 1 | resource, '://') !== false) { 34 | $source->filepath = $source->resource; 35 | } else { 36 | $source->filepath = str_replace(':', '://', $source->resource); 37 | } 38 | $source->uid = false; 39 | $source->content = $this->getContent($source); 40 | $source->timestamp = $source->exists = !!$source->content; 41 | } 42 | 43 | /** 44 | * Load template's source from stream into current template object 45 | * 46 | * @param Smarty_Template_Source $source source object 47 | * 48 | * @return string template source 49 | * @throws SmartyException if source cannot be loaded 50 | */ 51 | public function getContent(Smarty_Template_Source $source) 52 | { 53 | $t = ''; 54 | // the availability of the stream has already been checked in Smarty_Resource::fetch() 55 | $fp = fopen($source->filepath, 'r+'); 56 | if ($fp) { 57 | while (!feof($fp) && ($current_line = fgets($fp)) !== false) { 58 | $t .= $current_line; 59 | } 60 | fclose($fp); 61 | 62 | return $t; 63 | } else { 64 | return false; 65 | } 66 | } 67 | 68 | /** 69 | * modify resource_name according to resource handlers specifications 70 | * 71 | * @param Smarty $smarty Smarty instance 72 | * @param string $resource_name resource_name to make unique 73 | * @param boolean $isConfig flag for config resource 74 | * 75 | * @return string unique resource name 76 | */ 77 | public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) 78 | { 79 | return get_class($this) . '#' . $resource_name; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /HServer/core/http/Link.php: -------------------------------------------------------------------------------- 1 | $setRequest($req); 32 | $Obj->$setResponse($resp); 33 | $Obj->$method(); 34 | } 35 | } catch (\Throwable $exception) { 36 | echo "404->" . $exception->getMessage(); 37 | } 38 | return; 39 | } 40 | 41 | $map = array(); 42 | /** 43 | * 扫描Filter文件路径 44 | */ 45 | $path = __DIR__ . "/../../../app/filter/"; 46 | $filterFile = scandir($path); 47 | foreach ($filterFile as $filename) { 48 | if ($filename != '.' && $filename != '..' && $filename . strpos($filename, 'php') !== false) { 49 | $classname = substr($filename, 0, -4); 50 | 51 | $class = new \ReflectionClass($classname); 52 | $filter = $class->newInstanceArgs(); 53 | if ($class->hasMethod("auth")) { 54 | 55 | $setRequest = $class->getMethod("setRequest"); 56 | $setRequest->setAccessible(true); 57 | $setRequest->invoke($filter, $req); 58 | 59 | $setResponse = $class->getMethod("setResponse"); 60 | $setResponse->setAccessible(true); 61 | $setResponse->invoke($filter, $resp); 62 | 63 | $level = $class->getProperty('level'); 64 | $level->setAccessible(true); 65 | $index = $level->getValue($filter); 66 | 67 | $a = array("level" => $index, "filter" => $filter, "class" => $class); 68 | $map[] = $a; 69 | array_multisort(array_column($map, 'level'), SORT_DESC, $map); 70 | 71 | } else { 72 | echo "无拦截器"; 73 | } 74 | } 75 | } 76 | 77 | Container::addBean($benName, $map); 78 | foreach ($map as $m) { 79 | $auth = $m['class']->getMethod("auth"); 80 | $auth->setAccessible(true); 81 | $auth->invoke($m['filter']); 82 | } 83 | } 84 | 85 | 86 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_registerfilter.php: -------------------------------------------------------------------------------- 1 | true, 'post' => true, 'output' => true, 'variable' => true); 27 | 28 | /** 29 | * Registers a filter function 30 | * 31 | * @api Smarty::registerFilter() 32 | * 33 | * @link http://www.smarty.net/docs/en/api.register.filter.tpl 34 | * 35 | * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj 36 | * @param string $type filter type 37 | * @param callback $callback 38 | * @param string|null $name optional filter name 39 | * 40 | * @return \Smarty|\Smarty_Internal_Template 41 | * @throws \SmartyException 42 | */ 43 | public function registerFilter(Smarty_Internal_TemplateBase $obj, $type, $callback, $name = null) 44 | { 45 | $smarty = $obj->_getSmartyObj(); 46 | $this->_checkFilterType($type); 47 | $name = isset($name) ? $name : $this->_getFilterName($callback); 48 | if (!is_callable($callback)) { 49 | throw new SmartyException("{$type}filter '{$name}' not callable"); 50 | } 51 | $smarty->registered_filters[ $type ][ $name ] = $callback; 52 | return $obj; 53 | } 54 | 55 | /** 56 | * Return internal filter name 57 | * 58 | * @param callback $function_name 59 | * 60 | * @return string internal filter name 61 | */ 62 | public function _getFilterName($function_name) 63 | { 64 | if (is_array($function_name)) { 65 | $_class_name = (is_object($function_name[ 0 ]) ? get_class($function_name[ 0 ]) : $function_name[ 0 ]); 66 | 67 | return $_class_name . '_' . $function_name[ 1 ]; 68 | } elseif (is_string($function_name)) { 69 | return $function_name; 70 | } else { 71 | return 'closure'; 72 | } 73 | } 74 | 75 | /** 76 | * Check if filter type is valid 77 | * 78 | * @param string $type 79 | * 80 | * @throws \SmartyException 81 | */ 82 | public function _checkFilterType($type) 83 | { 84 | if (!isset($this->filterTypes[ $type ])) { 85 | throw new SmartyException("Illegal filter type '{$type}'"); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_runtime_cachemodify.php: -------------------------------------------------------------------------------- 1 | isCached() && !$_template->compiled->has_nocache_code; 26 | $_last_modified_date = 27 | @substr($_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ], 0, strpos($_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ], 'GMT') + 3); 28 | if ($_isCached && $cached->timestamp <= strtotime($_last_modified_date)) { 29 | switch (PHP_SAPI) { 30 | case 'cgi': // php-cgi < 5.3 31 | case 'cgi-fcgi': // php-cgi >= 5.3 32 | case 'fpm-fcgi': // php-fpm >= 5.3.3 33 | header('Status: 304 Not Modified'); 34 | break; 35 | 36 | case 'cli': 37 | if ( /* ^phpunit */ 38 | !empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */ 39 | ) { 40 | $_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = '304 Not Modified'; 41 | } 42 | break; 43 | 44 | default: 45 | if ( /* ^phpunit */ 46 | !empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */ 47 | ) { 48 | $_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = '304 Not Modified'; 49 | } else { 50 | header($_SERVER[ 'SERVER_PROTOCOL' ] . ' 304 Not Modified'); 51 | } 52 | break; 53 | } 54 | } else { 55 | switch (PHP_SAPI) { 56 | case 'cli': 57 | if ( /* ^phpunit */ 58 | !empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */ 59 | ) { 60 | $_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = 61 | 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT'; 62 | } 63 | break; 64 | default: 65 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT'); 66 | break; 67 | } 68 | echo $content; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /HServer/core/view/Dispatcher.php: -------------------------------------------------------------------------------- 1 | getFullUri()); 23 | $path = null; 24 | $size = count($paths); 25 | if ($size > 2) { 26 | $boo = strpos($paths[$size - 1], "?"); 27 | if ($boo > 0) { 28 | $paths[$size - 1] = substr($paths[$size - 1], 0, $boo); 29 | } 30 | } 31 | $classname = $paths[$size - 2]; 32 | for ($i = 0; $i < $size - 1; $i++) { 33 | if (strlen($paths[$i]) > 0) { 34 | $path .= "/" . $paths[$i]; 35 | } 36 | } 37 | 38 | $path = __DIR__ . "/../../../app/action" . $path . ".php"; 39 | if (count($paths) > 2 && is_file($path)) { 40 | /** 41 | * 判断容器, 42 | */ 43 | if (Container::exist($classname)) { 44 | try { 45 | $Obj = Container::getBean($classname); 46 | $setResponse = "setResponse"; 47 | $setRequest = "setRequest"; 48 | $method = $paths[$size - 1]; 49 | $Obj->$setRequest($req); 50 | $Obj->$setResponse($resp); 51 | $Obj->$method(); 52 | } catch (\Throwable $exception) { 53 | $resp->send("404->" . $exception->getMessage()); 54 | } 55 | return; 56 | } 57 | 58 | /** 59 | * 首次加载 60 | */ 61 | $class = new \ReflectionClass($classname); 62 | $controller = $class->newInstanceArgs(); 63 | Container::addBean($classname, $controller); 64 | if ($class->hasMethod($paths[$size - 1])) { 65 | try { 66 | $setResponse = $class->getMethod("setResponse"); 67 | $setRequest = $class->getMethod("setRequest"); 68 | /** 69 | * 反射传入request和response 70 | */ 71 | $setRequest->setAccessible(true); 72 | $setRequest->invoke($controller, $req); 73 | $setResponse->setAccessible(true); 74 | $setResponse->invoke($controller, $resp); 75 | 76 | $method = $class->getMethod($paths[$size - 1]); 77 | $method->invoke($controller); 78 | } catch (\Throwable $exception) { 79 | $resp->send("404->" . $exception->getMessage()); 80 | } 81 | } else { 82 | $resp->send("404"); 83 | } 84 | } else { 85 | $resp->send("无法访问控制器--->首页路径"); 86 | } 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /vendor/wokerman/workerman/Connection/ConnectionInterface.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Workerman\Connection; 15 | 16 | /** 17 | * ConnectionInterface. 18 | */ 19 | abstract class ConnectionInterface 20 | { 21 | /** 22 | * Statistics for status command. 23 | * 24 | * @var array 25 | */ 26 | public static $statistics = array( 27 | 'connection_count' => 0, 28 | 'total_request' => 0, 29 | 'throw_exception' => 0, 30 | 'send_fail' => 0, 31 | ); 32 | 33 | /** 34 | * Emitted when data is received. 35 | * 36 | * @var callback 37 | */ 38 | public $onMessage = null; 39 | 40 | /** 41 | * Emitted when the other end of the socket sends a FIN packet. 42 | * 43 | * @var callback 44 | */ 45 | public $onClose = null; 46 | 47 | /** 48 | * Emitted when an error occurs with connection. 49 | * 50 | * @var callback 51 | */ 52 | public $onError = null; 53 | 54 | /** 55 | * Sends data on the connection. 56 | * 57 | * @param string $send_buffer 58 | * @return void|boolean 59 | */ 60 | abstract public function send($send_buffer); 61 | 62 | /** 63 | * Get remote IP. 64 | * 65 | * @return string 66 | */ 67 | abstract public function getRemoteIp(); 68 | 69 | /** 70 | * Get remote port. 71 | * 72 | * @return int 73 | */ 74 | abstract public function getRemotePort(); 75 | 76 | /** 77 | * Get remote address. 78 | * 79 | * @return string 80 | */ 81 | abstract public function getRemoteAddress(); 82 | 83 | /** 84 | * Get local IP. 85 | * 86 | * @return string 87 | */ 88 | abstract public function getLocalIp(); 89 | 90 | /** 91 | * Get local port. 92 | * 93 | * @return int 94 | */ 95 | abstract public function getLocalPort(); 96 | 97 | /** 98 | * Get local address. 99 | * 100 | * @return string 101 | */ 102 | abstract public function getLocalAddress(); 103 | 104 | /** 105 | * Is ipv4. 106 | * 107 | * @return bool 108 | */ 109 | abstract public function isIPv4(); 110 | 111 | /** 112 | * Is ipv6. 113 | * 114 | * @return bool 115 | */ 116 | abstract public function isIPv6(); 117 | 118 | /** 119 | * Close connection. 120 | * 121 | * @param $data 122 | * @return void 123 | */ 124 | abstract public function close($data = null); 125 | } 126 | -------------------------------------------------------------------------------- /vendor/smarty/plugins/modifier.date_format.php: -------------------------------------------------------------------------------- 1 | 21 | * 22 | * @param string $string input date string 23 | * @param string $format strftime format for output 24 | * @param string $default_date default date if $string is empty 25 | * @param string $formatter either 'strftime' or 'auto' 26 | * 27 | * @return string |void 28 | * @uses smarty_make_timestamp() 29 | */ 30 | function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto') 31 | { 32 | if ($format === null) { 33 | $format = Smarty::$_DATE_FORMAT; 34 | } 35 | /** 36 | * require_once the {@link shared.make_timestamp.php} plugin 37 | */ 38 | static $is_loaded = false; 39 | if (!$is_loaded) { 40 | if (!is_callable('smarty_make_timestamp')) { 41 | require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); 42 | } 43 | $is_loaded = true; 44 | } 45 | if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') { 46 | $timestamp = smarty_make_timestamp($string); 47 | } elseif ($default_date !== '') { 48 | $timestamp = smarty_make_timestamp($default_date); 49 | } else { 50 | return; 51 | } 52 | if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) { 53 | if (Smarty::$_IS_WINDOWS) { 54 | $_win_from = array('%D', 55 | '%h', 56 | '%n', 57 | '%r', 58 | '%R', 59 | '%t', 60 | '%T'); 61 | $_win_to = array('%m/%d/%y', 62 | '%b', 63 | "\n", 64 | '%I:%M:%S %p', 65 | '%H:%M', 66 | "\t", 67 | '%H:%M:%S'); 68 | if (strpos($format, '%e') !== false) { 69 | $_win_from[] = '%e'; 70 | $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); 71 | } 72 | if (strpos($format, '%l') !== false) { 73 | $_win_from[] = '%l'; 74 | $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); 75 | } 76 | $format = str_replace($_win_from, $_win_to, $format); 77 | } 78 | 79 | return strftime($format, $timestamp); 80 | } else { 81 | return date($format, $timestamp); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /vendor/smarty/sysplugins/smarty_internal_method_append.php: -------------------------------------------------------------------------------- 1 | $_val) { 41 | if ($_key !== '') { 42 | $this->append($data, $_key, $_val, $merge, $nocache); 43 | } 44 | } 45 | } else { 46 | if ($tpl_var !== '' && isset($value)) { 47 | if (!isset($data->tpl_vars[ $tpl_var ])) { 48 | $tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false); 49 | if ($tpl_var_inst instanceof Smarty_Undefined_Variable) { 50 | $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); 51 | } else { 52 | $data->tpl_vars[ $tpl_var ] = clone $tpl_var_inst; 53 | } 54 | } 55 | if (!(is_array($data->tpl_vars[ $tpl_var ]->value) || 56 | $data->tpl_vars[ $tpl_var ]->value instanceof ArrayAccess) 57 | ) { 58 | settype($data->tpl_vars[ $tpl_var ]->value, 'array'); 59 | } 60 | if ($merge && is_array($value)) { 61 | foreach ($value as $_mkey => $_mval) { 62 | $data->tpl_vars[ $tpl_var ]->value[ $_mkey ] = $_mval; 63 | } 64 | } else { 65 | $data->tpl_vars[ $tpl_var ]->value[] = $value; 66 | } 67 | } 68 | if ($data->_isTplObj() && $data->scope) { 69 | $data->ext->_updateScope->_updateScope($data, $tpl_var); 70 | } 71 | } 72 | return $data; 73 | } 74 | } --------------------------------------------------------------------------------