├── DqWeb ├── templates │ ├── footer.tpl │ ├── .DS_Store │ ├── header.tpl │ ├── topic_list.tpl │ └── index.tpl ├── .DS_Store ├── configs │ └── test.conf ├── bootstrap.min.css.php ├── check.php ├── libs │ ├── 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_variable.php │ │ ├── smarty_internal_parsetree_dqcontent.php │ │ ├── smarty_internal_method_compileallconfig.php │ │ ├── smarty_internal_parsetree.php │ │ ├── smarty_internal_method_clearconfig.php │ │ ├── smarty_internal_method_clearallcache.php │ │ ├── smarty_internal_method_setdefaultmodifiers.php │ │ ├── smarty_internal_compile_ldelim.php │ │ ├── smarty_internal_method_setdebugtemplate.php │ │ ├── smarty_internal_method_unregisterresource.php │ │ ├── smarty_internal_method_unregisterobject.php │ │ ├── smarty_internal_compile_debug.php │ │ ├── smarty_internal_method_unregistercacheresource.php │ │ ├── smarty_internal_method_clearassign.php │ │ ├── smarty_internal_method_getglobal.php │ │ ├── smarty_internal_method_unregisterplugin.php │ │ ├── smarty_internal_method_adddefaultmodifiers.php │ │ ├── smarty_internal_method_registercacheresource.php │ │ ├── smarty_internal_method_registerdefaultconfighandler.php │ │ ├── smarty_internal_method_assignbyref.php │ │ ├── smarty_internal_method_registerdefaultpluginhandler.php │ │ ├── smarty_internal_method_getstreamvariable.php │ │ ├── smarty_internal_method_clearcache.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_assignglobal.php │ │ ├── smarty_internal_method_unloadfilter.php │ │ ├── smarty_resource_uncompiled.php │ │ ├── smarty_internal_method_registerclass.php │ │ ├── smarty_internal_method_unregisterfilter.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_compile_shared_inheritance.php │ │ ├── smarty_internal_block.php │ │ ├── smarty_internal_method_registerresource.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_loadfilter.php │ │ ├── smarty_internal_method_setautoloadfilters.php │ │ ├── smarty_internal_resource_stream.php │ │ ├── smarty_resource_recompiled.php │ │ ├── smarty_internal_compile_child.php │ │ ├── smarty_internal_compile_private_function_plugin.php │ │ ├── smarty_internal_method_registerfilter.php │ │ └── smarty_internal_runtime_cachemodify.php │ ├── plugins │ │ ├── modifiercompiler.noprint.php │ │ ├── variablefilter.htmlspecialchars.php │ │ ├── modifiercompiler.string_format.php │ │ ├── modifiercompiler.cat.php │ │ ├── modifiercompiler.count_paragraphs.php │ │ ├── modifiercompiler.upper.php │ │ ├── modifiercompiler.indent.php │ │ ├── modifiercompiler.strip_tags.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 └── plugins │ ├── cacheresource.pdo_gzip.php │ ├── resource.extendsall.php │ ├── cacheresource.apc.php │ ├── resource.mysqls.php │ └── cacheresource.memcache.php ├── .DS_Store ├── images ├── list.png ├── scan.png ├── .DS_Store ├── index.png ├── jiagou.png ├── topic.png ├── topic2.png ├── xieru.png ├── redisdown.png ├── topiclist.png ├── warning.png ├── xiaofei.png └── delaythird.png ├── dq_stop.sh ├── DqException.php ├── DqLoader.php ├── java ├── src │ └── main │ │ └── java │ │ └── com │ │ └── phpdelayqueue │ │ ├── DqRequestAdd.java │ │ ├── DqResponse.java │ │ ├── DqRequestBase.java │ │ ├── DqConfig.java │ │ ├── SocketUtil.java │ │ └── DqClient.java └── pom.xml ├── demo.php ├── DqHttpServer.php ├── DqAlert.php ├── dq.sql ├── DqLog.php ├── DqBench.php ├── test_swoole_bench.php ├── test_swoole_server.php ├── DqInit.php ├── .gitignore ├── DqComm.php └── DqSwooleClient.php /DqWeb/templates/footer.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/.DS_Store -------------------------------------------------------------------------------- /DqWeb/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/DqWeb/.DS_Store -------------------------------------------------------------------------------- /images/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/list.png -------------------------------------------------------------------------------- /images/scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/scan.png -------------------------------------------------------------------------------- /images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/.DS_Store -------------------------------------------------------------------------------- /images/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/index.png -------------------------------------------------------------------------------- /images/jiagou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/jiagou.png -------------------------------------------------------------------------------- /images/topic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/topic.png -------------------------------------------------------------------------------- /images/topic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/topic2.png -------------------------------------------------------------------------------- /images/xieru.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/xieru.png -------------------------------------------------------------------------------- /images/redisdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/redisdown.png -------------------------------------------------------------------------------- /images/topiclist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/topiclist.png -------------------------------------------------------------------------------- /images/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/warning.png -------------------------------------------------------------------------------- /images/xiaofei.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/xiaofei.png -------------------------------------------------------------------------------- /DqWeb/configs/test.conf: -------------------------------------------------------------------------------- 1 | title = Welcome to Smarty! 2 | cutoff_size = 40 3 | 4 | [setup] 5 | bold = true 6 | -------------------------------------------------------------------------------- /dq_stop.sh: -------------------------------------------------------------------------------- 1 | ps -ef | grep dq-master| grep -v grep | head -n 1 | awk '{print $2}' | xargs kill -USR2 2 | 3 | -------------------------------------------------------------------------------- /images/delaythird.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/images/delaythird.png -------------------------------------------------------------------------------- /DqWeb/templates/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenlinzhong/php-delayqueue/HEAD/DqWeb/templates/.DS_Store -------------------------------------------------------------------------------- /DqWeb/templates/header.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | {$title} - {$Name} 4 | 5 | 6 | -------------------------------------------------------------------------------- /DqWeb/bootstrap.min.css.php: -------------------------------------------------------------------------------- 1 | getFile().' line:'.$this->getLine().' '.$this->getMessage(); 9 | } 10 | } -------------------------------------------------------------------------------- /DqLoader.php: -------------------------------------------------------------------------------- 1 | 1,'msg'=>'可以使用')); 17 | }else{ 18 | echo json_encode(array('code'=>2,'msg'=>'topic已存在')); 19 | } -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smartyexception.php: -------------------------------------------------------------------------------- 1 | Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.noprint.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 在线尝试 Bootstrap 实例 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Hello, world!

13 | 14 | 15 | -------------------------------------------------------------------------------- /DqWeb/libs/bootstrap.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 | * Load and register Smarty Autoloader 12 | */ 13 | if (!class_exists('Smarty_Autoloader')) { 14 | include dirname(__FILE__) . '/Autoloader.php'; 15 | } 16 | Smarty_Autoloader::register(true); 17 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 25 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.string_format.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child 17 | { 18 | /** 19 | * Tag name 20 | * 21 | * @var string 22 | */ 23 | public $tag = 'parent'; 24 | 25 | /** 26 | * Block type 27 | * 28 | * @var string 29 | */ 30 | public $blockType = 'Parent'; 31 | } 32 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 32 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.count_paragraphs.php: -------------------------------------------------------------------------------- 1 | ]*?>!', ' ', {$params[0]})"; 25 | } else { 26 | return 'strip_tags(' . $params[ 0 ] . ')'; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.lower.php: -------------------------------------------------------------------------------- 1 | 16 | * @author Uwe Tews 17 | * 18 | * @param array $params parameters 19 | * 20 | * @return string with compiled code 21 | */ 22 | function smarty_modifiercompiler_lower($params) 23 | { 24 | if (Smarty::$_MBSTRING) { 25 | return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; 26 | } 27 | // no MBString fallback 28 | return 'strtolower(' . $params[ 0 ] . ')'; 29 | } 30 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifier.spacify.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @param string $string input string 18 | * @param string $spacify_char string to insert between characters. 19 | * 20 | * @return string 21 | */ 22 | function smarty_modifier_spacify($string, $spacify_char = ' ') 23 | { 24 | // well… what about charsets besides latin and UTF-8? 25 | return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); 26 | } 27 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.count_sentences.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 33 | return $smarty->debug_tpl; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.from_charset.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 33 | return $smarty->default_modifiers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.strip.php: -------------------------------------------------------------------------------- 1 | tpl_vars = array(); 34 | return $data; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /java/src/main/java/com/phpdelayqueue/DqResponse.java: -------------------------------------------------------------------------------- 1 | package com.phpdelayqueue; 2 | 3 | import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 4 | import org.apache.commons.lang3.builder.ToStringStyle; 5 | 6 | public class DqResponse { 7 | private Integer code; 8 | private String msg; 9 | private T data; 10 | 11 | @Override 12 | public String toString() { 13 | return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE); 14 | } 15 | 16 | public String getMsg() { 17 | return msg; 18 | } 19 | 20 | public void setMsg(String msg) { 21 | this.msg = msg; 22 | } 23 | 24 | public T getData() { 25 | return data; 26 | } 27 | 28 | public void setData(T data) { 29 | this.data = data; 30 | } 31 | 32 | public Integer getCode() { 33 | return code; 34 | } 35 | 36 | public void setCode(Integer code) { 37 | this.code = code; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /java/src/main/java/com/phpdelayqueue/DqRequestBase.java: -------------------------------------------------------------------------------- 1 | package com.phpdelayqueue; 2 | 3 | import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 4 | import org.apache.commons.lang3.builder.ToStringStyle; 5 | 6 | public class DqRequestBase { 7 | protected String cmd; 8 | protected String topic; 9 | protected String id; 10 | 11 | @Override 12 | public String toString() { 13 | return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE); 14 | } 15 | 16 | public String getCmd() { 17 | return cmd; 18 | } 19 | 20 | public void setCmd(String cmd) { 21 | this.cmd = cmd; 22 | } 23 | 24 | public String getTopic() { 25 | return topic; 26 | } 27 | 28 | public void setTopic(String topic) { 29 | this.topic = topic; 30 | } 31 | 32 | public String getId() { 33 | return id; 34 | } 35 | 36 | public void setId(String id) { 37 | this.id = id; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_parsetree_text.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 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_compile_rdelim.php: -------------------------------------------------------------------------------- 1 | smarty->right_delimiter; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.count_characters.php: -------------------------------------------------------------------------------- 1 | ext->configLoad->_getConfigVariable($data, $varName, $errorEnable); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.count_words.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @param string $string text that should by escaped 17 | * 18 | * @return string 19 | */ 20 | function smarty_function_escape_special_chars($string) 21 | { 22 | if (!is_array($string)) { 23 | if (version_compare(PHP_VERSION, '5.2.3', '>=')) { 24 | $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); 25 | } else { 26 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); 27 | $string = htmlspecialchars($string); 28 | $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); 29 | } 30 | } 31 | return $string; 32 | } 33 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_variable.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 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_compileallconfig.php: -------------------------------------------------------------------------------- 1 | compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors, true); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_parsetree.php: -------------------------------------------------------------------------------- 1 | data = null; 48 | $this->subtrees = null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifier.replace.php: -------------------------------------------------------------------------------- 1 | 16 | * @author Uwe Tews 17 | * 18 | * @param string $string input string 19 | * @param string $search text to search for 20 | * @param string $replace replacement text 21 | * 22 | * @return string 23 | */ 24 | function smarty_modifier_replace($string, $search, $replace) 25 | { 26 | static $is_loaded = false; 27 | if (Smarty::$_MBSTRING) { 28 | if (!$is_loaded) { 29 | if (!is_callable('smarty_mb_str_replace')) { 30 | include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'; 31 | } 32 | $is_loaded = true; 33 | } 34 | return smarty_mb_str_replace($search, $replace, $string); 35 | } 36 | return str_replace($search, $replace, $string); 37 | } 38 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_clearconfig.php: -------------------------------------------------------------------------------- 1 | config_vars[ $name ]); 36 | } else { 37 | $data->config_vars = array(); 38 | } 39 | return $data; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 42 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_setdefaultmodifiers.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 35 | $smarty->default_modifiers = (array)$modifiers; 36 | return $obj; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /demo.php: -------------------------------------------------------------------------------- 1 | addServer($server); 13 | 14 | $topic ='order_openvip_checker'; //topic在后台注册 15 | $id = uniqid(); 16 | $data=array( 17 | 'id'=>$id, 18 | 'body'=>array( 19 | 'a'=>1, 20 | 'b'=>2, 21 | 'c'=>3, 22 | 'ext'=>str_repeat('a',64), 23 | ), 24 | //可选,设置后以这个通知时间为准,默认延时时间在注册topic的时候指定 25 | //'fix_time'=>date('Y-m-d 23:50:50'), 26 | ); 27 | 28 | $time = msectime(); 29 | 30 | //添加 31 | $boolRet = $dqClient->add($topic, $data); 32 | echo 'add耗时:'.(msectime() - $time)."ms\n"; 33 | 34 | //查询 35 | $time = msectime(); 36 | $result = $dqClient->get($topic, $id); 37 | echo 'get耗时:'.(msectime() - $time)."ms\n"; 38 | 39 | //删除 40 | $time = msectime(); 41 | $boolRet = $dqClient->del($topic,$id); 42 | echo 'del耗时:'.(msectime() - $time)."ms\n"; 43 | 44 | 45 | 46 | function msectime() { 47 | list($msec, $sec) = explode(' ', microtime()); 48 | $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); 49 | return $msectime; 50 | } 51 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/shared.literal_compiler_param.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 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_setdebugtemplate.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 | } 42 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 41 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 41 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_compile_debug.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 32 | // compile always as nocache 33 | $compiler->tag_nocache = true; 34 | // display debug template 35 | $_output = 36 | "display_debug(\$_smarty_tpl);\n"; 37 | $_output .= "unset(\$_smarty_debug);\n?>"; 38 | return $_output; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 41 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_clearassign.php: -------------------------------------------------------------------------------- 1 | tpl_vars[ $curr_var ]); 37 | } 38 | } else { 39 | unset($data->tpl_vars[ $tpl_var ]); 40 | } 41 | return $data; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /DqWeb/plugins/cacheresource.pdo_gzip.php: -------------------------------------------------------------------------------- 1 | setCachingType('pdo_gzip'); 9 | * $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip'); 10 | * $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache')); 11 | * 12 | * @require Smarty_CacheResource_Pdo class 13 | * @author Beno!t POLASZEK - 2014 14 | */ 15 | class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo 16 | { 17 | /** 18 | * Encodes the content before saving to database 19 | * 20 | * @param string $content 21 | * 22 | * @return string $content 23 | * @access protected 24 | */ 25 | protected function inputContent($content) 26 | { 27 | return gzdeflate($content); 28 | } 29 | 30 | /** 31 | * Decodes the content before saving to database 32 | * 33 | * @param string $content 34 | * 35 | * @return string $content 36 | * @access protected 37 | */ 38 | protected function outputContent($content) 39 | { 40 | return gzinflate($content); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.wordwrap.php: -------------------------------------------------------------------------------- 1 | getPlugin('mb_wordwrap', 'modifier'); 37 | } 38 | return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')'; 39 | } 40 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 48 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 42 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 43 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifiercompiler.unescape.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 39 | $smarty->registered_cache_resources[ $name ] = $resource_handler; 40 | return $obj; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 43 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 37 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 44 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_getstreamvariable.php: -------------------------------------------------------------------------------- 1 | smarty) ? $data->smarty : $data; 44 | if ($smarty->error_unassigned) { 45 | throw new SmartyException('Undefined stream variable "' . $variable . '"'); 46 | } else { 47 | return null; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_clearcache.php: -------------------------------------------------------------------------------- 1 | _clearTemplateCache(); 46 | // load cache resource and call clear 47 | $_cache_resource = Smarty_CacheResource::load($smarty, $type); 48 | return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 38 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 45 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 45 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | -------------------------------------------------------------------------------- /DqHttpServer.php: -------------------------------------------------------------------------------- 1 | ${logs} 2>&1 "; 49 | $fp = popen($cmd,'r'); 50 | pclose($fp); 51 | 52 | 53 | /** 54 | * 自身进程检测代码,如果当前进程存在则退出 55 | */ 56 | function check_self($name) { 57 | $_cmd = "ps -ef | grep '$name' | grep -v grep | awk '{print $3,$8,$2}' "; 58 | $fp = popen($_cmd, 'r'); 59 | $pid = array(); 60 | while (!feof($fp) && $fp) { 61 | $_line = trim(fgets($fp, 1024)); 62 | if(empty($_line)){ 63 | break; 64 | } 65 | $arr = explode(" ",$_line); 66 | if(trim($arr[1])==$name){ 67 | echo 'process exists,will exit'; 68 | exit(0); 69 | } 70 | } 71 | fclose($fp); 72 | return $pid; 73 | } -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_assignglobal.php: -------------------------------------------------------------------------------- 1 | _isTplObj()) { 38 | $ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ]; 39 | $ptr = $ptr->parent; 40 | } 41 | } 42 | return $data; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 44 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 47 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 44 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/shared.make_timestamp.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime() 15 | * 16 | * @return int 17 | */ 18 | function smarty_make_timestamp($string) 19 | { 20 | if (empty($string)) { 21 | // use "now": 22 | return time(); 23 | } elseif ($string instanceof DateTime 24 | || (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface) 25 | ) { 26 | return (int)$string->format('U'); // PHP 5.2 BC 27 | } elseif (strlen($string) === 14 && ctype_digit($string)) { 28 | // it is mysql timestamp format of YYYYMMDDHHMMSS? 29 | return mktime( 30 | substr($string, 8, 2), 31 | substr($string, 10, 2), 32 | substr($string, 12, 2), 33 | substr($string, 4, 2), 34 | substr($string, 6, 2), 35 | substr($string, 0, 4) 36 | ); 37 | } elseif (is_numeric($string)) { 38 | // it is a numeric string, we handle it as timestamp 39 | return (int)$string; 40 | } else { 41 | // strtotime should handle it 42 | $time = strtotime($string); 43 | if ($time === -1 || $time === false) { 44 | // strtotime() was not able to parse $string, use "now": 45 | return time(); 46 | } 47 | return $time; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /DqAlert.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * @param string $string input string 19 | * @param string|array $search regular expression(s) to search for 20 | * @param string|array $replace string(s) that should be replaced 21 | * @param int $limit the maximum number of replacements 22 | * 23 | * @return string 24 | */ 25 | function smarty_modifier_regex_replace($string, $search, $replace, $limit = -1) 26 | { 27 | if (is_array($search)) { 28 | foreach ($search as $idx => $s) { 29 | $search[ $idx ] = _smarty_regex_replace_check($s); 30 | } 31 | } else { 32 | $search = _smarty_regex_replace_check($search); 33 | } 34 | return preg_replace($search, $replace, $string, $limit); 35 | } 36 | 37 | /** 38 | * @param string $search string(s) that should be replaced 39 | * 40 | * @return string 41 | * @ignore 42 | */ 43 | function _smarty_regex_replace_check($search) 44 | { 45 | // null-byte injection detection 46 | // anything behind the first null-byte is ignored 47 | if (($pos = strpos($search, "\0")) !== false) { 48 | $search = substr($search, 0, $pos); 49 | } 50 | // remove eval-modifier from $search 51 | if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) { 52 | $search = substr($search, 0, -strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]); 53 | } 54 | return $search; 55 | } 56 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 59 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /DqLog.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 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | return $_template->mustCompile; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /DqBench.php: -------------------------------------------------------------------------------- 1 | name = $name; 12 | } 13 | static $concurrency=10; 14 | static $nums = 2; 15 | 16 | function run(){ 17 | $server=array( 18 | '10.13.131.116:6789', 19 | ); 20 | $time = self::msectime(); 21 | $dqClient = new DqClient(); 22 | $dqClient->addServer($server); 23 | 24 | $topic ='order_openvip_checker'; //topic在后台注册 25 | for($i=0;$i $id, 29 | 'body' => array( 30 | 'a' => 1, 31 | 'b' => 2, 32 | 'c' => 3, 33 | 'ext' => str_repeat('a', 128), 34 | ), 35 | //可选,设置后以这个通知时间为准,默认延时时间在注册topic的时候指定 36 | //'fix_time' => date('Y-m-d 23:50:50'), 37 | ); 38 | $boolRet = $dqClient->add($topic, $data); 39 | echo 'add耗时:'.(self::msectime() - $time)."ms\n"; 40 | } 41 | } 42 | 43 | static function msectime() { 44 | list($msec, $sec) = explode(' ', microtime()); 45 | $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); 46 | return $msectime; 47 | } 48 | } 49 | 50 | DqBench::$concurrency =$_SERVER['argv'][1]; 51 | DqBench::$nums = $_SERVER['argv'][2]; 52 | 53 | 54 | 55 | 56 | for($i=0;$istart(); 63 | } 64 | 65 | 66 | foreach($pool as $worker) { 67 | $worker->join();//等待执行完成 68 | } 69 | 70 | echo "总耗时:".(DqBench::msectime()-$start)."ms\n"; 71 | 72 | // php DqBench 100 2 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_undefined.php: -------------------------------------------------------------------------------- 1 | class = $class; 29 | } 30 | 31 | /** 32 | * Wrapper for obsolete class Smarty_Internal_Runtime_ValidateCompiled 33 | * 34 | * @param \Smarty_Internal_Template $tpl 35 | * @param array $properties special template properties 36 | * @param bool $cache flag if called from cache file 37 | * 38 | * @return bool false 39 | */ 40 | public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) 41 | { 42 | if ($cache) { 43 | $tpl->cached->valid = false; 44 | } else { 45 | $tpl->mustCompile = true; 46 | } 47 | return false; 48 | } 49 | 50 | /** 51 | * Call error handler for undefined method 52 | * 53 | * @param string $name unknown method-name 54 | * @param array $args argument array 55 | * 56 | * @return mixed 57 | * @throws SmartyException 58 | */ 59 | public function __call($name, $args) 60 | { 61 | if (isset($this->class)) { 62 | throw new SmartyException("undefined extension class '{$this->class}'"); 63 | } else { 64 | throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method"); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /test_swoole_bench.php: -------------------------------------------------------------------------------- 1 | name = $name; 13 | } 14 | static $concurrency=10; 15 | static $nums = 2; 16 | 17 | function run(){ 18 | $server=array( 19 | '127.0.0.1:9055', 20 | ); 21 | $time = self::msectime(); 22 | $dqClient = new DqSwooleClient(); 23 | $dqClient->addServer($server); 24 | 25 | $topic ='mytest'; 26 | for($i=0;$i $id, 30 | 'body' => array( 31 | 'a' => 1, 32 | 'b' => 2, 33 | 'c' => 3, 34 | 'ext' => str_repeat('a', 128), 35 | ), 36 | //可选,设置后以这个通知时间为准,默认延时时间在注册topic的时候指定 37 | //'fix_time' => date('Y-m-d 23:50:50'), 38 | ); 39 | $boolRet = $dqClient->add($topic, $data); 40 | echo 'add耗时:'.(self::msectime() - $time)."ms\n"; 41 | } 42 | } 43 | 44 | static function msectime() { 45 | list($msec, $sec) = explode(' ', microtime()); 46 | $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); 47 | return $msectime; 48 | } 49 | } 50 | 51 | DqBench::$concurrency =$_SERVER['argv'][1]; 52 | DqBench::$nums = $_SERVER['argv'][2]; 53 | 54 | 55 | 56 | 57 | for($i=0;$istart(); 64 | } 65 | 66 | 67 | foreach($pool as $worker) { 68 | $worker->join();//等待执行完成 69 | } 70 | 71 | echo "总耗时:".(DqBench::msectime()-$start)."ms\n"; 72 | 73 | // php DqBench 100 2 74 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_appendbyref.php: -------------------------------------------------------------------------------- 1 | tpl_vars[ $tpl_var ])) { 31 | $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(); 32 | } 33 | if (!is_array($data->tpl_vars[ $tpl_var ]->value)) { 34 | settype($data->tpl_vars[ $tpl_var ]->value, 'array'); 35 | } 36 | if ($merge && is_array($value)) { 37 | foreach ($value as $_key => $_val) { 38 | $data->tpl_vars[ $tpl_var ]->value[ $_key ] = &$value[ $_key ]; 39 | } 40 | } else { 41 | $data->tpl_vars[ $tpl_var ]->value[] = &$value; 42 | } 43 | if ($data->_isTplObj() && $data->scope) { 44 | $data->ext->_updateScope->_updateScope($data, $tpl_var); 45 | } 46 | } 47 | return $data; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /DqWeb/libs/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( 41 | array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'), 42 | array($initChildSequence), 43 | 'inheritanceInit', 44 | $initChildSequence 45 | ); 46 | $compiler->_cache[ 'inheritanceInit' ] = true; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 91 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_registerresource.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 42 | $smarty->registered_resources[ $name ] = 43 | $resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false); 44 | return $obj; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_parsetree_tag.php: -------------------------------------------------------------------------------- 1 | data = $data; 37 | $this->saved_block_nesting = $parser->block_nesting_level; 38 | } 39 | 40 | /** 41 | * Return buffer content 42 | * 43 | * @param \Smarty_Internal_Templateparser $parser 44 | * 45 | * @return string content 46 | */ 47 | public function to_smarty_php(Smarty_Internal_Templateparser $parser) 48 | { 49 | return $this->data; 50 | } 51 | 52 | /** 53 | * Return complied code that loads the evaluated output of buffer content into a temporary variable 54 | * 55 | * @param \Smarty_Internal_Templateparser $parser 56 | * 57 | * @return string template code 58 | */ 59 | public function assign_to_var(Smarty_Internal_Templateparser $parser) 60 | { 61 | $var = $parser->compiler->getNewPrefixVariable(); 62 | $tmp = $parser->compiler->appendCode('', $this->data); 63 | $tmp = $parser->compiler->appendCode($tmp, ""); 64 | $parser->compiler->prefix_code[] = sprintf('%s', $tmp); 65 | return $var; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/function.counter.php: -------------------------------------------------------------------------------- 1 | 15 | * @link http://www.smarty.net/manual/en/language.function.counter.php {counter} 16 | * (Smarty online manual) 17 | * 18 | * @param array $params parameters 19 | * @param Smarty_Internal_Template $template template object 20 | * 21 | * @return string|null 22 | */ 23 | function smarty_function_counter($params, $template) 24 | { 25 | static $counters = array(); 26 | $name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default'; 27 | if (!isset($counters[ $name ])) { 28 | $counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1); 29 | } 30 | $counter =& $counters[ $name ]; 31 | if (isset($params[ 'start' ])) { 32 | $counter[ 'start' ] = $counter[ 'count' ] = (int)$params[ 'start' ]; 33 | } 34 | if (!empty($params[ 'assign' ])) { 35 | $counter[ 'assign' ] = $params[ 'assign' ]; 36 | } 37 | if (isset($counter[ 'assign' ])) { 38 | $template->assign($counter[ 'assign' ], $counter[ 'count' ]); 39 | } 40 | if (isset($params[ 'print' ])) { 41 | $print = (bool)$params[ 'print' ]; 42 | } else { 43 | $print = empty($counter[ 'assign' ]); 44 | } 45 | if ($print) { 46 | $retval = $counter[ 'count' ]; 47 | } else { 48 | $retval = null; 49 | } 50 | if (isset($params[ 'skip' ])) { 51 | $counter[ 'skip' ] = $params[ 'skip' ]; 52 | } 53 | if (isset($params[ 'direction' ])) { 54 | $counter[ 'direction' ] = $params[ 'direction' ]; 55 | } 56 | if ($counter[ 'direction' ] === 'down') { 57 | $counter[ 'count' ] -= $counter[ 'skip' ]; 58 | } else { 59 | $counter[ 'count' ] += $counter[ 'skip' ]; 60 | } 61 | return $retval; 62 | } 63 | -------------------------------------------------------------------------------- /DqWeb/plugins/resource.extendsall.php: -------------------------------------------------------------------------------- 1 | smarty->getTemplateDir() as $key => $directory) { 27 | try { 28 | $s = Smarty_Resource::source(null, $source->smarty, 'file:' . '[' . $key . ']' . $source->name); 29 | if (!$s->exists) { 30 | continue; 31 | } 32 | $sources[ $s->uid ] = $s; 33 | $uid .= $s->filepath; 34 | $timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp; 35 | } catch (SmartyException $e) { 36 | } 37 | } 38 | if (!$sources) { 39 | $source->exists = false; 40 | return; 41 | } 42 | $sources = array_reverse($sources, true); 43 | reset($sources); 44 | $s = current($sources); 45 | $source->components = $sources; 46 | $source->filepath = $s->filepath; 47 | $source->uid = sha1($uid . $source->smarty->_joined_template_dir); 48 | $source->exists = true; 49 | $source->timestamp = $timestamp; 50 | } 51 | 52 | /** 53 | * Disable timestamp checks for extendsall resource. 54 | * The individual source components will be checked. 55 | * 56 | * @return bool false 57 | */ 58 | public function checkTimestamps() 59 | { 60 | return false; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | // create template object 60 | $_output = 61 | "\$_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 | return ""; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_registerplugin.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 47 | if (isset($smarty->registered_plugins[ $type ][ $name ])) { 48 | throw new SmartyException("Plugin tag '{$name}' already registered"); 49 | } elseif (!is_callable($callback)) { 50 | throw new SmartyException("Plugin '{$name}' not callable"); 51 | } else { 52 | $smarty->registered_plugins[ $type ][ $name ] = array($callback, (bool)$cacheable, (array)$cache_attr); 53 | } 54 | return $obj; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_runtime_make_nocache.php: -------------------------------------------------------------------------------- 1 | tpl_vars[ $var ])) { 24 | $export = 25 | preg_replace('/^Smarty_Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true)); 26 | if (preg_match('/(\w+)::__set_state/', $export, $match)) { 27 | throw new SmartyException("{make_nocache \${$var}} in template '{$tpl->source->name}': variable does contain object '{$match[1]}' not implementing method '__set_state'"); 28 | } 29 | echo "/*%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/smarty->ext->_make_nocache->store(\$_smarty_tpl, '{$var}', ", '\\') . 31 | $export . ");?>\n/*/%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/"; 32 | } 33 | } 34 | 35 | /** 36 | * Store variable value saved while rendering compiled template in cached template context 37 | * 38 | * @param \Smarty_Internal_Template $tpl 39 | * @param string $var variable name 40 | * @param array $properties 41 | */ 42 | public function store(Smarty_Internal_Template $tpl, $var, $properties) 43 | { 44 | // do not overwrite existing nocache variables 45 | if (!isset($tpl->tpl_vars[ $var ]) || !$tpl->tpl_vars[ $var ]->nocache) { 46 | $newVar = new Smarty_Variable(); 47 | unset($properties[ 'nocache' ]); 48 | foreach ($properties as $k => $v) { 49 | $newVar->$k = $v; 50 | } 51 | $tpl->tpl_vars[ $var ] = $newVar; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test_swoole_server.php: -------------------------------------------------------------------------------- 1 | set(array( 11 | 'open_length_check' => true, 12 | 'package_max_length' => 4096, 13 | 'package_length_type' => 'N', //see php pack() 14 | 'package_length_offset' => 0, 15 | 'package_body_offset' => 4, 16 | )); 17 | 18 | 19 | $serv->on('connect', function ($serv, $fd) { 20 | $clientInfo = $serv->getClientInfo($fd); 21 | DqLog::writeLog('new client connet,info='.json_encode($clientInfo)); 22 | }); 23 | 24 | 25 | $serv->on('receive', function ($serv, $fd, $from_id, $data) { 26 | $length = unpack("N" , $data)[1]; 27 | $data = substr($data,-$length); 28 | //$reply = "Get Message From Client {$fd}:{$length}:{$data}"; 29 | //DqLog::writeLog($reply); 30 | //echo $reply."\n"; 31 | $arrData=json_decode($data,true); 32 | switch ($arrData['cmd']) { 33 | case 'add': 34 | add($arrData,$serv,$fd); 35 | } 36 | 37 | }); 38 | $serv->on('close', function ($serv, $fd) { 39 | 40 | }); 41 | 42 | }catch (Exception $e){ 43 | echo $e->getMessage(); 44 | } 45 | 46 | 47 | function add($arrData,$serv,$fd){ 48 | $client = new Swoole_Redis(); 49 | $client->connect('127.0.0.1', 6666, function (swoole_redis $client, $result)use($arrData,$serv,$fd){ 50 | $body=json_encode($arrData['body']); 51 | $id = 135; 52 | $topic = $arrData['topic']; 53 | $tid = DqRedis::create_tid($topic,$id); 54 | $hkey='hkeytest'; 55 | $score=time()+rand(1,5); 56 | $serv->send($fd, 'this is a test'); 57 | $client->hset($hkey, $tid, $body, function (swoole_redis $client, $result) use($serv,$fd,$tid,$score) { 58 | if($result) { 59 | $zkey= 33333; 60 | $client->zadd($zkey, $score, $tid, function (swoole_redis $client, $result) use ($serv, $fd) { 61 | DqRedis::incr_nums(1,2); 62 | $serv->send($fd, 'this is a test'); 63 | }); 64 | }else{ 65 | $serv->send($fd, 'this is a test'); 66 | } 67 | }); 68 | }); 69 | 70 | } 71 | 72 | $serv->start(); -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 64 | -------------------------------------------------------------------------------- /DqInit.php: -------------------------------------------------------------------------------- 1 | $v) { 40 | $_res[ $k ] = $v; 41 | } 42 | return $_res; 43 | } 44 | 45 | /** 46 | * Save values for a set of keys to cache 47 | * 48 | * @param array $keys list of values to save 49 | * @param int $expire expiration time 50 | * 51 | * @return boolean true on success, false on failure 52 | */ 53 | protected function write(array $keys, $expire = null) 54 | { 55 | foreach ($keys as $k => $v) { 56 | apc_store($k, $v, $expire); 57 | } 58 | return true; 59 | } 60 | 61 | /** 62 | * Remove values from cache 63 | * 64 | * @param array $keys list of keys to delete 65 | * 66 | * @return boolean true on success, false on failure 67 | */ 68 | protected function delete(array $keys) 69 | { 70 | foreach ($keys as $k) { 71 | apc_delete($k); 72 | } 73 | return true; 74 | } 75 | 76 | /** 77 | * Remove *all* values from cache 78 | * 79 | * @return boolean true on success, false on failure 80 | */ 81 | protected function purge() 82 | { 83 | return apc_clear_cache('user'); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /DqWeb/templates/index.tpl: -------------------------------------------------------------------------------- 1 | {config_load file="test.conf" section="setup"} 2 | {include file="header.tpl" title=foo} 3 | 4 |
 5 | 
 6 | {* bold and title are read from the config file *}
 7 |     {if #bold#}{/if}
 8 |         {* capitalize the first letters of each word of the title *}
 9 |         Title: {#title#|capitalize}
10 |         {if #bold#}{/if}
11 | 
12 |     The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
13 | 
14 |     The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
15 | 
16 |     Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
17 | 
18 |     The value of {ldelim}$Name{rdelim} is {$Name}
19 | 
20 | variable modifier example of {ldelim}$Name|upper{rdelim}
21 | 
22 | {$Name|upper}
23 | 
24 | 
25 | An example of a section loop:
26 | 
27 |     {section name=outer
28 |     loop=$FirstName}
29 |         {if $smarty.section.outer.index is odd by 2}
30 |             {$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
31 |         {else}
32 |             {$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
33 |         {/if}
34 |         {sectionelse}
35 |         none
36 |     {/section}
37 | 
38 |     An example of section looped key values:
39 | 
40 |     {section name=sec1 loop=$contacts}
41 |         phone: {$contacts[sec1].phone}
42 |         
43 | 44 | fax: {$contacts[sec1].fax} 45 |
46 | 47 | cell: {$contacts[sec1].cell} 48 |
49 | {/section} 50 |

51 | 52 | testing strip tags 53 | {strip} 54 | 55 | 56 | 61 | 62 |
57 | 58 | This is a test 59 | 60 |
63 | {/strip} 64 | 65 |

66 | 67 | This is an example of the html_select_date function: 68 | 69 |
70 | {html_select_date start_year=1998 end_year=2010} 71 |
72 | 73 | This is an example of the html_select_time function: 74 | 75 |
76 | {html_select_time use_24_hours=false} 77 |
78 | 79 | This is an example of the html_options function: 80 | 81 |
82 | 85 |
86 | 87 | {include file="footer.tpl"} 88 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_method_addautoloadfilters.php: -------------------------------------------------------------------------------- 1 | _getSmartyObj(); 33 | if ($type !== null) { 34 | $this->_checkFilterType($type); 35 | if (!empty($smarty->autoload_filters[ $type ])) { 36 | $smarty->autoload_filters[ $type ] = array_merge($smarty->autoload_filters[ $type ], (array)$filters); 37 | } else { 38 | $smarty->autoload_filters[ $type ] = (array)$filters; 39 | } 40 | } else { 41 | foreach ((array)$filters as $type => $value) { 42 | $this->_checkFilterType($type); 43 | if (!empty($smarty->autoload_filters[ $type ])) { 44 | $smarty->autoload_filters[ $type ] = 45 | array_merge($smarty->autoload_filters[ $type ], (array)$value); 46 | } else { 47 | $smarty->autoload_filters[ $type ] = (array)$value; 48 | } 49 | } 50 | } 51 | return $obj; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | return true; 44 | } 45 | } 46 | 47 | /** 48 | * Smarty Internal Plugin Compile Nocacheclose Class 49 | * 50 | * @package Smarty 51 | * @subpackage Compiler 52 | */ 53 | class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase 54 | { 55 | /** 56 | * Compiles code for the {/nocache} tag 57 | * This tag does not generate compiled output. It only sets a compiler flag. 58 | * 59 | * @param array $args array with attributes from parser 60 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object 61 | * 62 | * @return bool 63 | */ 64 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) 65 | { 66 | $_attr = $this->getAttributes($compiler, $args); 67 | // leave nocache mode 68 | list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); 69 | // this tag does not return compiled code 70 | $compiler->has_code = false; 71 | return true; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifier.truncate.php: -------------------------------------------------------------------------------- 1 | 18 | * 19 | * @param string $string input string 20 | * @param integer $length length of truncated text 21 | * @param string $etc end string 22 | * @param boolean $break_words truncate at word boundary 23 | * @param boolean $middle truncate in the middle of text 24 | * 25 | * @return string truncated string 26 | */ 27 | function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) 28 | { 29 | if ($length === 0) { 30 | return ''; 31 | } 32 | if (Smarty::$_MBSTRING) { 33 | if (mb_strlen($string, Smarty::$_CHARSET) > $length) { 34 | $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); 35 | if (!$break_words && !$middle) { 36 | $string = preg_replace( 37 | '/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, 38 | '', 39 | mb_substr($string, 0, $length + 1, Smarty::$_CHARSET) 40 | ); 41 | } 42 | if (!$middle) { 43 | return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; 44 | } 45 | return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . 46 | mb_substr($string, -$length / 2, $length, Smarty::$_CHARSET); 47 | } 48 | return $string; 49 | } 50 | // no MBString fallback 51 | if (isset($string[ $length ])) { 52 | $length -= min($length, strlen($etc)); 53 | if (!$break_words && !$middle) { 54 | $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); 55 | } 56 | if (!$middle) { 57 | return substr($string, 0, $length) . $etc; 58 | } 59 | return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2); 60 | } 61 | return $string; 62 | } 63 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | return true; 35 | } 36 | } 37 | 38 | /** 39 | * Smarty Internal Plugin Compile Setfilterclose Class 40 | * 41 | * @package Smarty 42 | * @subpackage Compiler 43 | */ 44 | class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase 45 | { 46 | /** 47 | * Compiles code for the {/setfilter} tag 48 | * This tag does not generate compiled output. It resets variable filter. 49 | * 50 | * @param array $args array with attributes from parser 51 | * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object 52 | * 53 | * @return string compiled code 54 | */ 55 | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) 56 | { 57 | $_attr = $this->getAttributes($compiler, $args); 58 | // reset variable filter to previous state 59 | if (count($compiler->variable_filter_stack)) { 60 | $compiler->variable_filters = array_pop($compiler->variable_filter_stack); 61 | } else { 62 | $compiler->variable_filters = array(); 63 | } 64 | // this tag does not return compiled code 65 | $compiler->has_code = false; 66 | return true; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } 78 | -------------------------------------------------------------------------------- /DqWeb/plugins/resource.mysqls.php: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS `templates` ( 11 | * `name` varchar(100) NOT NULL, 12 | * `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 13 | * `source` text, 14 | * PRIMARY KEY (`name`) 15 | * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 16 | * Demo data: 17 | *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello
18 |  * world"}{$x}');
19 | * 20 | * 21 | * @package Resource-examples 22 | * @author Rodney Rehm 23 | */ 24 | class Smarty_Resource_Mysqls extends Smarty_Resource_Custom 25 | { 26 | /** 27 | * PDO instance 28 | * 29 | * @var \PDO 30 | */ 31 | protected $db; 32 | 33 | /** 34 | * prepared fetch() statement 35 | * 36 | * @var \PDOStatement 37 | */ 38 | protected $fetch; 39 | 40 | /** 41 | * Smarty_Resource_Mysqls constructor. 42 | * 43 | * @throws \SmartyException 44 | */ 45 | public function __construct() 46 | { 47 | try { 48 | $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); 49 | } catch (PDOException $e) { 50 | throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); 51 | } 52 | $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); 53 | } 54 | 55 | /** 56 | * Fetch a template and its modification time from database 57 | * 58 | * @param string $name template name 59 | * @param string $source template source 60 | * @param integer $mtime template modification timestamp (epoch) 61 | * 62 | * @return void 63 | */ 64 | protected function fetch($name, &$source, &$mtime) 65 | { 66 | $this->fetch->execute(array('name' => $name)); 67 | $row = $this->fetch->fetch(); 68 | $this->fetch->closeCursor(); 69 | if ($row) { 70 | $source = $row[ 'source' ]; 71 | $mtime = strtotime($row[ 'modified' ]); 72 | } else { 73 | $source = null; 74 | $mtime = null; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /DqWeb/libs/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 36 | * the filter type to set. 37 | * Defaults to none treating 38 | * $filters' keys as the 39 | * appropriate types 40 | * 41 | * @return \Smarty|\Smarty_Internal_Template 42 | * @throws \SmartyException 43 | */ 44 | public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null) 45 | { 46 | $smarty = $obj->_getSmartyObj(); 47 | if ($type !== null) { 48 | $this->_checkFilterType($type); 49 | $smarty->autoload_filters[ $type ] = (array)$filters; 50 | } else { 51 | foreach ((array)$filters as $type => $value) { 52 | $this->_checkFilterType($type); 53 | } 54 | $smarty->autoload_filters = (array)$filters; 55 | } 56 | return $obj; 57 | } 58 | 59 | /** 60 | * Check if filter type is valid 61 | * 62 | * @param string $type 63 | * 64 | * @throws \SmartyException 65 | */ 66 | public function _checkFilterType($type) 67 | { 68 | if (!isset($this->filterTypes[ $type ])) { 69 | throw new SmartyException("Illegal filter type '{$type}'"); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifier.mb_wordwrap.php: -------------------------------------------------------------------------------- 1 | $width) { 36 | if ($cut) { 37 | $_tokens = preg_split( 38 | '!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, 39 | $_token, 40 | -1, 41 | PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE 42 | ); 43 | } 44 | } 45 | foreach ($_tokens as $token) { 46 | $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); 47 | $token_length = mb_strlen($token, Smarty::$_CHARSET); 48 | $length += $token_length; 49 | if ($length > $width) { 50 | // remove space before inserted break 51 | if ($_previous) { 52 | $t = mb_substr($t, 0, -1, Smarty::$_CHARSET); 53 | } 54 | if (!$_space) { 55 | // add the break before the token 56 | if (!empty($t)) { 57 | $t .= $break; 58 | } 59 | $length = $token_length; 60 | } 61 | } elseif ($token === "\n") { 62 | // hard break must reset counters 63 | $length = 0; 64 | } 65 | $_previous = $_space; 66 | // add the token 67 | $t .= $token; 68 | } 69 | } 70 | return $t; 71 | } 72 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_resource_stream.php: -------------------------------------------------------------------------------- 1 | resource, '://') !== false) { 33 | $source->filepath = $source->resource; 34 | } else { 35 | $source->filepath = str_replace(':', '://', $source->resource); 36 | } 37 | $source->uid = false; 38 | $source->content = $this->getContent($source); 39 | $source->timestamp = $source->exists = !!$source->content; 40 | } 41 | 42 | /** 43 | * Load template's source from stream into current template object 44 | * 45 | * @param Smarty_Template_Source $source source object 46 | * 47 | * @return string template source 48 | */ 49 | public function getContent(Smarty_Template_Source $source) 50 | { 51 | $t = ''; 52 | // the availability of the stream has already been checked in Smarty_Resource::fetch() 53 | $fp = fopen($source->filepath, 'r+'); 54 | if ($fp) { 55 | while (!feof($fp) && ($current_line = fgets($fp)) !== false) { 56 | $t .= $current_line; 57 | } 58 | fclose($fp); 59 | return $t; 60 | } else { 61 | return false; 62 | } 63 | } 64 | 65 | /** 66 | * modify resource_name according to resource handlers specifications 67 | * 68 | * @param Smarty $smarty Smarty instance 69 | * @param string $resource_name resource_name to make unique 70 | * @param boolean $isConfig flag for config resource 71 | * 72 | * @return string unique resource name 73 | */ 74 | public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) 75 | { 76 | return get_class($this) . '#' . $resource_name; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /java/src/main/java/com/phpdelayqueue/SocketUtil.java: -------------------------------------------------------------------------------- 1 | package com.phpdelayqueue; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.DataInputStream; 7 | import java.io.DataOutputStream; 8 | import java.io.IOException; 9 | import java.net.Socket; 10 | import java.nio.ByteBuffer; 11 | import java.nio.ByteOrder; 12 | import java.nio.charset.Charset; 13 | 14 | class SocketUtil { 15 | private static Logger logger = LoggerFactory.getLogger(SocketUtil.class); 16 | 17 | private static int CHUNK_SIZE = 4096; 18 | 19 | static String send(String host, Integer port, byte[] content) { 20 | DataOutputStream out = null; 21 | try { 22 | Socket socket = new Socket(host, port); 23 | 24 | out = new DataOutputStream(socket.getOutputStream()); 25 | 26 | String headStr = String.format("%04d", content.length); 27 | byte[] head = headStr.getBytes(Charset.forName("UTF-8")); 28 | 29 | 30 | head = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).put(head).array(); 31 | content = ByteBuffer.allocate(content.length).order(ByteOrder.BIG_ENDIAN).put(content).array(); 32 | 33 | logger.info("head bytes : {}", head); 34 | logger.info("content bytes : {}", content); 35 | 36 | out.write(head, 0, 4); 37 | out.write(content); 38 | out.flush(); 39 | 40 | logger.info("content : {}{}", headStr, new String(content)); 41 | 42 | DataInputStream in = new DataInputStream(socket.getInputStream()); 43 | 44 | 45 | if (in.read(head, 0, 4) != 4) { 46 | logger.error("read response header failed, length not 4"); 47 | return ""; 48 | } 49 | int responseLen = Integer.parseInt(new String(head, 0, 4)); 50 | logger.info("response header length : {}", responseLen); 51 | 52 | byte[] chunk = new byte[CHUNK_SIZE]; 53 | int total = 0; 54 | int readlen; 55 | StringBuilder sb = new StringBuilder(); 56 | while ((readlen = in.read(chunk, 0, CHUNK_SIZE)) > 0) { 57 | sb.append(new String(chunk, 0, readlen)); 58 | total += readlen; 59 | if (total >= responseLen) { 60 | break; 61 | } 62 | } 63 | 64 | return sb.toString(); 65 | 66 | } catch (IOException e) { 67 | logger.error("send content failed", e); 68 | } finally { 69 | if (out != null) { 70 | try { 71 | out.close(); 72 | } catch (IOException e) { 73 | // do nothing 74 | } 75 | } 76 | } 77 | return ""; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | } catch (Exception $e) { 54 | unset($_smarty_tpl->compiler); 55 | while (ob_get_level() > $level) { 56 | ob_end_clean(); 57 | } 58 | throw $e; 59 | } 60 | // release compiler object to free memory 61 | unset($_smarty_tpl->compiler); 62 | ob_get_clean(); 63 | $compiled->timestamp = time(); 64 | $compiled->exists = true; 65 | } 66 | 67 | /** 68 | * populate Compiled Object with compiled filepath 69 | * 70 | * @param Smarty_Template_Compiled $compiled compiled object 71 | * @param Smarty_Internal_Template $_template template object 72 | * 73 | * @return void 74 | */ 75 | public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template) 76 | { 77 | $compiled->filepath = false; 78 | $compiled->timestamp = false; 79 | $compiled->exists = false; 80 | } 81 | 82 | /* 83 | * Disable timestamp checks for recompiled resource. 84 | * 85 | * @return bool 86 | */ 87 | /** 88 | * @return bool 89 | */ 90 | public function checkTimestamps() 91 | { 92 | return false; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /DqWeb/libs/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( 57 | "{$tag} used outside {block} tags ", 58 | $compiler->parser->lex->taglineno 59 | ); 60 | } 61 | $compiler->has_code = true; 62 | $compiler->suppressNocacheProcessing = true; 63 | if ($this->blockType === 'Child') { 64 | $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true'; 65 | } 66 | $_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null; 67 | $output = "inheritance->call' . $this->blockType . '($_smarty_tpl, $this' . 72 | ($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n"; 73 | if (isset($_assign)) { 74 | $output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n"; 75 | } 76 | $output .= "?>\n"; 77 | return $output; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /java/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.phpdelayqueue 8 | dqclient 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | org.apache.maven.plugins 14 | maven-compiler-plugin 15 | 16 | 7 17 | 7 18 | 19 | 20 | 21 | 22 | jar 23 | 24 | 25 | 26 | 27 | 28 | org.apache.commons 29 | commons-lang3 30 | 3.7 31 | 32 | 33 | 34 | com.google.guava 35 | guava 36 | 19 37 | 38 | 39 | 40 | com.google.code.gson 41 | gson 42 | 2.2.4 43 | 44 | 45 | 46 | 47 | org.slf4j 48 | slf4j-api 49 | 1.7.25 50 | 51 | 52 | ch.qos.logback 53 | logback-classic 54 | 1.2.3 55 | 56 | 57 | org.slf4j 58 | slf4j-simple 59 | 1.7.25 60 | 61 | 62 | log4j 63 | log4j 64 | 1.2.17 65 | 66 | 67 | org.slf4j 68 | slf4j-log4j12 69 | 1.7.12 70 | 71 | 72 | 73 | 74 | junit 75 | junit 76 | 4.12 77 | test 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### macOS template 3 | *.DS_Store 4 | .AppleDouble 5 | .LSOverride 6 | 7 | # Icon must end with two \r 8 | Icon 9 | 10 | 11 | # Thumbnails 12 | ._* 13 | 14 | # Files that might appear in the root of a volume 15 | .DocumentRevisions-V100 16 | .fseventsd 17 | .Spotlight-V100 18 | .TemporaryItems 19 | .Trashes 20 | .VolumeIcon.icns 21 | .com.apple.timemachine.donotpresent 22 | 23 | # Directories potentially created on remote AFP share 24 | .AppleDB 25 | .AppleDesktop 26 | Network Trash Folder 27 | Temporary Items 28 | .apdisk 29 | ### C template 30 | # Prerequisites 31 | *.d 32 | 33 | # Object files 34 | *.o 35 | *.ko 36 | *.obj 37 | *.elf 38 | 39 | # Linker output 40 | *.ilk 41 | *.map 42 | *.exp 43 | 44 | # Precompiled Headers 45 | *.gch 46 | *.pch 47 | 48 | # Libraries 49 | *.lib 50 | *.a 51 | *.la 52 | *.lo 53 | 54 | # Shared objects (inc. Windows DLLs) 55 | *.dll 56 | *.so 57 | *.so.* 58 | *.dylib 59 | 60 | # Executables 61 | *.exe 62 | *.out 63 | *.app 64 | *.i*86 65 | *.x86_64 66 | *.hex 67 | 68 | # Debug files 69 | *.dSYM/ 70 | *.su 71 | *.idb 72 | *.pdb 73 | 74 | # Kernel Module Compile Results 75 | *.mod* 76 | *.cmd 77 | modules.order 78 | Module.symvers 79 | Mkfile.old 80 | dkms.conf 81 | ### C++ template 82 | # Prerequisites 83 | 84 | # Compiled Object files 85 | *.slo 86 | 87 | # Precompiled Headers 88 | 89 | # Compiled Dynamic libraries 90 | 91 | # Fortran module files 92 | *.mod 93 | *.smod 94 | 95 | # Compiled Static libraries 96 | *.lai 97 | 98 | # Executables 99 | ### SVN template 100 | .svn/ 101 | ### CMake template 102 | CMakeCache.txt 103 | CMakeLists.txt 104 | CMakeFiles 105 | CMakeScripts 106 | Makefile 107 | makefile 108 | cmake_install.cmake 109 | install_manifest.txt 110 | CTestTestfile.cmake 111 | ### Example user template template 112 | ### Example user template 113 | 114 | # IntelliJ project files 115 | .idea 116 | *.iml 117 | out 118 | gen### Python template 119 | # Byte-compiled / optimized / DLL files 120 | __pycache__/ 121 | *.py[cod] 122 | *$py.class 123 | 124 | # C extensions 125 | 126 | # Distribution / packaging 127 | .Python 128 | develop-eggs/ 129 | dist/ 130 | downloads/ 131 | eggs/ 132 | .eggs/ 133 | lib/ 134 | lib64/ 135 | parts/ 136 | sdist/ 137 | var/ 138 | 139 | # Sphinx documentation 140 | docs/_build/ 141 | 142 | # PyBuilder 143 | target/ 144 | 145 | # Jupyter Notebook 146 | .ipynb_checkpoints 147 | 148 | # pyenv 149 | .python-version 150 | 151 | # celery beat schedule file 152 | celerybeat-schedule 153 | 154 | # dotenv 155 | .env 156 | 157 | # virtualenv 158 | .venv/ 159 | venv/ 160 | ENV/ 161 | 162 | # Spyder project settings 163 | .spyderproject 164 | 165 | # Rope project settings 166 | .ropeproject 167 | 168 | .gitattributes 169 | *.pb.cc 170 | *.pb.h 171 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_compile_private_function_plugin.php: -------------------------------------------------------------------------------- 1 | getAttributes($compiler, $args); 52 | unset($_attr[ 'nocache' ]); 53 | // convert attributes into parameter array string 54 | $_paramsArray = array(); 55 | foreach ($_attr as $_key => $_value) { 56 | if (is_int($_key)) { 57 | $_paramsArray[] = "$_key=>$_value"; 58 | } else { 59 | $_paramsArray[] = "'$_key'=>$_value"; 60 | } 61 | } 62 | $_params = 'array(' . implode(',', $_paramsArray) . ')'; 63 | // compile code 64 | $output = "{$function}({$_params},\$_smarty_tpl)"; 65 | if (!empty($parameter[ 'modifierlist' ])) { 66 | $output = $compiler->compileTag( 67 | 'private_modifier', 68 | array(), 69 | array( 70 | 'modifierlist' => $parameter[ 'modifierlist' ], 71 | 'value' => $output 72 | ) 73 | ); 74 | } 75 | $output = "\n"; 76 | return $output; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /DqWeb/libs/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 | return $_class_name . '_' . $function_name[ 1 ]; 67 | } elseif (is_string($function_name)) { 68 | return $function_name; 69 | } else { 70 | return 'closure'; 71 | } 72 | } 73 | 74 | /** 75 | * Check if filter type is valid 76 | * 77 | * @param string $type 78 | * 79 | * @throws \SmartyException 80 | */ 81 | public function _checkFilterType($type) 82 | { 83 | if (!isset($this->filterTypes[ $type ])) { 84 | throw new SmartyException("Illegal filter type '{$type}'"); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /DqWeb/libs/sysplugins/smarty_internal_runtime_cachemodify.php: -------------------------------------------------------------------------------- 1 | isCached() && !$_template->compiled->has_nocache_code; 25 | $_last_modified_date = 26 | @substr($_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ], 0, strpos($_SERVER[ 'HTTP_IF_MODIFIED_SINCE' ], 'GMT') + 3); 27 | if ($_isCached && $cached->timestamp <= strtotime($_last_modified_date)) { 28 | switch (PHP_SAPI) { 29 | case 'cgi': // php-cgi < 5.3 30 | case 'cgi-fcgi': // php-cgi >= 5.3 31 | case 'fpm-fcgi': // php-fpm >= 5.3.3 32 | header('Status: 304 Not Modified'); 33 | break; 34 | case 'cli': 35 | if (/* ^phpunit */ 36 | !empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */ 37 | ) { 38 | $_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = '304 Not Modified'; 39 | } 40 | break; 41 | default: 42 | if (/* ^phpunit */ 43 | !empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */ 44 | ) { 45 | $_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = '304 Not Modified'; 46 | } else { 47 | header($_SERVER[ 'SERVER_PROTOCOL' ] . ' 304 Not Modified'); 48 | } 49 | break; 50 | } 51 | } else { 52 | switch (PHP_SAPI) { 53 | case 'cli': 54 | if (/* ^phpunit */ 55 | !empty($_SERVER[ 'SMARTY_PHPUNIT_DISABLE_HEADERS' ]) /* phpunit$ */ 56 | ) { 57 | $_SERVER[ 'SMARTY_PHPUNIT_HEADERS' ][] = 58 | 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT'; 59 | } 60 | break; 61 | default: 62 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $cached->timestamp) . ' GMT'); 63 | break; 64 | } 65 | echo $content; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /DqComm.php: -------------------------------------------------------------------------------- 1 | getDqMessage(),DqLog::LOG_TYPE_EXCEPTION); 35 | return false; 36 | } 37 | } 38 | 39 | public static function format_data($params){ 40 | $str = json_encode($params); 41 | $len = strlen($str); 42 | $packageData=sprintf('%04d%s',$len,$str); 43 | return array($len+4,$packageData); 44 | } 45 | 46 | public static function socket_wirte($fd,$data){ 47 | if(is_resource($fd)) { 48 | list($len, $data) = self::format_data($data); 49 | if ($len >= self::$max_package_size) { 50 | DqLog::writeLog('data too long,str=' . $data . ' max_package_size=' . self::$max_package_size,DqLog::LOG_TYPE_EXCEPTION); 51 | } 52 | while ($len) { 53 | $nwrite = @socket_write($fd, $data, $len); //可能一次性写不完,需要多次写入 54 | if ($nwrite === false) { /*数据写入失败*/ 55 | DqLog::writeLog('socker error: data=' . $data . ',fd=' . $fd . ',error=' . json_encode(error_get_last()),DqLog::LOG_TYPE_EXCEPTION); 56 | return false; 57 | } else if ($nwrite > 0) { 58 | $len -= $nwrite; 59 | $data = substr($data, $nwrite); 60 | } 61 | } 62 | return true; 63 | } 64 | return false; 65 | } 66 | 67 | public static function msectime() { 68 | list($msec, $sec) = explode(' ', microtime()); 69 | $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); 70 | return $msectime; 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /DqSwooleClient.php: -------------------------------------------------------------------------------- 1 | serverList[] = $server; 13 | } 14 | if (is_array($server) && !empty($server)) { 15 | $this->serverList = array_merge($this->serverList, $server); 16 | } 17 | $this->serverList = array_unique($this->serverList); 18 | } 19 | 20 | 21 | public function connect() 22 | { 23 | if (!empty($this->fd)) { 24 | return $this->fd; 25 | } 26 | if (empty($this->serverList)) { 27 | DqLog::writeLog('empty server list'); 28 | return false; 29 | } 30 | $serverList = $this->serverList; 31 | 32 | while (count($serverList)) { 33 | try { 34 | $idx = rand(0, count($serverList) - 1); 35 | $server = $serverList[$idx]; 36 | list($host, $port) = explode(':', $server); 37 | 38 | $fd = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 39 | //1s内没处理完直接返回 40 | socket_set_option($fd, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 5, "usec" => 0)); 41 | if (!is_resource($fd)) { 42 | $strMsg = 'socket_create error:' . socket_strerror(socket_last_error()); 43 | throw new DqException($strMsg); 44 | } 45 | if (!socket_connect($fd, $host, $port)) { 46 | $strMsg = 'socket_create error:' . socket_strerror(socket_last_error() . ' ip=' . $host . ' port=' . $port); 47 | throw new DqException($strMsg); 48 | } 49 | $this->fd = $fd; 50 | return $fd; 51 | } catch (DqException $e) { 52 | unset($this->serverList[$idx]); //删除无用的配置 53 | 54 | unset($serverList[$idx]); 55 | $serverList = array_values($serverList); 56 | 57 | DqLog::writeLog($e->getDqMessage(), DqLog::LOG_TYPE_EXCEPTION); 58 | } 59 | 60 | } 61 | return false; 62 | } 63 | 64 | public function add($topic,$data){ 65 | try{ 66 | $fd = $this->connect(); 67 | if($fd===false){ 68 | throw new DqException(' connect server faild'); 69 | } 70 | $data['cmd']='add'; 71 | $data['topic'] = $topic; 72 | $message = json_encode($data); 73 | $sendMessage = pack("N", strlen($message)) . $message; 74 | if(socket_write($fd,$sendMessage)){ 75 | echo socket_read($fd,1024)."\n\n"; 76 | }else{ 77 | echo 'send message fail'."\n"; 78 | } 79 | 80 | }catch (DqException $e){ 81 | DqLog::writeLog($e->getDqMessage(),DqLog::LOG_TYPE_EXCEPTION); 82 | } 83 | return false; 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /DqWeb/libs/plugins/modifier.date_format.php: -------------------------------------------------------------------------------- 1 | 20 | * 21 | * @param string $string input date string 22 | * @param string $format strftime format for output 23 | * @param string $default_date default date if $string is empty 24 | * @param string $formatter either 'strftime' or 'auto' 25 | * 26 | * @return string |void 27 | * @uses smarty_make_timestamp() 28 | */ 29 | function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto') 30 | { 31 | if ($format === null) { 32 | $format = Smarty::$_DATE_FORMAT; 33 | } 34 | /** 35 | * require_once the {@link shared.make_timestamp.php} plugin 36 | */ 37 | static $is_loaded = false; 38 | if (!$is_loaded) { 39 | if (!is_callable('smarty_make_timestamp')) { 40 | include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'; 41 | } 42 | $is_loaded = true; 43 | } 44 | if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') { 45 | $timestamp = smarty_make_timestamp($string); 46 | } elseif ($default_date !== '') { 47 | $timestamp = smarty_make_timestamp($default_date); 48 | } else { 49 | return; 50 | } 51 | if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) { 52 | if (Smarty::$_IS_WINDOWS) { 53 | $_win_from = array( 54 | '%D', 55 | '%h', 56 | '%n', 57 | '%r', 58 | '%R', 59 | '%t', 60 | '%T' 61 | ); 62 | $_win_to = array( 63 | '%m/%d/%y', 64 | '%b', 65 | "\n", 66 | '%I:%M:%S %p', 67 | '%H:%M', 68 | "\t", 69 | '%H:%M:%S' 70 | ); 71 | if (strpos($format, '%e') !== false) { 72 | $_win_from[] = '%e'; 73 | $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); 74 | } 75 | if (strpos($format, '%l') !== false) { 76 | $_win_from[] = '%l'; 77 | $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); 78 | } 79 | $format = str_replace($_win_from, $_win_to, $format); 80 | } 81 | return strftime($format, $timestamp); 82 | } else { 83 | return date($format, $timestamp); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /java/src/main/java/com/phpdelayqueue/DqClient.java: -------------------------------------------------------------------------------- 1 | package com.phpdelayqueue; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | import com.google.gson.reflect.TypeToken; 6 | import org.apache.commons.lang3.StringUtils; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import java.lang.reflect.Type; 11 | import java.nio.charset.Charset; 12 | import java.util.List; 13 | 14 | public class DqClient { 15 | private static Logger logger = LoggerFactory.getLogger(DqClient.class); 16 | 17 | private Gson gson = new GsonBuilder().create(); 18 | 19 | private DqConfig dqConfig; 20 | 21 | public DqClient(DqConfig dqConfig) { 22 | this.dqConfig = dqConfig; 23 | } 24 | 25 | private DqResponse action(String request_str) { 26 | logger.info("requst content : {}", request_str); 27 | String response = SocketUtil.send(dqConfig.getHost(), dqConfig.getPort(), 28 | request_str.getBytes(Charset.forName("UTF-8"))); 29 | if (StringUtils.isEmpty(response)) { 30 | return null; 31 | } 32 | logger.info("response content : {}", response); 33 | 34 | Type type = new TypeToken>() { 35 | }.getType(); 36 | return gson.fromJson(response, type); 37 | } 38 | 39 | public DqResponse> add(DqRequestAdd request) { 40 | request.setCmd("add"); 41 | String requestJson = gson.toJson(request); 42 | 43 | return action(requestJson); 44 | } 45 | 46 | public DqResponse del(DqRequestBase request) { 47 | request.setCmd("del"); 48 | String requestJson = gson.toJson(request); 49 | return action(requestJson); 50 | } 51 | 52 | public DqResponse get(DqRequestBase request) { 53 | request.setCmd("get"); 54 | String requestJson = gson.toJson(request); 55 | return action(requestJson); 56 | } 57 | 58 | 59 | public static void main(String[] args) { 60 | DqConfig config = new DqConfig(); 61 | config.setHost(""); 62 | // config.setPort(8236); 63 | config.setPort(6789); 64 | 65 | DqClient dqClient = new DqClient(config); 66 | 67 | DqResponse response; 68 | DqRequestBase request = new DqRequestBase(); 69 | // request.setId("123456"); 70 | // request.setTopic("fankux"); 71 | // response = dqClient.get(request); 72 | // logger.info("get response : {}", response.toString()); 73 | // 74 | DqRequestAdd add = new DqRequestAdd(); 75 | add.setTopic("fankux"); 76 | add.setId("123456"); 77 | add.setBody("\\{\"a\" : \"b\"\\}"); 78 | DqResponse> addresponse = dqClient.add(add); 79 | logger.info("add response : {}", addresponse.toString()); 80 | 81 | response = dqClient.get(request); 82 | logger.info("get response : {}", response.toString()); 83 | 84 | DqResponse delResponse = dqClient.del(request); 85 | logger.info("del response : {}", delResponse.toString()); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /DqWeb/plugins/cacheresource.memcache.php: -------------------------------------------------------------------------------- 1 | memcache = new Memcached(); 29 | } else { 30 | $this->memcache = new Memcache(); 31 | } 32 | $this->memcache->addServer('127.0.0.1', 11211); 33 | } 34 | 35 | /** 36 | * Read values for a set of keys from cache 37 | * 38 | * @param array $keys list of keys to fetch 39 | * 40 | * @return array list of values with the given keys used as indexes 41 | * @return boolean true on success, false on failure 42 | */ 43 | protected function read(array $keys) 44 | { 45 | $_keys = $lookup = array(); 46 | foreach ($keys as $k) { 47 | $_k = sha1($k); 48 | $_keys[] = $_k; 49 | $lookup[ $_k ] = $k; 50 | } 51 | $_res = array(); 52 | $res = $this->memcache->get($_keys); 53 | foreach ($res as $k => $v) { 54 | $_res[ $lookup[ $k ] ] = $v; 55 | } 56 | return $_res; 57 | } 58 | 59 | /** 60 | * Save values for a set of keys to cache 61 | * 62 | * @param array $keys list of values to save 63 | * @param int $expire expiration time 64 | * 65 | * @return boolean true on success, false on failure 66 | */ 67 | protected function write(array $keys, $expire = null) 68 | { 69 | foreach ($keys as $k => $v) { 70 | $k = sha1($k); 71 | $this->memcache->set($k, $v, 0, $expire); 72 | } 73 | return true; 74 | } 75 | 76 | /** 77 | * Remove values from cache 78 | * 79 | * @param array $keys list of keys to delete 80 | * 81 | * @return boolean true on success, false on failure 82 | */ 83 | protected function delete(array $keys) 84 | { 85 | foreach ($keys as $k) { 86 | $k = sha1($k); 87 | $this->memcache->delete($k); 88 | } 89 | return true; 90 | } 91 | 92 | /** 93 | * Remove *all* values from cache 94 | * 95 | * @return boolean true on success, false on failure 96 | */ 97 | protected function purge() 98 | { 99 | return $this->memcache->flush(); 100 | } 101 | } 102 | --------------------------------------------------------------------------------