├── Applications ├── Statistics │ ├── Config │ │ ├── Cache │ │ │ └── empty │ │ └── Config.php │ ├── Web │ │ ├── js │ │ │ ├── scripts.js │ │ │ └── html5shiv.js │ │ ├── img │ │ │ ├── favicon.png │ │ │ ├── glyphicons-halflings.png │ │ │ ├── glyphicons-halflings-white.png │ │ │ ├── apple-touch-icon-57-precomposed.png │ │ │ ├── apple-touch-icon-72-precomposed.png │ │ │ ├── apple-touch-icon-114-precomposed.png │ │ │ └── apple-touch-icon-144-precomposed.png │ │ ├── css │ │ │ └── style.css │ │ ├── config.php │ │ ├── less │ │ │ ├── breadcrumbs.less │ │ │ ├── component-animations.less │ │ │ ├── wells.less │ │ │ ├── thumbnails.less │ │ │ ├── close.less │ │ │ ├── utilities.less │ │ │ ├── jumbotron.less │ │ │ ├── media.less │ │ │ ├── pager.less │ │ │ ├── badges.less │ │ │ ├── labels.less │ │ │ ├── bootstrap.less │ │ │ ├── code.less │ │ │ ├── alerts.less │ │ │ ├── print.less │ │ │ ├── pagination.less │ │ │ ├── progress-bars.less │ │ │ ├── list-group.less │ │ │ ├── scaffolding.less │ │ │ ├── grid.less │ │ │ ├── tooltip.less │ │ │ ├── modals.less │ │ │ ├── popovers.less │ │ │ ├── input-groups.less │ │ │ ├── buttons.less │ │ │ ├── panels.less │ │ │ ├── dropdowns.less │ │ │ ├── tables.less │ │ │ ├── carousel.less │ │ │ ├── responsive-utilities.less │ │ │ └── type.less │ │ ├── _init.php │ │ └── index.php │ ├── README.md │ ├── Views │ │ ├── footer.tpl.php │ │ ├── log.tpl.php │ │ ├── header.tpl.php │ │ ├── setting.tpl.php │ │ ├── login.tpl.php │ │ ├── admin.tpl.php │ │ └── statistic.tpl.php │ ├── Lib │ │ ├── Cache.php │ │ └── functions.php │ ├── Modules │ │ ├── setting.php │ │ ├── logger.php │ │ ├── admin.php │ │ └── statistic.php │ ├── start.php │ └── Protocols │ │ └── Statistic.php └── ThriftRpc │ ├── Services │ └── HelloWorld │ │ ├── HelloWorldHandler.php │ │ └── Types.php │ ├── Lib │ └── Thrift │ │ ├── Factory │ │ ├── TTransportFactory.php │ │ ├── TProtocolFactory.php │ │ ├── TCompactProtocolFactory.php │ │ ├── TJSONProtocolFactory.php │ │ ├── TBinaryProtocolFactory.php │ │ └── TStringFuncFactory.php │ │ ├── StringFunc │ │ ├── TStringFunc.php │ │ ├── Core.php │ │ └── Mbstring.php │ │ ├── Type │ │ ├── TMessageType.php │ │ └── TType.php │ │ ├── Server │ │ ├── TServerTransport.php │ │ ├── TSimpleServer.php │ │ ├── TServerSocket.php │ │ ├── TServer.php │ │ └── TForkingServer.php │ │ ├── Protocol │ │ ├── JSON │ │ │ ├── BaseContext.php │ │ │ ├── ListContext.php │ │ │ ├── LookaheadReader.php │ │ │ └── PairContext.php │ │ └── TBinaryProtocolAccelerated.php │ │ ├── Exception │ │ ├── TTransportException.php │ │ ├── TProtocolException.php │ │ └── TApplicationException.php │ │ ├── Transport │ │ ├── TNullTransport.php │ │ ├── TTransport.php │ │ ├── TMemoryBuffer.php │ │ ├── TPhpStream.php │ │ ├── TBufferedTransport.php │ │ ├── TFramedTransport.php │ │ └── THttpClient.php │ │ └── Serializer │ │ └── TBinarySerializer.php │ ├── start.php │ └── ThriftWorker.php ├── .gitignore ├── composer.json ├── start.php ├── MIT-LICENSE.txt └── composer.lock /Applications/Statistics/Config/Cache/empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/js/scripts.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | logs 2 | .buildpath 3 | .project 4 | .settings 5 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/workerman-thrift/HEAD/Applications/Statistics/Web/img/favicon.png -------------------------------------------------------------------------------- /Applications/Statistics/Web/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/workerman-thrift/HEAD/Applications/Statistics/Web/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /Applications/Statistics/README.md: -------------------------------------------------------------------------------- 1 | 2 | 统计模块 3 | ======= 4 | 5 | * 管理员用户名密码默认都为空,即不需要登录就可以查看监控数据 6 | * 如果需要登录验证,在applications/Statistics/Config/Config.php里面设置管理员密码 7 | 8 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/workerman-thrift/HEAD/Applications/Statistics/Web/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /Applications/Statistics/Views/footer.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/img/apple-touch-icon-57-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/workerman-thrift/HEAD/Applications/Statistics/Web/img/apple-touch-icon-57-precomposed.png -------------------------------------------------------------------------------- /Applications/Statistics/Web/img/apple-touch-icon-72-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/workerman-thrift/HEAD/Applications/Statistics/Web/img/apple-touch-icon-72-precomposed.png -------------------------------------------------------------------------------- /Applications/Statistics/Web/img/apple-touch-icon-114-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/workerman-thrift/HEAD/Applications/Statistics/Web/img/apple-touch-icon-114-precomposed.png -------------------------------------------------------------------------------- /Applications/Statistics/Web/img/apple-touch-icon-144-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/walkor/workerman-thrift/HEAD/Applications/Statistics/Web/img/apple-touch-icon-144-precomposed.png -------------------------------------------------------------------------------- /Applications/ThriftRpc/Services/HelloWorld/HelloWorldHandler.php: -------------------------------------------------------------------------------- 1 | a 18 | { 19 | font-size:bold; 20 | color:#333; 21 | } -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Factory/TTransportFactory.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Statistics\Web; 15 | class Config 16 | { 17 | // 数据源端口,会向这个端口发送udp广播获取ip,然后从这个端口以tcp协议获取统计信息 18 | public static $ProviderPort = 55858; 19 | } -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/breadcrumbs.less: -------------------------------------------------------------------------------- 1 | // 2 | // Breadcrumbs 3 | // -------------------------------------------------- 4 | 5 | 6 | .breadcrumb { 7 | padding: 8px 15px; 8 | margin-bottom: @line-height-computed; 9 | list-style: none; 10 | background-color: @breadcrumb-bg; 11 | border-radius: @border-radius-base; 12 | > li { 13 | display: inline-block; 14 | + li:before { 15 | content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space 16 | padding: 0 5px; 17 | color: @breadcrumb-color; 18 | } 19 | } 20 | > .active { 21 | color: @breadcrumb-active-color; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/component-animations.less: -------------------------------------------------------------------------------- 1 | // 2 | // Component animations 3 | // -------------------------------------------------- 4 | 5 | // Heads up! 6 | // 7 | // We don't use the `.opacity()` mixin here since it causes a bug with text 8 | // fields in IE7-8. Source: https://github.com/twitter/bootstrap/pull/3552. 9 | 10 | .fade { 11 | opacity: 0; 12 | .transition(opacity .15s linear); 13 | &.in { 14 | opacity: 1; 15 | } 16 | } 17 | 18 | .collapse { 19 | display: none; 20 | &.in { 21 | display: block; 22 | } 23 | } 24 | .collapsing { 25 | position: relative; 26 | height: 0; 27 | overflow: hidden; 28 | .transition(height .35s ease); 29 | } 30 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/wells.less: -------------------------------------------------------------------------------- 1 | // 2 | // Wells 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .well { 8 | min-height: 20px; 9 | padding: 19px; 10 | margin-bottom: 20px; 11 | background-color: @well-bg; 12 | border: 1px solid darken(@well-bg, 7%); 13 | border-radius: @border-radius-base; 14 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.05)); 15 | blockquote { 16 | border-color: #ddd; 17 | border-color: rgba(0,0,0,.15); 18 | } 19 | } 20 | 21 | // Sizes 22 | .well-lg { 23 | padding: 24px; 24 | border-radius: @border-radius-large; 25 | } 26 | .well-sm { 27 | padding: 9px; 28 | border-radius: @border-radius-small; 29 | } 30 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/thumbnails.less: -------------------------------------------------------------------------------- 1 | // 2 | // Thumbnails 3 | // -------------------------------------------------- 4 | 5 | 6 | // Mixin and adjust the regular image class 7 | .thumbnail { 8 | .img-thumbnail(); 9 | display: block; // Override the inline-block from `.img-thumbnail` 10 | margin-bottom: @line-height-computed; 11 | 12 | > img { 13 | .img-responsive(); 14 | margin-left: auto; 15 | margin-right: auto; 16 | } 17 | } 18 | 19 | 20 | // Add a hover state for linked versions only 21 | a.thumbnail:hover, 22 | a.thumbnail:focus, 23 | a.thumbnail.active { 24 | border-color: @link-color; 25 | } 26 | 27 | // Image captions 28 | .thumbnail .caption { 29 | padding: @thumbnail-caption-padding; 30 | color: @thumbnail-caption-color; 31 | } 32 | -------------------------------------------------------------------------------- /start.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Statistics\Lib; 15 | class Cache 16 | { 17 | public static $statisticDataCache = array(); 18 | public static $ServerIpList = array(); 19 | public static $modulesDataCache = array(); 20 | public static $lastFailedIpArray = array(); 21 | public static $lastSuccessIpArray = array(); 22 | } -------------------------------------------------------------------------------- /Applications/Statistics/Web/_init.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | define('ST_ROOT', realpath(__DIR__.'/../')); 15 | require_once ST_ROOT .'/Lib/functions.php'; 16 | require_once ST_ROOT .'/Lib/Cache.php'; 17 | require_once ST_ROOT .'/Config/Config.php'; 18 | // 覆盖配置文件 19 | foreach(glob(ST_ROOT . '/Config/Cache/*.php') as $php_file) 20 | { 21 | require_once $php_file; 22 | } -------------------------------------------------------------------------------- /Applications/ThriftRpc/start.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | use Workerman\Worker; 15 | require_once __DIR__ . '/ThriftWorker.php'; 16 | 17 | 18 | $worker = new ThriftWorker('tcp://0.0.0.0:9090'); 19 | $worker->count = 16; 20 | $worker->class = 'HelloWorld'; 21 | 22 | 23 | // 如果不是在根目录启动,则运行runAll方法 24 | if(!defined('GLOBAL_START')) 25 | { 26 | Worker::runAll(); 27 | } 28 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/close.less: -------------------------------------------------------------------------------- 1 | // 2 | // Close icons 3 | // -------------------------------------------------- 4 | 5 | 6 | .close { 7 | float: right; 8 | font-size: (@font-size-base * 1.5); 9 | font-weight: @close-font-weight; 10 | line-height: 1; 11 | color: @close-color; 12 | text-shadow: @close-text-shadow; 13 | .opacity(.2); 14 | 15 | &:hover, 16 | &:focus { 17 | color: @close-color; 18 | text-decoration: none; 19 | cursor: pointer; 20 | .opacity(.5); 21 | } 22 | 23 | // Additional properties for button version 24 | // iOS requires the button element instead of an anchor tag. 25 | // If you want the anchor version, it requires `href="#"`. 26 | button& { 27 | padding: 0; 28 | cursor: pointer; 29 | background: transparent; 30 | border: 0; 31 | -webkit-appearance: none; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Applications/Statistics/Config/Config.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Statistics; 15 | class Config 16 | { 17 | // 数据源端口,会向这个端口发送udp广播获取ip,然后从这个端口以tcp协议获取统计信息 18 | public static $ProviderPort = 55858; 19 | 20 | // 管理员用户名,用户名密码都为空字符串时说明不用验证 21 | public static $adminName = ''; 22 | 23 | // 管理员密码,用户名密码都为空字符串时说明不用验证 24 | public static $adminPassword = ''; 25 | 26 | public static $dataPath = ''; 27 | } 28 | 29 | Config::$dataPath = __DIR__ . '/../data/'; -------------------------------------------------------------------------------- /Applications/Statistics/Views/log.tpl.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 32 |
33 |
34 |
35 |
36 | 37 |
38 |
39 |
40 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/utilities.less: -------------------------------------------------------------------------------- 1 | // 2 | // Utility classes 3 | // -------------------------------------------------- 4 | 5 | 6 | // Floats 7 | // ------------------------- 8 | 9 | .clearfix { 10 | .clearfix(); 11 | } 12 | .center-block { 13 | .center-block(); 14 | } 15 | .pull-right { 16 | float: right !important; 17 | } 18 | .pull-left { 19 | float: left !important; 20 | } 21 | 22 | 23 | // Toggling content 24 | // ------------------------- 25 | 26 | // Note: Deprecated .hide in favor of .hidden or .sr-only (as appropriate) in v3.0.1 27 | .hide { 28 | display: none !important; 29 | } 30 | .show { 31 | display: block !important; 32 | } 33 | .invisible { 34 | visibility: hidden; 35 | } 36 | .text-hide { 37 | .text-hide(); 38 | } 39 | 40 | 41 | // Hide from screenreaders and browsers 42 | // 43 | // Credit: HTML5 Boilerplate 44 | 45 | .hidden { 46 | display: none !important; 47 | visibility: hidden !important; 48 | } 49 | 50 | 51 | // For Affix plugin 52 | // ------------------------- 53 | 54 | .affix { 55 | position: fixed; 56 | } 57 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/jumbotron.less: -------------------------------------------------------------------------------- 1 | // 2 | // Jumbotron 3 | // -------------------------------------------------- 4 | 5 | 6 | .jumbotron { 7 | padding: @jumbotron-padding; 8 | margin-bottom: @jumbotron-padding; 9 | font-size: @jumbotron-font-size; 10 | font-weight: 200; 11 | line-height: (@line-height-base * 1.5); 12 | color: @jumbotron-color; 13 | background-color: @jumbotron-bg; 14 | 15 | h1 { 16 | line-height: 1; 17 | color: @jumbotron-heading-color; 18 | } 19 | p { 20 | line-height: 1.4; 21 | } 22 | 23 | .container & { 24 | border-radius: @border-radius-large; // Only round corners at higher resolutions if contained in a container 25 | } 26 | 27 | @media screen and (min-width: @screen-sm-min) { 28 | padding-top: (@jumbotron-padding * 1.6); 29 | padding-bottom: (@jumbotron-padding * 1.6); 30 | 31 | .container & { 32 | padding-left: (@jumbotron-padding * 2); 33 | padding-right: (@jumbotron-padding * 2); 34 | } 35 | 36 | h1 { 37 | font-size: (@font-size-base * 4.5); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/StringFunc/TStringFunc.php: -------------------------------------------------------------------------------- 1 | .pull-left { 41 | margin-right: 10px; 42 | } 43 | > .pull-right { 44 | margin-left: 10px; 45 | } 46 | } 47 | 48 | 49 | // Media list variation 50 | // ------------------------- 51 | 52 | // Undo default ul/ol styles 53 | .media-list { 54 | padding-left: 0; 55 | list-style: none; 56 | } 57 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/pager.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pager pagination 3 | // -------------------------------------------------- 4 | 5 | 6 | .pager { 7 | padding-left: 0; 8 | margin: @line-height-computed 0; 9 | list-style: none; 10 | text-align: center; 11 | .clearfix(); 12 | li { 13 | display: inline; 14 | > a, 15 | > span { 16 | display: inline-block; 17 | padding: 5px 14px; 18 | background-color: @pagination-bg; 19 | border: 1px solid @pagination-border; 20 | border-radius: @pager-border-radius; 21 | } 22 | 23 | > a:hover, 24 | > a:focus { 25 | text-decoration: none; 26 | background-color: @pagination-hover-bg; 27 | } 28 | } 29 | 30 | .next { 31 | > a, 32 | > span { 33 | float: right; 34 | } 35 | } 36 | 37 | .previous { 38 | > a, 39 | > span { 40 | float: left; 41 | } 42 | } 43 | 44 | .disabled { 45 | > a, 46 | > a:hover, 47 | > a:focus, 48 | > span { 49 | color: @pager-disabled-color; 50 | background-color: @pagination-bg; 51 | cursor: not-allowed; 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Type/TMessageType.php: -------------------------------------------------------------------------------- 1 | acceptImpl(); 47 | 48 | if ($transport == null) { 49 | throw new TTransportException("accept() may not return NULL"); 50 | } 51 | 52 | return $transport; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Protocol/JSON/BaseContext.php: -------------------------------------------------------------------------------- 1 | and contributors (see https://github.com/walkor/workerman/contributors) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/badges.less: -------------------------------------------------------------------------------- 1 | // 2 | // Badges 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base classes 7 | .badge { 8 | display: inline-block; 9 | min-width: 10px; 10 | padding: 3px 7px; 11 | font-size: @font-size-small; 12 | font-weight: @badge-font-weight; 13 | color: @badge-color; 14 | line-height: @badge-line-height; 15 | vertical-align: baseline; 16 | white-space: nowrap; 17 | text-align: center; 18 | background-color: @badge-bg; 19 | border-radius: @badge-border-radius; 20 | 21 | // Empty badges collapse automatically (not available in IE8) 22 | &:empty { 23 | display: none; 24 | } 25 | } 26 | 27 | // Hover state, but only for links 28 | a.badge { 29 | &:hover, 30 | &:focus { 31 | color: @badge-link-hover-color; 32 | text-decoration: none; 33 | cursor: pointer; 34 | } 35 | } 36 | 37 | // Quick fix for labels/badges in buttons 38 | .btn .badge { 39 | position: relative; 40 | top: -1px; 41 | } 42 | 43 | // Account for counters in navs 44 | a.list-group-item.active > .badge, 45 | .nav-pills > .active > a > .badge { 46 | color: @badge-active-color; 47 | background-color: @badge-active-bg; 48 | } 49 | .nav-pills > li > a > .badge { 50 | margin-left: 3px; 51 | } 52 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/labels.less: -------------------------------------------------------------------------------- 1 | // 2 | // Labels 3 | // -------------------------------------------------- 4 | 5 | .label { 6 | display: inline; 7 | padding: .2em .6em .3em; 8 | font-size: 75%; 9 | font-weight: bold; 10 | line-height: 1; 11 | color: @label-color; 12 | text-align: center; 13 | white-space: nowrap; 14 | vertical-align: baseline; 15 | border-radius: .25em; 16 | 17 | // Add hover effects, but only for links 18 | &[href] { 19 | &:hover, 20 | &:focus { 21 | color: @label-link-hover-color; 22 | text-decoration: none; 23 | cursor: pointer; 24 | } 25 | } 26 | 27 | // Empty labels collapse automatically (not available in IE8) 28 | &:empty { 29 | display: none; 30 | } 31 | } 32 | 33 | // Colors 34 | // Contextual variations (linked labels get darker on :hover) 35 | 36 | .label-default { 37 | .label-variant(@label-default-bg); 38 | } 39 | 40 | .label-primary { 41 | .label-variant(@label-primary-bg); 42 | } 43 | 44 | .label-success { 45 | .label-variant(@label-success-bg); 46 | } 47 | 48 | .label-info { 49 | .label-variant(@label-info-bg); 50 | } 51 | 52 | .label-warning { 53 | .label-variant(@label-warning-bg); 54 | } 55 | 56 | .label-danger { 57 | .label-variant(@label-danger-bg); 58 | } 59 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Factory/TProtocolFactory.php: -------------------------------------------------------------------------------- 1 | strictRead_ = $strictRead; 37 | $this->strictWrite_ = $strictWrite; 38 | } 39 | 40 | public function getProtocol($trans) { 41 | return new TBinaryProtocol($trans, $this->strictRead_, $this->strictWrite_); 42 | } 43 | } -------------------------------------------------------------------------------- /Applications/Statistics/Web/index.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | require_once __DIR__.'/_init.php'; 15 | 16 | // 检查是否登录 17 | check_auth(); 18 | 19 | $func = isset($_GET['fn']) ? $_GET['fn'] : 'main'; 20 | $func = "\\Statistics\\Modules\\".$func; 21 | if(!function_exists($func)) 22 | { 23 | foreach(glob(ST_ROOT . "/Modules/*") as $php_file) 24 | { 25 | require_once $php_file; 26 | } 27 | } 28 | 29 | if(!function_exists($func)) 30 | { 31 | $func = "\\Statistics\\Modules\\main"; 32 | } 33 | 34 | $module = isset($_GET['module']) ? $_GET['module'] : ''; 35 | $interface = isset($_GET['interface']) ? $_GET['interface'] : ''; 36 | $date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d'); 37 | $start_time = isset($_GET['start_time']) ? $_GET['start_time'] : strtotime(date('Y-m-d')); 38 | $offset = isset($_GET['offset']) ? $_GET['offset'] : 0; 39 | $log_count_per_ip = $log_count_per_page = 40; 40 | if(empty($_GET['count']) && $ip_count = count(\Statistics\Lib\Cache::$ServerIpList)) 41 | { 42 | $log_count_per_ip = ceil($log_count_per_page/$ip_count); 43 | } 44 | call_user_func_array($func, array($module, $interface, $date, $start_time, $offset, $log_count_per_ip)); -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Exception/TProtocolException.php: -------------------------------------------------------------------------------- 1 | transport_->listen(); 30 | 31 | while (!$this->stop_) { 32 | try { 33 | $transport = $this->transport_->accept(); 34 | 35 | if ($transport != null) { 36 | $inputTransport = $this->inputTransportFactory_->getTransport($transport); 37 | $outputTransport = $this->outputTransportFactory_->getTransport($transport); 38 | $inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport); 39 | $outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport); 40 | while ($this->processor_->process($inputProtocol, $outputProtocol)) { } 41 | } 42 | } 43 | catch (TTransportException $e) { } 44 | } 45 | } 46 | 47 | /** 48 | * Stops the server running. Kills the transport 49 | * and then stops the main serving loop 50 | * 51 | * @return void 52 | */ 53 | public function stop() { 54 | $this->transport_->close(); 55 | $this->stop_ = true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/alerts.less: -------------------------------------------------------------------------------- 1 | // 2 | // Alerts 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base styles 7 | // ------------------------- 8 | 9 | .alert { 10 | padding: @alert-padding; 11 | margin-bottom: @line-height-computed; 12 | border: 1px solid transparent; 13 | border-radius: @alert-border-radius; 14 | 15 | // Headings for larger alerts 16 | h4 { 17 | margin-top: 0; 18 | // Specified for the h4 to prevent conflicts of changing @headings-color 19 | color: inherit; 20 | } 21 | // Provide class for links that match alerts 22 | .alert-link { 23 | font-weight: @alert-link-font-weight; 24 | } 25 | 26 | // Improve alignment and spacing of inner content 27 | > p, 28 | > ul { 29 | margin-bottom: 0; 30 | } 31 | > p + p { 32 | margin-top: 5px; 33 | } 34 | } 35 | 36 | // Dismissable alerts 37 | // 38 | // Expand the right padding and account for the close button's positioning. 39 | 40 | .alert-dismissable { 41 | padding-right: (@alert-padding + 20); 42 | 43 | // Adjust close link position 44 | .close { 45 | position: relative; 46 | top: -2px; 47 | right: -21px; 48 | color: inherit; 49 | } 50 | } 51 | 52 | // Alternate styles 53 | // 54 | // Generate contextual modifier classes for colorizing the alert. 55 | 56 | .alert-success { 57 | .alert-variant(@alert-success-bg; @alert-success-border; @alert-success-text); 58 | } 59 | .alert-info { 60 | .alert-variant(@alert-info-bg; @alert-info-border; @alert-info-text); 61 | } 62 | .alert-warning { 63 | .alert-variant(@alert-warning-bg; @alert-warning-border; @alert-warning-text); 64 | } 65 | .alert-danger { 66 | .alert-variant(@alert-danger-bg; @alert-danger-border; @alert-danger-text); 67 | } 68 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Protocol/JSON/ListContext.php: -------------------------------------------------------------------------------- 1 | p_ = $p; 35 | } 36 | 37 | public function write() { 38 | if ($this->first_) { 39 | $this->first_ = false; 40 | } else { 41 | $this->p_->getTransport()->write(TJSONProtocol::COMMA); 42 | } 43 | } 44 | 45 | public function read() { 46 | if ($this->first_) { 47 | $this->first_ = false; 48 | } else { 49 | $this->p_->readJSONSyntaxChar(TJSONProtocol::COMMA); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/StringFunc/Mbstring.php: -------------------------------------------------------------------------------- 1 | strlen($str) - $start; 37 | } 38 | 39 | return mb_substr($str, $start, $length, '8bit'); 40 | } 41 | 42 | public function strlen($str) { 43 | return mb_strlen($str, '8bit'); 44 | } 45 | } -------------------------------------------------------------------------------- /Applications/Statistics/Views/header.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WorkerMan-集群统计与监控 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Protocol/JSON/LookaheadReader.php: -------------------------------------------------------------------------------- 1 | p_ = $p; 34 | } 35 | 36 | public function read() { 37 | if ($this->hasData_) { 38 | $this->hasData_ = false; 39 | } else { 40 | $this->data_ = $this->p_->getTransport()->readAll(1); 41 | } 42 | 43 | return substr($this->data_, 0, 1); 44 | } 45 | 46 | public function peek() { 47 | if (!$this->hasData_) { 48 | $this->data_ = $this->p_->getTransport()->readAll(1); 49 | } 50 | 51 | $this->hasData_ = true; 52 | return substr($this->data_, 0, 1); 53 | } 54 | } -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Protocol/TBinaryProtocolAccelerated.php: -------------------------------------------------------------------------------- 1 | strictRead_; 43 | } 44 | public function isStrictWrite() { 45 | return $this->strictWrite_; 46 | } 47 | } -------------------------------------------------------------------------------- /Applications/Statistics/Modules/setting.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Statistics\Modules; 15 | 16 | function setting() 17 | { 18 | $act = isset($_GET['act'])? $_GET['act'] : 'home'; 19 | $err_msg = $notice_msg = $suc_msg = $ip_list_str = ''; 20 | switch($act) 21 | { 22 | case 'save': 23 | if(empty($_POST['detect_port'])) 24 | { 25 | $err_msg = "探测端口不能为空"; 26 | break; 27 | } 28 | $detect_port = (int)$_POST['detect_port']; 29 | 30 | if($detect_port<0 || $detect_port > 65535) 31 | { 32 | $err_msg = "探测端口不合法"; 33 | break; 34 | } 35 | $suc_msg = "保存成功"; 36 | \Statistics\Config::$ProviderPort = $detect_port; 37 | saveDetectPortToCache(); 38 | break; 39 | default: 40 | $detect_port = \Statistics\Config::$ProviderPort; 41 | } 42 | 43 | include ST_ROOT . '/Views/header.tpl.php'; 44 | include ST_ROOT . '/Views/setting.tpl.php'; 45 | include ST_ROOT . '/Views/footer.tpl.php'; 46 | } 47 | 48 | function saveDetectPortToCache() 49 | { 50 | foreach(glob(ST_ROOT . '/Config/Cache/*detect_port.cache.php') as $php_file) 51 | { 52 | unlink($php_file); 53 | } 54 | file_put_contents(ST_ROOT . '/Config/Cache/'.time().'.detect_port.cache.php', " 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | require_once __DIR__ .'/Config/Config.php'; 15 | require_once __DIR__.'/Protocols/Statistic.php'; 16 | require_once __DIR__.'/Bootstrap/StatisticProvider.php'; 17 | require_once __DIR__.'/Bootstrap/StatisticWorker.php'; 18 | use Bootstrap\StatisticProvider; 19 | use Bootstrap\StatisticWorker; 20 | use \Workerman\Worker; 21 | use \Workerman\WebServer; 22 | // StatisticProvider 23 | $statistic_provider = new StatisticProvider("Text://0.0.0.0:55858"); 24 | $statistic_provider->name = 'StatisticProvider'; 25 | // StatisticWorker 26 | $statistic_worker = new StatisticWorker("Statistic://0.0.0.0:55656"); 27 | $statistic_worker->transport = 'udp'; 28 | $statistic_worker->name = 'StatisticWorker'; 29 | // WebServer 30 | $web = new WebServer("http://0.0.0.0:55757"); 31 | $web->name = 'StatisticWeb'; 32 | $web->addRoot('www.your_domain.com', __DIR__.'/Web'); 33 | // recv udp broadcast 34 | $udp_finder = new Worker("Text://0.0.0.0:55858"); 35 | $udp_finder->name = 'StatisticFinder'; 36 | $udp_finder->transport = 'udp'; 37 | $udp_finder->onMessage = function ($connection, $data) 38 | { 39 | $data = json_decode($data, true); 40 | if(empty($data)) 41 | { 42 | return false; 43 | } 44 | // 无法解析的包 45 | if(empty($data['cmd']) || $data['cmd'] != 'REPORT_IP' ) 46 | { 47 | return false; 48 | } 49 | // response 50 | return $connection->send(json_encode(array('result'=>'ok'))); 51 | }; 52 | // 如果不是在根目录启动,则运行runAll方法 53 | if(!defined('GLOBAL_START')) 54 | { 55 | Worker::runAll(); 56 | } 57 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Protocol/JSON/PairContext.php: -------------------------------------------------------------------------------- 1 | p_ = $p; 35 | } 36 | 37 | public function write() { 38 | if ($this->first_) { 39 | $this->first_ = false; 40 | $this->colon_ = true; 41 | } else { 42 | $this->p_->getTransport()->write($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA); 43 | $this->colon_ = !$this->colon_; 44 | } 45 | } 46 | 47 | public function read() { 48 | if ($this->first_) { 49 | $this->first_ = false; 50 | $this->colon_ = true; 51 | } else { 52 | $this->p_->readJSONSyntaxChar($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA); 53 | $this->colon_ = !$this->colon_; 54 | } 55 | } 56 | 57 | public function escapeNum() { 58 | return $this->colon_; 59 | } 60 | } -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/print.less: -------------------------------------------------------------------------------- 1 | // 2 | // Basic print styles 3 | // -------------------------------------------------- 4 | // Source: https://github.com/h5bp/html5-boilerplate/blob/master/css/main.css 5 | 6 | @media print { 7 | 8 | * { 9 | text-shadow: none !important; 10 | color: #000 !important; // Black prints faster: h5bp.com/s 11 | background: transparent !important; 12 | box-shadow: none !important; 13 | } 14 | 15 | a, 16 | a:visited { 17 | text-decoration: underline; 18 | } 19 | 20 | a[href]:after { 21 | content: " (" attr(href) ")"; 22 | } 23 | 24 | abbr[title]:after { 25 | content: " (" attr(title) ")"; 26 | } 27 | 28 | // Don't show links for images, or javascript/internal links 29 | a[href^="javascript:"]:after, 30 | a[href^="#"]:after { 31 | content: ""; 32 | } 33 | 34 | pre, 35 | blockquote { 36 | border: 1px solid #999; 37 | page-break-inside: avoid; 38 | } 39 | 40 | thead { 41 | display: table-header-group; // h5bp.com/t 42 | } 43 | 44 | tr, 45 | img { 46 | page-break-inside: avoid; 47 | } 48 | 49 | img { 50 | max-width: 100% !important; 51 | } 52 | 53 | @page { 54 | margin: 2cm .5cm; 55 | } 56 | 57 | p, 58 | h2, 59 | h3 { 60 | orphans: 3; 61 | widows: 3; 62 | } 63 | 64 | h2, 65 | h3 { 66 | page-break-after: avoid; 67 | } 68 | 69 | // Chrome (OSX) fix for https://github.com/twbs/bootstrap/issues/11245 70 | // Once fixed, we can just straight up remove this. 71 | select { 72 | background: #fff !important; 73 | } 74 | 75 | // Bootstrap components 76 | .navbar { 77 | display: none; 78 | } 79 | .table { 80 | td, 81 | th { 82 | background-color: #fff !important; 83 | } 84 | } 85 | .btn, 86 | .dropup > .btn { 87 | > .caret { 88 | border-top-color: #000 !important; 89 | } 90 | } 91 | .label { 92 | border: 1px solid #000; 93 | } 94 | 95 | .table { 96 | border-collapse: collapse !important; 97 | } 98 | .table-bordered { 99 | th, 100 | td { 101 | border: 1px solid #ddd !important; 102 | } 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/pagination.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pagination (multiple pages) 3 | // -------------------------------------------------- 4 | .pagination { 5 | display: inline-block; 6 | padding-left: 0; 7 | margin: @line-height-computed 0; 8 | border-radius: @border-radius-base; 9 | 10 | > li { 11 | display: inline; // Remove list-style and block-level defaults 12 | > a, 13 | > span { 14 | position: relative; 15 | float: left; // Collapse white-space 16 | padding: @padding-base-vertical @padding-base-horizontal; 17 | line-height: @line-height-base; 18 | text-decoration: none; 19 | background-color: @pagination-bg; 20 | border: 1px solid @pagination-border; 21 | margin-left: -1px; 22 | } 23 | &:first-child { 24 | > a, 25 | > span { 26 | margin-left: 0; 27 | .border-left-radius(@border-radius-base); 28 | } 29 | } 30 | &:last-child { 31 | > a, 32 | > span { 33 | .border-right-radius(@border-radius-base); 34 | } 35 | } 36 | } 37 | 38 | > li > a, 39 | > li > span { 40 | &:hover, 41 | &:focus { 42 | background-color: @pagination-hover-bg; 43 | } 44 | } 45 | 46 | > .active > a, 47 | > .active > span { 48 | &, 49 | &:hover, 50 | &:focus { 51 | z-index: 2; 52 | color: @pagination-active-color; 53 | background-color: @pagination-active-bg; 54 | border-color: @pagination-active-bg; 55 | cursor: default; 56 | } 57 | } 58 | 59 | > .disabled { 60 | > span, 61 | > span:hover, 62 | > span:focus, 63 | > a, 64 | > a:hover, 65 | > a:focus { 66 | color: @pagination-disabled-color; 67 | background-color: @pagination-bg; 68 | border-color: @pagination-border; 69 | cursor: not-allowed; 70 | } 71 | } 72 | } 73 | 74 | // Sizing 75 | // -------------------------------------------------- 76 | 77 | // Large 78 | .pagination-lg { 79 | .pagination-size(@padding-large-vertical; @padding-large-horizontal; @font-size-large; @border-radius-large); 80 | } 81 | 82 | // Small 83 | .pagination-sm { 84 | .pagination-size(@padding-small-vertical; @padding-small-horizontal; @font-size-small; @border-radius-small); 85 | } 86 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Factory/TStringFuncFactory.php: -------------------------------------------------------------------------------- 1 | .striped(); 65 | background-size: 40px 40px; 66 | } 67 | 68 | // Call animation for the active one 69 | .progress.active .progress-bar { 70 | .animation(progress-bar-stripes 2s linear infinite); 71 | } 72 | 73 | 74 | 75 | // Variations 76 | // ------------------------- 77 | 78 | .progress-bar-success { 79 | .progress-bar-variant(@progress-bar-success-bg); 80 | } 81 | 82 | .progress-bar-info { 83 | .progress-bar-variant(@progress-bar-info-bg); 84 | } 85 | 86 | .progress-bar-warning { 87 | .progress-bar-variant(@progress-bar-warning-bg); 88 | } 89 | 90 | .progress-bar-danger { 91 | .progress-bar-variant(@progress-bar-danger-bg); 92 | } 93 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Server/TServerSocket.php: -------------------------------------------------------------------------------- 1 | host_ = $host; 52 | $this->port_ = $port; 53 | } 54 | 55 | /** 56 | * Sets the accept timeout 57 | * 58 | * @param int $acceptTimeout 59 | * @return void 60 | */ 61 | public function setAcceptTimeout($acceptTimeout) { 62 | $this->acceptTimeout_ = $acceptTimeout; 63 | } 64 | 65 | /** 66 | * Opens a new socket server handle 67 | * 68 | * @return void 69 | */ 70 | public function listen() { 71 | $this->listener_ = stream_socket_server('tcp://' . $this->host_ . ':' . $this->port_); 72 | } 73 | 74 | /** 75 | * Closes the socket server handle 76 | * 77 | * @return void 78 | */ 79 | public function close() { 80 | @fclose($this->listener_); 81 | $this->listener_ = null; 82 | } 83 | 84 | /** 85 | * Implementation of accept. If not client is accepted in the given time 86 | * 87 | * @return TSocket 88 | */ 89 | protected function acceptImpl() { 90 | $handle = @stream_socket_accept($this->listener_, $this->acceptTimeout_ / 1000.0); 91 | if(!$handle) return null; 92 | 93 | $socket = new TSocket(); 94 | $socket->setHandle($handle); 95 | 96 | return $socket; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/list-group.less: -------------------------------------------------------------------------------- 1 | // 2 | // List groups 3 | // -------------------------------------------------- 4 | 5 | // Base class 6 | // 7 | // Easily usable on
    ,
      , or
      . 8 | .list-group { 9 | // No need to set list-style: none; since .list-group-item is block level 10 | margin-bottom: 20px; 11 | padding-left: 0; // reset padding because ul and ol 12 | } 13 | 14 | // Individual list items 15 | // ------------------------- 16 | 17 | .list-group-item { 18 | position: relative; 19 | display: block; 20 | padding: 10px 15px; 21 | // Place the border on the list items and negative margin up for better styling 22 | margin-bottom: -1px; 23 | background-color: @list-group-bg; 24 | border: 1px solid @list-group-border; 25 | 26 | // Round the first and last items 27 | &:first-child { 28 | .border-top-radius(@list-group-border-radius); 29 | } 30 | &:last-child { 31 | margin-bottom: 0; 32 | .border-bottom-radius(@list-group-border-radius); 33 | } 34 | 35 | // Align badges within list items 36 | > .badge { 37 | float: right; 38 | } 39 | > .badge + .badge { 40 | margin-right: 5px; 41 | } 42 | } 43 | 44 | // Linked list items 45 | a.list-group-item { 46 | color: @list-group-link-color; 47 | 48 | .list-group-item-heading { 49 | color: @list-group-link-heading-color; 50 | } 51 | 52 | // Hover state 53 | &:hover, 54 | &:focus { 55 | text-decoration: none; 56 | background-color: @list-group-hover-bg; 57 | } 58 | 59 | // Active class on item itself, not parent 60 | &.active, 61 | &.active:hover, 62 | &.active:focus { 63 | z-index: 2; // Place active items above their siblings for proper border styling 64 | color: @list-group-active-color; 65 | background-color: @list-group-active-bg; 66 | border-color: @list-group-active-border; 67 | 68 | // Force color to inherit for custom content 69 | .list-group-item-heading { 70 | color: inherit; 71 | } 72 | .list-group-item-text { 73 | color: lighten(@list-group-active-bg, 40%); 74 | } 75 | } 76 | } 77 | 78 | // Custom content options 79 | // ------------------------- 80 | 81 | .list-group-item-heading { 82 | margin-top: 0; 83 | margin-bottom: 5px; 84 | } 85 | .list-group-item-text { 86 | margin-bottom: 0; 87 | line-height: 1.3; 88 | } 89 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/js/html5shiv.js: -------------------------------------------------------------------------------- 1 | /* 2 | HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag(); 5 | a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x"; 6 | c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode|| 7 | "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video",version:"3.6.2",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment(); 8 | for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d=5.3" 26 | }, 27 | "suggest": { 28 | "ext-libevent": "For better performance." 29 | }, 30 | "type": "project", 31 | "autoload": { 32 | "psr-4": { 33 | "Workerman\\": "./" 34 | } 35 | }, 36 | "notification-url": "https://packagist.org/downloads/", 37 | "license": [ 38 | "MIT" 39 | ], 40 | "authors": [ 41 | { 42 | "name": "walkor", 43 | "email": "walkor@workerman.net", 44 | "homepage": "http://www.workerman.net", 45 | "role": "Developer" 46 | } 47 | ], 48 | "description": "An asynchronous event driven PHP framework for easily building fast, scalable network applications.", 49 | "homepage": "http://www.workerman.net", 50 | "keywords": [ 51 | "asynchronous", 52 | "event-loop" 53 | ], 54 | "time": "2016-09-19 02:15:51" 55 | } 56 | ], 57 | "packages-dev": [], 58 | "aliases": [], 59 | "minimum-stability": "stable", 60 | "stability-flags": [], 61 | "prefer-stable": false, 62 | "prefer-lowest": false, 63 | "platform": [], 64 | "platform-dev": [] 65 | } 66 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/scaffolding.less: -------------------------------------------------------------------------------- 1 | // 2 | // Scaffolding 3 | // -------------------------------------------------- 4 | 5 | 6 | // Reset the box-sizing 7 | 8 | *, 9 | *:before, 10 | *:after { 11 | .box-sizing(border-box); 12 | } 13 | 14 | 15 | // Body reset 16 | 17 | html { 18 | font-size: 62.5%; 19 | -webkit-tap-highlight-color: rgba(0,0,0,0); 20 | } 21 | 22 | body { 23 | font-family: @font-family-base; 24 | font-size: @font-size-base; 25 | line-height: @line-height-base; 26 | color: @text-color; 27 | background-color: @body-bg; 28 | } 29 | 30 | // Reset fonts for relevant elements 31 | input, 32 | button, 33 | select, 34 | textarea { 35 | font-family: inherit; 36 | font-size: inherit; 37 | line-height: inherit; 38 | } 39 | 40 | 41 | // Links 42 | 43 | a { 44 | color: @link-color; 45 | text-decoration: none; 46 | 47 | &:hover, 48 | &:focus { 49 | color: @link-hover-color; 50 | text-decoration: underline; 51 | } 52 | 53 | &:focus { 54 | .tab-focus(); 55 | } 56 | } 57 | 58 | 59 | // Images 60 | 61 | img { 62 | vertical-align: middle; 63 | } 64 | 65 | // Responsive images (ensure images don't scale beyond their parents) 66 | .img-responsive { 67 | .img-responsive(); 68 | } 69 | 70 | // Rounded corners 71 | .img-rounded { 72 | border-radius: @border-radius-large; 73 | } 74 | 75 | // Image thumbnails 76 | // 77 | // Heads up! This is mixin-ed into thumbnails.less for `.thumbnail`. 78 | .img-thumbnail { 79 | padding: @thumbnail-padding; 80 | line-height: @line-height-base; 81 | background-color: @thumbnail-bg; 82 | border: 1px solid @thumbnail-border; 83 | border-radius: @thumbnail-border-radius; 84 | .transition(all .2s ease-in-out); 85 | 86 | // Keep them at most 100% wide 87 | .img-responsive(inline-block); 88 | } 89 | 90 | // Perfect circle 91 | .img-circle { 92 | border-radius: 50%; // set radius in percents 93 | } 94 | 95 | 96 | // Horizontal rules 97 | 98 | hr { 99 | margin-top: @line-height-computed; 100 | margin-bottom: @line-height-computed; 101 | border: 0; 102 | border-top: 1px solid @hr-border; 103 | } 104 | 105 | 106 | // Only display content to screen readers 107 | // 108 | // See: http://a11yproject.com/posts/how-to-hide-content/ 109 | 110 | .sr-only { 111 | position: absolute; 112 | width: 1px; 113 | height: 1px; 114 | margin: -1px; 115 | padding: 0; 116 | overflow: hidden; 117 | clip: rect(0,0,0,0); 118 | border: 0; 119 | } 120 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/grid.less: -------------------------------------------------------------------------------- 1 | // 2 | // Grid system 3 | // -------------------------------------------------- 4 | 5 | // Set the container width, and override it for fixed navbars in media queries 6 | .container { 7 | .container-fixed(); 8 | } 9 | 10 | // mobile first defaults 11 | .row { 12 | .make-row(); 13 | } 14 | 15 | // Common styles for small and large grid columns 16 | .make-grid-columns(); 17 | 18 | 19 | // Extra small grid 20 | // 21 | // Grid classes for extra small devices like smartphones. No offset, push, or 22 | // pull classes are present here due to the size of the target. 23 | // 24 | // Note that `.col-xs-12` doesn't get floated on purpose--there's no need since 25 | // it's full-width. 26 | 27 | .make-grid-columns-float(xs); 28 | .make-grid(@grid-columns, xs, width); 29 | .make-grid(@grid-columns, xs, pull); 30 | .make-grid(@grid-columns, xs, push); 31 | .make-grid(@grid-columns, xs, offset); 32 | 33 | 34 | // Small grid 35 | // 36 | // Columns, offsets, pushes, and pulls for the small device range, from phones 37 | // to tablets. 38 | // 39 | // Note that `.col-sm-12` doesn't get floated on purpose--there's no need since 40 | // it's full-width. 41 | 42 | @media (min-width: @screen-sm-min) { 43 | .container { 44 | width: @container-sm; 45 | } 46 | 47 | .make-grid-columns-float(sm); 48 | .make-grid(@grid-columns, sm, width); 49 | .make-grid(@grid-columns, sm, pull); 50 | .make-grid(@grid-columns, sm, push); 51 | .make-grid(@grid-columns, sm, offset); 52 | } 53 | 54 | 55 | // Medium grid 56 | // 57 | // Columns, offsets, pushes, and pulls for the desktop device range. 58 | // 59 | // Note that `.col-md-12` doesn't get floated on purpose--there's no need since 60 | // it's full-width. 61 | 62 | @media (min-width: @screen-md-min) { 63 | .container { 64 | width: @container-md; 65 | } 66 | 67 | .make-grid-columns-float(md); 68 | .make-grid(@grid-columns, md, width); 69 | .make-grid(@grid-columns, md, pull); 70 | .make-grid(@grid-columns, md, push); 71 | .make-grid(@grid-columns, md, offset); 72 | } 73 | 74 | 75 | // Large grid 76 | // 77 | // Columns, offsets, pushes, and pulls for the large desktop device range. 78 | // 79 | // Note that `.col-lg-12` doesn't get floated on purpose--there's no need since 80 | // it's full-width. 81 | 82 | @media (min-width: @screen-lg-min) { 83 | .container { 84 | width: @container-lg; 85 | } 86 | 87 | .make-grid-columns-float(lg); 88 | .make-grid(@grid-columns, lg, width); 89 | .make-grid(@grid-columns, lg, pull); 90 | .make-grid(@grid-columns, lg, push); 91 | .make-grid(@grid-columns, lg, offset); 92 | } 93 | 94 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Exception/TApplicationException.php: -------------------------------------------------------------------------------- 1 | array('var' => 'message', 31 | 'type' => TType::STRING), 32 | 2 => array('var' => 'code', 33 | 'type' => TType::I32)); 34 | 35 | const UNKNOWN = 0; 36 | const UNKNOWN_METHOD = 1; 37 | const INVALID_MESSAGE_TYPE = 2; 38 | const WRONG_METHOD_NAME = 3; 39 | const BAD_SEQUENCE_ID = 4; 40 | const MISSING_RESULT = 5; 41 | const INTERNAL_ERROR = 6; 42 | const PROTOCOL_ERROR = 7; 43 | const INVALID_TRANSFORM = 8; 44 | const INVALID_PROTOCOL = 9; 45 | const UNSUPPORTED_CLIENT_TYPE = 10; 46 | 47 | function __construct($message=null, $code=0) { 48 | parent::__construct($message, $code); 49 | } 50 | 51 | public function read($output) { 52 | return $this->_read('TApplicationException', self::$_TSPEC, $output); 53 | } 54 | 55 | public function write($output) { 56 | $xfer = 0; 57 | $xfer += $output->writeStructBegin('TApplicationException'); 58 | if ($message = $this->getMessage()) { 59 | $xfer += $output->writeFieldBegin('message', TType::STRING, 1); 60 | $xfer += $output->writeString($message); 61 | $xfer += $output->writeFieldEnd(); 62 | } 63 | if ($code = $this->getCode()) { 64 | $xfer += $output->writeFieldBegin('type', TType::I32, 2); 65 | $xfer += $output->writeI32($code); 66 | $xfer += $output->writeFieldEnd(); 67 | } 68 | $xfer += $output->writeFieldStop(); 69 | $xfer += $output->writeStructEnd(); 70 | return $xfer; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Applications/Statistics/Views/setting.tpl.php: -------------------------------------------------------------------------------- 1 |
      2 |
      3 |
      4 | 32 |
      33 |
      34 |
      35 |
      36 | 44 | 45 |
      46 | 47 | 48 |
      49 | 50 |
      51 | 52 | 53 |
      54 | 55 |
      56 | 57 | 58 |
      59 | 60 |
      61 |
      62 |
      63 |
      64 |
      65 |
      66 |
      67 |
      68 | 69 |
      70 | 71 |
      72 |
      73 |
      74 |
      75 | 76 |
      77 |
      78 |
      79 |
      80 |
      81 |
      82 |
      83 |
      84 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Transport/TTransport.php: -------------------------------------------------------------------------------- 1 | read($len); 70 | 71 | $data = ''; 72 | $got = 0; 73 | while (($got = TStringFuncFactory::create()->strlen($data)) < $len) { 74 | $data .= $this->read($len - $got); 75 | } 76 | return $data; 77 | } 78 | 79 | /** 80 | * Writes the given data out. 81 | * 82 | * @param string $buf The data to write 83 | * @throws TTransportException if writing fails 84 | */ 85 | public abstract function write($buf); 86 | 87 | /** 88 | * Flushes any pending data out of a buffer 89 | * 90 | * @throws TTransportException if a writing error occurs 91 | */ 92 | public function flush() {} 93 | } 94 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Transport/TMemoryBuffer.php: -------------------------------------------------------------------------------- 1 | buf_ = $buf; 45 | } 46 | 47 | protected $buf_ = ''; 48 | 49 | public function isOpen() { 50 | return true; 51 | } 52 | 53 | public function open() {} 54 | 55 | public function close() {} 56 | 57 | public function write($buf) { 58 | $this->buf_ .= $buf; 59 | } 60 | 61 | public function read($len) { 62 | $bufLength = TStringFuncFactory::create()->strlen($this->buf_); 63 | 64 | if ($bufLength === 0) { 65 | throw new TTransportException('TMemoryBuffer: Could not read ' . 66 | $len . ' bytes from buffer.', 67 | TTransportException::UNKNOWN); 68 | } 69 | 70 | if ($bufLength <= $len) { 71 | $ret = $this->buf_; 72 | $this->buf_ = ''; 73 | return $ret; 74 | } 75 | 76 | $ret = TStringFuncFactory::create()->substr($this->buf_, 0, $len); 77 | $this->buf_ = TStringFuncFactory::create()->substr($this->buf_, $len); 78 | 79 | return $ret; 80 | } 81 | 82 | function getBuffer() { 83 | return $this->buf_; 84 | } 85 | 86 | public function available() { 87 | return TStringFuncFactory::create()->strlen($this->buf_); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Server/TServer.php: -------------------------------------------------------------------------------- 1 | processor_ = $processor; 77 | $this->transport_ = $transport; 78 | $this->inputTransportFactory_ = $inputTransportFactory; 79 | $this->outputTransportFactory_ = $outputTransportFactory; 80 | $this->inputProtocolFactory_ = $inputProtocolFactory; 81 | $this->outputProtocolFactory_ = $outputProtocolFactory; 82 | } 83 | 84 | /** 85 | * Serves the server. This should never return 86 | * unless a problem permits it to do so or it 87 | * is interrupted intentionally 88 | * 89 | * @abstract 90 | * @return void 91 | */ 92 | abstract public function serve(); 93 | 94 | /** 95 | * Stops the server serving 96 | * 97 | * @abstract 98 | * @return void 99 | */ 100 | abstract public function stop(); 101 | } 102 | -------------------------------------------------------------------------------- /Applications/Statistics/Views/login.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WorkerMan-集群统计与监控 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
      38 |
      39 |
      40 |
      41 |
      42 | 43 |
      44 | 45 |

      46 | 47 |

      48 |
      49 | 50 |

      workerman管理员登录

      51 |
      52 |
      53 | 54 |
      55 |
      56 | 57 |
      58 | 59 |
      60 |
      61 |
      62 |
      63 |
      64 |
      65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/tooltip.less: -------------------------------------------------------------------------------- 1 | // 2 | // Tooltips 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .tooltip { 8 | position: absolute; 9 | z-index: @zindex-tooltip; 10 | display: block; 11 | visibility: visible; 12 | font-size: @font-size-small; 13 | line-height: 1.4; 14 | .opacity(0); 15 | 16 | &.in { .opacity(.9); } 17 | &.top { margin-top: -3px; padding: @tooltip-arrow-width 0; } 18 | &.right { margin-left: 3px; padding: 0 @tooltip-arrow-width; } 19 | &.bottom { margin-top: 3px; padding: @tooltip-arrow-width 0; } 20 | &.left { margin-left: -3px; padding: 0 @tooltip-arrow-width; } 21 | } 22 | 23 | // Wrapper for the tooltip content 24 | .tooltip-inner { 25 | max-width: @tooltip-max-width; 26 | padding: 3px 8px; 27 | color: @tooltip-color; 28 | text-align: center; 29 | text-decoration: none; 30 | background-color: @tooltip-bg; 31 | border-radius: @border-radius-base; 32 | } 33 | 34 | // Arrows 35 | .tooltip-arrow { 36 | position: absolute; 37 | width: 0; 38 | height: 0; 39 | border-color: transparent; 40 | border-style: solid; 41 | } 42 | .tooltip { 43 | &.top .tooltip-arrow { 44 | bottom: 0; 45 | left: 50%; 46 | margin-left: -@tooltip-arrow-width; 47 | border-width: @tooltip-arrow-width @tooltip-arrow-width 0; 48 | border-top-color: @tooltip-arrow-color; 49 | } 50 | &.top-left .tooltip-arrow { 51 | bottom: 0; 52 | left: @tooltip-arrow-width; 53 | border-width: @tooltip-arrow-width @tooltip-arrow-width 0; 54 | border-top-color: @tooltip-arrow-color; 55 | } 56 | &.top-right .tooltip-arrow { 57 | bottom: 0; 58 | right: @tooltip-arrow-width; 59 | border-width: @tooltip-arrow-width @tooltip-arrow-width 0; 60 | border-top-color: @tooltip-arrow-color; 61 | } 62 | &.right .tooltip-arrow { 63 | top: 50%; 64 | left: 0; 65 | margin-top: -@tooltip-arrow-width; 66 | border-width: @tooltip-arrow-width @tooltip-arrow-width @tooltip-arrow-width 0; 67 | border-right-color: @tooltip-arrow-color; 68 | } 69 | &.left .tooltip-arrow { 70 | top: 50%; 71 | right: 0; 72 | margin-top: -@tooltip-arrow-width; 73 | border-width: @tooltip-arrow-width 0 @tooltip-arrow-width @tooltip-arrow-width; 74 | border-left-color: @tooltip-arrow-color; 75 | } 76 | &.bottom .tooltip-arrow { 77 | top: 0; 78 | left: 50%; 79 | margin-left: -@tooltip-arrow-width; 80 | border-width: 0 @tooltip-arrow-width @tooltip-arrow-width; 81 | border-bottom-color: @tooltip-arrow-color; 82 | } 83 | &.bottom-left .tooltip-arrow { 84 | top: 0; 85 | left: @tooltip-arrow-width; 86 | border-width: 0 @tooltip-arrow-width @tooltip-arrow-width; 87 | border-bottom-color: @tooltip-arrow-color; 88 | } 89 | &.bottom-right .tooltip-arrow { 90 | top: 0; 91 | right: @tooltip-arrow-width; 92 | border-width: 0 @tooltip-arrow-width @tooltip-arrow-width; 93 | border-bottom-color: @tooltip-arrow-color; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Serializer/TBinarySerializer.php: -------------------------------------------------------------------------------- 1 | getName(), 46 | TMessageType::REPLY, $object, 47 | 0, $protocol->isStrictWrite()); 48 | 49 | $protocol->readMessageBegin($unused_name, $unused_type, 50 | $unused_seqid); 51 | } else { 52 | $object->write($protocol); 53 | } 54 | $protocol->getTransport()->flush(); 55 | return $transport->getBuffer(); 56 | } 57 | 58 | public static function deserialize($string_object, $class_name) { 59 | $transport = new TMemoryBuffer(); 60 | $protocol = new TBinaryProtocolAccelerated($transport); 61 | if (function_exists('thrift_protocol_read_binary')) { 62 | $protocol->writeMessageBegin('', TMessageType::REPLY, 0); 63 | $transport->write($string_object); 64 | return thrift_protocol_read_binary($protocol, $class_name, 65 | $protocol->isStrictRead()); 66 | } else { 67 | $transport->write($string_object); 68 | $object = new $class_name(); 69 | $object->read($protocol); 70 | return $object; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Applications/Statistics/Views/admin.tpl.php: -------------------------------------------------------------------------------- 1 |
      2 |
      3 |
      4 | 32 |
      33 |
      34 |
      35 |
      36 | 44 | 45 |
      46 | 47 | 48 |
      49 | 50 |
      51 | 52 | 53 |
      54 | 55 |
      56 | 57 | 58 |
      59 | 60 |
      61 |
      62 |
      63 |
      64 |
      65 |
      66 | 67 |
      68 |
      69 | 70 |
      71 |
      72 |
      73 | 74 |
      75 |
      76 |
      77 | 78 | 返回主页 继续添加 79 | 80 |
      81 |
      82 |
      83 |
      84 |
      85 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Server/TForkingServer.php: -------------------------------------------------------------------------------- 1 | transport_->listen(); 39 | 40 | while (!$this->stop_) { 41 | try { 42 | $transport = $this->transport_->accept(); 43 | 44 | if ($transport != null) { 45 | $pid = pcntl_fork(); 46 | 47 | if ($pid > 0) { 48 | $this->handleParent($transport, $pid); 49 | } 50 | else if ($pid === 0) { 51 | $this->handleChild($transport); 52 | } 53 | else { 54 | throw new TException('Failed to fork'); 55 | } 56 | } 57 | } 58 | catch (TTransportException $e) { } 59 | 60 | $this->collectChildren(); 61 | } 62 | } 63 | 64 | /** 65 | * Code run by the parent 66 | * 67 | * @param TTransport $transport 68 | * @param int $pid 69 | * @return void 70 | */ 71 | private function handleParent(TTransport $transport, $pid) { 72 | $this->children_[$pid] = $transport; 73 | } 74 | 75 | /** 76 | * Code run by the child. 77 | * 78 | * @param TTransport $transport 79 | * @return void 80 | */ 81 | private function handleChild(TTransport $transport) { 82 | try { 83 | $inputTransport = $this->inputTransportFactory_->getTransport($transport); 84 | $outputTransport = $this->outputTransportFactory_->getTransport($transport); 85 | $inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport); 86 | $outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport); 87 | while ($this->processor_->process($inputProtocol, $outputProtocol)) { } 88 | @$transport->close(); 89 | } 90 | catch (TTransportException $e) { } 91 | 92 | exit(0); 93 | } 94 | 95 | /** 96 | * Collects any children we may have 97 | * 98 | * @return void 99 | */ 100 | private function collectChildren() { 101 | foreach ($this->children_ as $pid => $transport) { 102 | if (pcntl_waitpid($pid, $status, WNOHANG) > 0) { 103 | unset($this->children_[$pid]); 104 | if ($transport) @$transport->close(); 105 | } 106 | } 107 | } 108 | 109 | /** 110 | * Stops the server running. Kills the transport 111 | * and then stops the main serving loop 112 | * 113 | * @return void 114 | */ 115 | public function stop() { 116 | $this->transport_->close(); 117 | $this->stop_ = true; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Applications/Statistics/Modules/logger.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Statistics\Modules; 15 | function logger($module, $interface, $date, $start_time, $offset, $count) 16 | { 17 | $module_str =''; 18 | foreach(\Statistics\Lib\Cache::$modulesDataCache as $mod => $interfaces) 19 | { 20 | if($mod == 'WorkerMan') 21 | { 22 | continue; 23 | } 24 | $module_str .= '
    1. '.$mod.'
    2. '; 25 | if($module == $mod) 26 | { 27 | foreach ($interfaces as $if) 28 | { 29 | $module_str .= '
    3.   '.$if.'
    4. '; 30 | } 31 | } 32 | } 33 | 34 | $log_data_arr = getStasticLog($module, $interface, $start_time ,$offset, $count); 35 | unset($_GET['fn'], $_GET['ip'], $_GET['offset']); 36 | $log_str = ''; 37 | foreach($log_data_arr as $address => $log_data) 38 | { 39 | list($ip, $port) = explode(':', $address); 40 | $log_str .= $log_data['data']; 41 | $_GET['ip'][] = $ip; 42 | $_GET['offset'][] = $log_data['offset']; 43 | } 44 | $log_str = nl2br(str_replace("\n", "\n\n", $log_str)); 45 | $next_page_url = http_build_query($_GET); 46 | $log_str .= "
      下一页
      "; 47 | 48 | include ST_ROOT . '/Views/header.tpl.php'; 49 | include ST_ROOT . '/Views/log.tpl.php'; 50 | include ST_ROOT . '/Views/footer.tpl.php'; 51 | } 52 | 53 | function getStasticLog($module, $interface , $start_time, $offset = '', $count = 10) 54 | { 55 | $ip_list = (!empty($_GET['ip']) && is_array($_GET['ip'])) ? $_GET['ip'] : \Statistics\Lib\Cache::$ServerIpList; 56 | $offset_list = (!empty($_GET['offset']) && is_array($_GET['offset'])) ? $_GET['offset'] : array(); 57 | $port = \Statistics\Config::$ProviderPort; 58 | $request_buffer_array = array(); 59 | foreach($ip_list as $key=>$ip) 60 | { 61 | $offset = isset($offset_list[$key]) ? $offset_list[$key] : 0; 62 | $request_buffer_array["$ip:$port"] = json_encode(array('cmd'=>'get_log', 'module'=>$module, 'interface'=>$interface, 'start_time'=>$start_time, 'offset'=>$offset, 'count'=>$count))."\n"; 63 | } 64 | 65 | $read_buffer_array = multiRequest($request_buffer_array); 66 | ksort($read_buffer_array); 67 | foreach($read_buffer_array as $address => $buf) 68 | { 69 | list($ip, $port) = explode(':', $address); 70 | $body_data = json_decode(trim($buf), true); 71 | $log_data = isset($body_data['data']) ? $body_data['data'] : ''; 72 | $offset = isset($body_data['offset']) ? $body_data['offset'] : 0; 73 | $read_buffer_array[$address] = array('offset'=>$offset,'data'=>$log_data); 74 | } 75 | return $read_buffer_array; 76 | } 77 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Transport/TPhpStream.php: -------------------------------------------------------------------------------- 1 | read_ = $mode & self::MODE_R; 50 | $this->write_ = $mode & self::MODE_W; 51 | } 52 | 53 | public function open() { 54 | if ($this->read_) { 55 | $this->inStream_ = @fopen(self::inStreamName(), 'r'); 56 | if (!is_resource($this->inStream_)) { 57 | throw new TException('TPhpStream: Could not open php://input'); 58 | } 59 | } 60 | if ($this->write_) { 61 | $this->outStream_ = @fopen('php://output', 'w'); 62 | if (!is_resource($this->outStream_)) { 63 | throw new TException('TPhpStream: Could not open php://output'); 64 | } 65 | } 66 | } 67 | 68 | public function close() { 69 | if ($this->read_) { 70 | @fclose($this->inStream_); 71 | $this->inStream_ = null; 72 | } 73 | if ($this->write_) { 74 | @fclose($this->outStream_); 75 | $this->outStream_ = null; 76 | } 77 | } 78 | 79 | public function isOpen() { 80 | return 81 | (!$this->read_ || is_resource($this->inStream_)) && 82 | (!$this->write_ || is_resource($this->outStream_)); 83 | } 84 | 85 | public function read($len) { 86 | $data = @fread($this->inStream_, $len); 87 | if ($data === FALSE || $data === '') { 88 | throw new TException('TPhpStream: Could not read '.$len.' bytes'); 89 | } 90 | return $data; 91 | } 92 | 93 | public function write($buf) { 94 | while (TStringFuncFactory::create()->strlen($buf) > 0) { 95 | $got = @fwrite($this->outStream_, $buf); 96 | if ($got === 0 || $got === FALSE) { 97 | throw new TException('TPhpStream: Could not write '.TStringFuncFactory::create()->strlen($buf).' bytes'); 98 | } 99 | $buf = TStringFuncFactory::create()->substr($buf, $got); 100 | } 101 | } 102 | 103 | public function flush() { 104 | @fflush($this->outStream_); 105 | } 106 | 107 | private static function inStreamName() { 108 | if (php_sapi_name() == 'cli') { 109 | return 'php://stdin'; 110 | } 111 | return 'php://input'; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/modals.less: -------------------------------------------------------------------------------- 1 | // 2 | // Modals 3 | // -------------------------------------------------- 4 | 5 | // .modal-open - body class for killing the scroll 6 | // .modal - container to scroll within 7 | // .modal-dialog - positioning shell for the actual modal 8 | // .modal-content - actual modal w/ bg and corners and shit 9 | 10 | // Kill the scroll on the body 11 | .modal-open { 12 | overflow: hidden; 13 | } 14 | 15 | // Container that the modal scrolls within 16 | .modal { 17 | display: none; 18 | overflow: auto; 19 | overflow-y: scroll; 20 | position: fixed; 21 | top: 0; 22 | right: 0; 23 | bottom: 0; 24 | left: 0; 25 | z-index: @zindex-modal-background; 26 | 27 | // When fading in the modal, animate it to slide down 28 | &.fade .modal-dialog { 29 | .translate(0, -25%); 30 | .transition-transform(~"0.3s ease-out"); 31 | } 32 | &.in .modal-dialog { .translate(0, 0)} 33 | } 34 | 35 | // Shell div to position the modal with bottom padding 36 | .modal-dialog { 37 | position: relative; 38 | margin-left: auto; 39 | margin-right: auto; 40 | width: auto; 41 | padding: 10px; 42 | z-index: (@zindex-modal-background + 10); 43 | } 44 | 45 | // Actual modal 46 | .modal-content { 47 | position: relative; 48 | background-color: @modal-content-bg; 49 | border: 1px solid @modal-content-fallback-border-color; //old browsers fallback (ie8 etc) 50 | border: 1px solid @modal-content-border-color; 51 | border-radius: @border-radius-large; 52 | .box-shadow(0 3px 9px rgba(0,0,0,.5)); 53 | background-clip: padding-box; 54 | // Remove focus outline from opened modal 55 | outline: none; 56 | } 57 | 58 | // Modal background 59 | .modal-backdrop { 60 | position: fixed; 61 | top: 0; 62 | right: 0; 63 | bottom: 0; 64 | left: 0; 65 | z-index: (@zindex-modal-background - 10); 66 | background-color: @modal-backdrop-bg; 67 | // Fade for backdrop 68 | &.fade { .opacity(0); } 69 | &.in { .opacity(.5); } 70 | } 71 | 72 | // Modal header 73 | // Top section of the modal w/ title and dismiss 74 | .modal-header { 75 | padding: @modal-title-padding; 76 | border-bottom: 1px solid @modal-header-border-color; 77 | min-height: (@modal-title-padding + @modal-title-line-height); 78 | } 79 | // Close icon 80 | .modal-header .close { 81 | margin-top: -2px; 82 | } 83 | 84 | // Title text within header 85 | .modal-title { 86 | margin: 0; 87 | line-height: @modal-title-line-height; 88 | } 89 | 90 | // Modal body 91 | // Where all modal content resides (sibling of .modal-header and .modal-footer) 92 | .modal-body { 93 | position: relative; 94 | padding: @modal-inner-padding; 95 | } 96 | 97 | // Footer (for actions) 98 | .modal-footer { 99 | margin-top: 15px; 100 | padding: (@modal-inner-padding - 1) @modal-inner-padding @modal-inner-padding; 101 | text-align: right; // right align buttons 102 | border-top: 1px solid @modal-footer-border-color; 103 | .clearfix(); // clear it in case folks use .pull-* classes on buttons 104 | 105 | // Properly space out buttons 106 | .btn + .btn { 107 | margin-left: 5px; 108 | margin-bottom: 0; // account for input[type="submit"] which gets the bottom margin like all other inputs 109 | } 110 | // but override that for button groups 111 | .btn-group .btn + .btn { 112 | margin-left: -1px; 113 | } 114 | // and override it for block buttons as well 115 | .btn-block + .btn-block { 116 | margin-left: 0; 117 | } 118 | } 119 | 120 | // Scale up the modal 121 | @media screen and (min-width: @screen-sm-min) { 122 | 123 | .modal-dialog { 124 | width: 600px; 125 | padding-top: 30px; 126 | padding-bottom: 30px; 127 | } 128 | .modal-content { 129 | .box-shadow(0 5px 15px rgba(0,0,0,.5)); 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/popovers.less: -------------------------------------------------------------------------------- 1 | // 2 | // Popovers 3 | // -------------------------------------------------- 4 | 5 | 6 | .popover { 7 | position: absolute; 8 | top: 0; 9 | left: 0; 10 | z-index: @zindex-popover; 11 | display: none; 12 | max-width: @popover-max-width; 13 | padding: 1px; 14 | text-align: left; // Reset given new insertion method 15 | background-color: @popover-bg; 16 | background-clip: padding-box; 17 | border: 1px solid @popover-fallback-border-color; 18 | border: 1px solid @popover-border-color; 19 | border-radius: @border-radius-large; 20 | .box-shadow(0 5px 10px rgba(0,0,0,.2)); 21 | 22 | // Overrides for proper insertion 23 | white-space: normal; 24 | 25 | // Offset the popover to account for the popover arrow 26 | &.top { margin-top: -10px; } 27 | &.right { margin-left: 10px; } 28 | &.bottom { margin-top: 10px; } 29 | &.left { margin-left: -10px; } 30 | } 31 | 32 | .popover-title { 33 | margin: 0; // reset heading margin 34 | padding: 8px 14px; 35 | font-size: @font-size-base; 36 | font-weight: normal; 37 | line-height: 18px; 38 | background-color: @popover-title-bg; 39 | border-bottom: 1px solid darken(@popover-title-bg, 5%); 40 | border-radius: 5px 5px 0 0; 41 | } 42 | 43 | .popover-content { 44 | padding: 9px 14px; 45 | } 46 | 47 | // Arrows 48 | // 49 | // .arrow is outer, .arrow:after is inner 50 | 51 | .popover .arrow { 52 | &, 53 | &:after { 54 | position: absolute; 55 | display: block; 56 | width: 0; 57 | height: 0; 58 | border-color: transparent; 59 | border-style: solid; 60 | } 61 | } 62 | .popover .arrow { 63 | border-width: @popover-arrow-outer-width; 64 | } 65 | .popover .arrow:after { 66 | border-width: @popover-arrow-width; 67 | content: ""; 68 | } 69 | 70 | .popover { 71 | &.top .arrow { 72 | left: 50%; 73 | margin-left: -@popover-arrow-outer-width; 74 | border-bottom-width: 0; 75 | border-top-color: @popover-arrow-outer-fallback-color; // IE8 fallback 76 | border-top-color: @popover-arrow-outer-color; 77 | bottom: -@popover-arrow-outer-width; 78 | &:after { 79 | content: " "; 80 | bottom: 1px; 81 | margin-left: -@popover-arrow-width; 82 | border-bottom-width: 0; 83 | border-top-color: @popover-arrow-color; 84 | } 85 | } 86 | &.right .arrow { 87 | top: 50%; 88 | left: -@popover-arrow-outer-width; 89 | margin-top: -@popover-arrow-outer-width; 90 | border-left-width: 0; 91 | border-right-color: @popover-arrow-outer-fallback-color; // IE8 fallback 92 | border-right-color: @popover-arrow-outer-color; 93 | &:after { 94 | content: " "; 95 | left: 1px; 96 | bottom: -@popover-arrow-width; 97 | border-left-width: 0; 98 | border-right-color: @popover-arrow-color; 99 | } 100 | } 101 | &.bottom .arrow { 102 | left: 50%; 103 | margin-left: -@popover-arrow-outer-width; 104 | border-top-width: 0; 105 | border-bottom-color: @popover-arrow-outer-fallback-color; // IE8 fallback 106 | border-bottom-color: @popover-arrow-outer-color; 107 | top: -@popover-arrow-outer-width; 108 | &:after { 109 | content: " "; 110 | top: 1px; 111 | margin-left: -@popover-arrow-width; 112 | border-top-width: 0; 113 | border-bottom-color: @popover-arrow-color; 114 | } 115 | } 116 | 117 | &.left .arrow { 118 | top: 50%; 119 | right: -@popover-arrow-outer-width; 120 | margin-top: -@popover-arrow-outer-width; 121 | border-right-width: 0; 122 | border-left-color: @popover-arrow-outer-fallback-color; // IE8 fallback 123 | border-left-color: @popover-arrow-outer-color; 124 | &:after { 125 | content: " "; 126 | right: 1px; 127 | border-right-width: 0; 128 | border-left-color: @popover-arrow-color; 129 | bottom: -@popover-arrow-width; 130 | } 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/input-groups.less: -------------------------------------------------------------------------------- 1 | // 2 | // Input groups 3 | // -------------------------------------------------- 4 | 5 | // Base styles 6 | // ------------------------- 7 | .input-group { 8 | position: relative; // For dropdowns 9 | display: table; 10 | border-collapse: separate; // prevent input groups from inheriting border styles from table cells when placed within a table 11 | 12 | // Undo padding and float of grid classes 13 | &.col { 14 | float: none; 15 | padding-left: 0; 16 | padding-right: 0; 17 | } 18 | 19 | .form-control { 20 | width: 100%; 21 | margin-bottom: 0; 22 | } 23 | } 24 | 25 | // Sizing options 26 | // 27 | // Remix the default form control sizing classes into new ones for easier 28 | // manipulation. 29 | 30 | .input-group-lg > .form-control, 31 | .input-group-lg > .input-group-addon, 32 | .input-group-lg > .input-group-btn > .btn { .input-lg(); } 33 | .input-group-sm > .form-control, 34 | .input-group-sm > .input-group-addon, 35 | .input-group-sm > .input-group-btn > .btn { .input-sm(); } 36 | 37 | 38 | // Display as table-cell 39 | // ------------------------- 40 | .input-group-addon, 41 | .input-group-btn, 42 | .input-group .form-control { 43 | display: table-cell; 44 | 45 | &:not(:first-child):not(:last-child) { 46 | border-radius: 0; 47 | } 48 | } 49 | // Addon and addon wrapper for buttons 50 | .input-group-addon, 51 | .input-group-btn { 52 | width: 1%; 53 | white-space: nowrap; 54 | vertical-align: middle; // Match the inputs 55 | } 56 | 57 | // Text input groups 58 | // ------------------------- 59 | .input-group-addon { 60 | padding: @padding-base-vertical @padding-base-horizontal; 61 | font-size: @font-size-base; 62 | font-weight: normal; 63 | line-height: 1; 64 | color: @input-color; 65 | text-align: center; 66 | background-color: @input-group-addon-bg; 67 | border: 1px solid @input-group-addon-border-color; 68 | border-radius: @border-radius-base; 69 | 70 | // Sizing 71 | &.input-sm { 72 | padding: @padding-small-vertical @padding-small-horizontal; 73 | font-size: @font-size-small; 74 | border-radius: @border-radius-small; 75 | } 76 | &.input-lg { 77 | padding: @padding-large-vertical @padding-large-horizontal; 78 | font-size: @font-size-large; 79 | border-radius: @border-radius-large; 80 | } 81 | 82 | // Nuke default margins from checkboxes and radios to vertically center within. 83 | input[type="radio"], 84 | input[type="checkbox"] { 85 | margin-top: 0; 86 | } 87 | } 88 | 89 | // Reset rounded corners 90 | .input-group .form-control:first-child, 91 | .input-group-addon:first-child, 92 | .input-group-btn:first-child > .btn, 93 | .input-group-btn:first-child > .dropdown-toggle, 94 | .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle) { 95 | .border-right-radius(0); 96 | } 97 | .input-group-addon:first-child { 98 | border-right: 0; 99 | } 100 | .input-group .form-control:last-child, 101 | .input-group-addon:last-child, 102 | .input-group-btn:last-child > .btn, 103 | .input-group-btn:last-child > .dropdown-toggle, 104 | .input-group-btn:first-child > .btn:not(:first-child) { 105 | .border-left-radius(0); 106 | } 107 | .input-group-addon:last-child { 108 | border-left: 0; 109 | } 110 | 111 | // Button input groups 112 | // ------------------------- 113 | .input-group-btn { 114 | position: relative; 115 | white-space: nowrap; 116 | 117 | // Negative margin to only have a 1px border between the two 118 | &:first-child > .btn { 119 | margin-right: -1px; 120 | } 121 | &:last-child > .btn { 122 | margin-left: -1px; 123 | } 124 | } 125 | .input-group-btn > .btn { 126 | position: relative; 127 | // Jankily prevent input button groups from wrapping 128 | + .btn { 129 | margin-left: -4px; 130 | } 131 | // Bring the "active" button to the front 132 | &:hover, 133 | &:active { 134 | z-index: 2; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/buttons.less: -------------------------------------------------------------------------------- 1 | // 2 | // Buttons 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base styles 7 | // -------------------------------------------------- 8 | 9 | // Core styles 10 | .btn { 11 | display: inline-block; 12 | margin-bottom: 0; // For input.btn 13 | font-weight: @btn-font-weight; 14 | text-align: center; 15 | vertical-align: middle; 16 | cursor: pointer; 17 | background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214 18 | border: 1px solid transparent; 19 | white-space: nowrap; 20 | .button-size(@padding-base-vertical; @padding-base-horizontal; @font-size-base; @line-height-base; @border-radius-base); 21 | .user-select(none); 22 | 23 | &:focus { 24 | .tab-focus(); 25 | } 26 | 27 | &:hover, 28 | &:focus { 29 | color: @btn-default-color; 30 | text-decoration: none; 31 | } 32 | 33 | &:active, 34 | &.active { 35 | outline: 0; 36 | background-image: none; 37 | .box-shadow(inset 0 3px 5px rgba(0,0,0,.125)); 38 | } 39 | 40 | &.disabled, 41 | &[disabled], 42 | fieldset[disabled] & { 43 | cursor: not-allowed; 44 | pointer-events: none; // Future-proof disabling of clicks 45 | .opacity(.65); 46 | .box-shadow(none); 47 | } 48 | 49 | } 50 | 51 | 52 | // Alternate buttons 53 | // -------------------------------------------------- 54 | 55 | .btn-default { 56 | .button-variant(@btn-default-color; @btn-default-bg; @btn-default-border); 57 | } 58 | .btn-primary { 59 | .button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border); 60 | } 61 | // Warning appears as orange 62 | .btn-warning { 63 | .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border); 64 | } 65 | // Danger and error appear as red 66 | .btn-danger { 67 | .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border); 68 | } 69 | // Success appears as green 70 | .btn-success { 71 | .button-variant(@btn-success-color; @btn-success-bg; @btn-success-border); 72 | } 73 | // Info appears as blue-green 74 | .btn-info { 75 | .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border); 76 | } 77 | 78 | 79 | // Link buttons 80 | // ------------------------- 81 | 82 | // Make a button look and behave like a link 83 | .btn-link { 84 | color: @link-color; 85 | font-weight: normal; 86 | cursor: pointer; 87 | border-radius: 0; 88 | 89 | &, 90 | &:active, 91 | &[disabled], 92 | fieldset[disabled] & { 93 | background-color: transparent; 94 | .box-shadow(none); 95 | } 96 | &, 97 | &:hover, 98 | &:focus, 99 | &:active { 100 | border-color: transparent; 101 | } 102 | &:hover, 103 | &:focus { 104 | color: @link-hover-color; 105 | text-decoration: underline; 106 | background-color: transparent; 107 | } 108 | &[disabled], 109 | fieldset[disabled] & { 110 | &:hover, 111 | &:focus { 112 | color: @btn-link-disabled-color; 113 | text-decoration: none; 114 | } 115 | } 116 | } 117 | 118 | 119 | // Button Sizes 120 | // -------------------------------------------------- 121 | 122 | .btn-lg { 123 | // line-height: ensure even-numbered height of button next to large input 124 | .button-size(@padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large); 125 | } 126 | .btn-sm, 127 | .btn-xs { 128 | // line-height: ensure proper height of button next to small input 129 | .button-size(@padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small); 130 | } 131 | .btn-xs { 132 | padding: 1px 5px; 133 | } 134 | 135 | 136 | // Block button 137 | // -------------------------------------------------- 138 | 139 | .btn-block { 140 | display: block; 141 | width: 100%; 142 | padding-left: 0; 143 | padding-right: 0; 144 | } 145 | 146 | // Vertically space out multiple block buttons 147 | .btn-block + .btn-block { 148 | margin-top: 5px; 149 | } 150 | 151 | // Specificity overrides 152 | input[type="submit"], 153 | input[type="reset"], 154 | input[type="button"] { 155 | &.btn-block { 156 | width: 100%; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/panels.less: -------------------------------------------------------------------------------- 1 | // 2 | // Panels 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .panel { 8 | margin-bottom: @line-height-computed; 9 | background-color: @panel-bg; 10 | border: 1px solid transparent; 11 | border-radius: @panel-border-radius; 12 | .box-shadow(0 1px 1px rgba(0,0,0,.05)); 13 | } 14 | 15 | // Panel contents 16 | .panel-body { 17 | padding: 15px; 18 | .clearfix(); 19 | } 20 | 21 | 22 | // List groups in panels 23 | // 24 | // By default, space out list group content from panel headings to account for 25 | // any kind of custom content between the two. 26 | 27 | .panel { 28 | > .list-group { 29 | margin-bottom: 0; 30 | 31 | .list-group-item { 32 | border-width: 1px 0; 33 | 34 | // Remove border radius for top one 35 | &:first-child { 36 | .border-top-radius(0); 37 | } 38 | // But keep it for the last one 39 | &:last-child { 40 | border-bottom: 0; 41 | } 42 | } 43 | } 44 | } 45 | // Collapse space between when there's no additional content. 46 | .panel-heading + .list-group { 47 | .list-group-item:first-child { 48 | border-top-width: 0; 49 | } 50 | } 51 | 52 | 53 | // Tables in panels 54 | // 55 | // Place a non-bordered `.table` within a panel (not within a `.panel-body`) and 56 | // watch it go full width. 57 | 58 | .panel { 59 | > .table, 60 | > .table-responsive { 61 | margin-bottom: 0; 62 | } 63 | > .panel-body + .table, 64 | > .panel-body + .table-responsive { 65 | border-top: 1px solid @table-border-color; 66 | } 67 | > .table-bordered, 68 | > .table-responsive > .table-bordered { 69 | border: 0; 70 | > thead, 71 | > tbody, 72 | > tfoot { 73 | > tr { 74 | > th:first-child, 75 | > td:first-child { 76 | border-left: 0; 77 | } 78 | > th:last-child, 79 | > td:last-child { 80 | border-right: 0; 81 | } 82 | 83 | &:last-child > th, 84 | &:last-child > td { 85 | border-bottom: 0; 86 | } 87 | } 88 | } 89 | } 90 | } 91 | 92 | 93 | // Optional heading 94 | .panel-heading { 95 | padding: 10px 15px; 96 | border-bottom: 1px solid transparent; 97 | .border-top-radius(@panel-border-radius - 1); 98 | 99 | & > .dropdown .dropdown-toggle { 100 | color: inherit; 101 | } 102 | } 103 | 104 | // Within heading, strip any `h*` tag of it's default margins for spacing. 105 | .panel-title { 106 | margin-top: 0; 107 | margin-bottom: 0; 108 | font-size: ceil((@font-size-base * 1.125)); 109 | > a { 110 | color: inherit; 111 | } 112 | } 113 | 114 | // Optional footer (stays gray in every modifier class) 115 | .panel-footer { 116 | padding: 10px 15px; 117 | background-color: @panel-footer-bg; 118 | border-top: 1px solid @panel-inner-border; 119 | .border-bottom-radius(@panel-border-radius - 1); 120 | } 121 | 122 | 123 | // Collapsable panels (aka, accordion) 124 | // 125 | // Wrap a series of panels in `.panel-group` to turn them into an accordion with 126 | // the help of our collapse JavaScript plugin. 127 | 128 | .panel-group { 129 | // Tighten up margin so it's only between panels 130 | .panel { 131 | margin-bottom: 0; 132 | border-radius: @panel-border-radius; 133 | overflow: hidden; // crop contents when collapsed 134 | + .panel { 135 | margin-top: 5px; 136 | } 137 | } 138 | 139 | .panel-heading { 140 | border-bottom: 0; 141 | + .panel-collapse .panel-body { 142 | border-top: 1px solid @panel-inner-border; 143 | } 144 | } 145 | .panel-footer { 146 | border-top: 0; 147 | + .panel-collapse .panel-body { 148 | border-bottom: 1px solid @panel-inner-border; 149 | } 150 | } 151 | } 152 | 153 | 154 | // Contextual variations 155 | .panel-default { 156 | .panel-variant(@panel-default-border; @panel-default-text; @panel-default-heading-bg; @panel-default-border); 157 | } 158 | .panel-primary { 159 | .panel-variant(@panel-primary-border; @panel-primary-text; @panel-primary-heading-bg; @panel-primary-border); 160 | } 161 | .panel-success { 162 | .panel-variant(@panel-success-border; @panel-success-text; @panel-success-heading-bg; @panel-success-border); 163 | } 164 | .panel-warning { 165 | .panel-variant(@panel-warning-border; @panel-warning-text; @panel-warning-heading-bg; @panel-warning-border); 166 | } 167 | .panel-danger { 168 | .panel-variant(@panel-danger-border; @panel-danger-text; @panel-danger-heading-bg; @panel-danger-border); 169 | } 170 | .panel-info { 171 | .panel-variant(@panel-info-border; @panel-info-text; @panel-info-heading-bg; @panel-info-border); 172 | } 173 | -------------------------------------------------------------------------------- /Applications/Statistics/Protocols/Statistic.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Protocols; 15 | /** 16 | * 17 | * struct statisticPortocol 18 | * { 19 | * unsigned char module_name_len; 20 | * unsigned char interface_name_len; 21 | * float cost_time; 22 | * unsigned char success; 23 | * int code; 24 | * unsigned short msg_len; 25 | * unsigned int time; 26 | * char[module_name_len] module_name; 27 | * char[interface_name_len] interface_name; 28 | * char[msg_len] msg; 29 | * } 30 | * 31 | * @author workerman.net 32 | */ 33 | class Statistic 34 | { 35 | /** 36 | * 包头长度 37 | * @var integer 38 | */ 39 | const PACKAGE_FIXED_LENGTH = 17; 40 | 41 | /** 42 | * udp 包最大长度 43 | * @var integer 44 | */ 45 | const MAX_UDP_PACKGE_SIZE = 65507; 46 | 47 | /** 48 | * char类型能保存的最大数值 49 | * @var integer 50 | */ 51 | const MAX_CHAR_VALUE = 255; 52 | 53 | /** 54 | * usigned short 能保存的最大数值 55 | * @var integer 56 | */ 57 | const MAX_UNSIGNED_SHORT_VALUE = 65535; 58 | 59 | /** 60 | * input 61 | * @param string $recv_buffer 62 | */ 63 | public static function input($recv_buffer) 64 | { 65 | if(strlen($recv_buffer) < self::PACKAGE_FIXED_LENGTH) 66 | { 67 | return 0; 68 | } 69 | $data = unpack("Cmodule_name_len/Cinterface_name_len/fcost_time/Csuccess/Ncode/nmsg_len/Ntime", $recv_buffer); 70 | return $data['module_name_len'] + $data['interface_name_len'] + $data['msg_len'] + self::PACKAGE_FIXED_LENGTH; 71 | } 72 | 73 | /** 74 | * 编码 75 | * @param string $module 76 | * @param string $interface 77 | * @param float $cost_time 78 | * @param int $success 79 | * @param int $code 80 | * @param string $msg 81 | * @return string 82 | */ 83 | public static function encode($data) 84 | { 85 | $module = $data['module']; 86 | $interface = $data['interface']; 87 | $cost_time = $data['$cost_time']; 88 | $success = $data['success']; 89 | $code = isset($data['code']) ? $data['code'] : 0; 90 | $msg = isset($data['msg']) ? $data['msg'] : ''; 91 | 92 | // 防止模块名过长 93 | if(strlen($module) > self::MAX_CHAR_VALUE) 94 | { 95 | $module = substr($module, 0, self::MAX_CHAR_VALUE); 96 | } 97 | 98 | // 防止接口名过长 99 | if(strlen($interface) > self::MAX_CHAR_VALUE) 100 | { 101 | $interface = substr($interface, 0, self::MAX_CHAR_VALUE); 102 | } 103 | 104 | // 防止msg过长 105 | $module_name_length = strlen($module); 106 | $interface_name_length = strlen($interface); 107 | $avalible_size = self::MAX_UDP_PACKGE_SIZE - self::PACKAGE_FIXED_LENGTH - $module_name_length - $interface_name_length; 108 | if(strlen($msg) > $avalible_size) 109 | { 110 | $msg = substr($msg, 0, $avalible_size); 111 | } 112 | 113 | // 打包 114 | return pack('CCfCNnN', $module_name_length, $interface_name_length, $cost_time, $success ? 1 : 0, $code, strlen($msg), time()).$module.$interface.$msg; 115 | } 116 | 117 | /** 118 | * 解包 119 | * @param string $recv_buffer 120 | * @return array 121 | */ 122 | public static function decode($recv_buffer) 123 | { 124 | // 解包 125 | $data = unpack("Cmodule_name_len/Cinterface_name_len/fcost_time/Csuccess/Ncode/nmsg_len/Ntime", $recv_buffer); 126 | $module = substr($recv_buffer, self::PACKAGE_FIXED_LENGTH, $data['module_name_len']); 127 | $interface = substr($recv_buffer, self::PACKAGE_FIXED_LENGTH + $data['module_name_len'], $data['interface_name_len']); 128 | $msg = substr($recv_buffer, self::PACKAGE_FIXED_LENGTH + $data['module_name_len'] + $data['interface_name_len']); 129 | return array( 130 | 'module' => $module, 131 | 'interface' => $interface, 132 | 'cost_time' => $data['cost_time'], 133 | 'success' => $data['success'], 134 | 'time' => $data['time'], 135 | 'code' => $data['code'], 136 | 'msg' => $msg, 137 | ); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Applications/Statistics/Lib/functions.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | use Workerman\Protocols\Http; 15 | /** 16 | * 批量请求 17 | * @param array $request_buffer_array ['ip:port'=>req_buf, 'ip:port'=>req_buf, ...] 18 | * @return multitype:unknown string 19 | */ 20 | function multiRequest($request_buffer_array) 21 | { 22 | \Statistics\Lib\Cache::$lastSuccessIpArray = array(); 23 | $client_array = $sock_to_ip = $ip_list = array(); 24 | foreach($request_buffer_array as $address => $buffer) 25 | { 26 | list($ip, $port) = explode(':', $address); 27 | $ip_list[$ip] = $ip; 28 | $client = stream_socket_client("tcp://$address", $errno, $errmsg, 1); 29 | if(!$client) 30 | { 31 | continue; 32 | } 33 | $client_array[$address] = $client; 34 | stream_set_timeout($client_array[$address], 0, 100000); 35 | fwrite($client_array[$address], $buffer); 36 | stream_set_blocking($client_array[$address], 0); 37 | $sock_to_address[(int)$client] = $address; 38 | } 39 | $read = $client_array; 40 | $write = $except = $read_buffer = array(); 41 | $time_start = microtime(true); 42 | $timeout = 0.99; 43 | // 轮询处理数据 44 | while(count($read) > 0) 45 | { 46 | if(@stream_select($read, $write, $except, 0, 200000)) 47 | { 48 | foreach($read as $socket) 49 | { 50 | $address = $sock_to_address[(int)$socket]; 51 | $buf = fread($socket, 8192); 52 | if(!$buf) 53 | { 54 | if(feof($socket)) 55 | { 56 | unset($client_array[$address]); 57 | } 58 | continue; 59 | } 60 | if(!isset($read_buffer[$address])) 61 | { 62 | $read_buffer[$address] = $buf; 63 | } 64 | else 65 | { 66 | $read_buffer[$address] .= $buf; 67 | } 68 | // 数据接收完毕 69 | if(($len = strlen($read_buffer[$address])) && $read_buffer[$address][$len-1] === "\n") 70 | { 71 | unset($client_array[$address]); 72 | } 73 | } 74 | } 75 | // 超时了 76 | if(microtime(true) - $time_start > $timeout) 77 | { 78 | break; 79 | } 80 | $read = $client_array; 81 | } 82 | 83 | foreach($read_buffer as $address => $buf) 84 | { 85 | list($ip, $port) = explode(':', $address); 86 | \Statistics\Lib\Cache::$lastSuccessIpArray[$ip] = $ip; 87 | } 88 | 89 | \Statistics\Lib\Cache::$lastFailedIpArray = array_diff($ip_list, \Statistics\Lib\Cache::$lastSuccessIpArray); 90 | 91 | ksort($read_buffer); 92 | 93 | return $read_buffer; 94 | } 95 | 96 | /** 97 | * 检查是否登录 98 | */ 99 | function check_auth() 100 | { 101 | // 如果配置中管理员用户名密码为空则说明不用验证 102 | if(Statistics\Config::$adminName == '' && Statistics\Config::$adminPassword == '') 103 | { 104 | return true; 105 | } 106 | // 进入验证流程 107 | _session_start(); 108 | if(!isset($_SESSION['admin'])) 109 | { 110 | if(!isset($_POST['admin_name']) || !isset($_POST['admin_password'])) 111 | { 112 | include ST_ROOT . '/Views/login.tpl.php'; 113 | _exit(); 114 | } 115 | else 116 | { 117 | $admin_name = $_POST['admin_name']; 118 | $admin_password = $_POST['admin_password']; 119 | if($admin_name != Statistics\Config::$adminName || $admin_password != Statistics\Config::$adminPassword) 120 | { 121 | $msg = "用户名或者密码不正确"; 122 | include ST_ROOT . '/Views/login.tpl.php'; 123 | _exit(); 124 | } 125 | $_SESSION['admin'] = $admin_name; 126 | } 127 | } 128 | return true; 129 | } 130 | 131 | /** 132 | * 启动session,兼容fpm 133 | */ 134 | function _session_start() 135 | { 136 | if(PHP_SAPI === 'cli') 137 | { 138 | return Http::sessionStart(); 139 | } 140 | return session_start(); 141 | } 142 | 143 | /** 144 | * 退出 145 | * @param string $str 146 | */ 147 | function _exit($str = '') 148 | { 149 | if(PHP_SAPI === 'cli') 150 | { 151 | return Http::end($str); 152 | } 153 | return exit($str); 154 | } 155 | -------------------------------------------------------------------------------- /Applications/Statistics/Modules/admin.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Statistics\Modules; 15 | 16 | function admin() 17 | { 18 | $act = isset($_GET['act'])? $_GET['act'] : 'home'; 19 | $err_msg = $notice_msg = $suc_msg = $ip_list_str = ''; 20 | $action = 'save_server_list'; 21 | switch($act) 22 | { 23 | case 'detect_server': 24 | // 创建udp socket 25 | $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 26 | socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, 1); 27 | $buffer = json_encode(array('cmd'=>'REPORT_IP'))."\n"; 28 | // 广播 29 | socket_sendto($socket, $buffer, strlen($buffer), 0, '255.255.255.255', \Statistics\Config::$ProviderPort); 30 | // 超时相关 31 | $time_start = microtime(true); 32 | $global_timeout = 1; 33 | $ip_list = array(); 34 | $recv_timeout = array('sec'=>0,'usec'=>8000); 35 | socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,$recv_timeout); 36 | 37 | // 循环读数据 38 | while(microtime(true) - $time_start < $global_timeout) 39 | { 40 | $buf = $host = $port = ''; 41 | if(@socket_recvfrom($socket, $buf, 65535, 0, $host, $port)) 42 | { 43 | $ip_list[$host] = $host; 44 | } 45 | } 46 | 47 | // 过滤掉已经保存的ip 48 | $count = 0; 49 | foreach($ip_list as $ip) 50 | { 51 | if(!isset(\Statistics\Lib\Cache::$ServerIpList[$ip])) 52 | { 53 | $ip_list_str .= $ip."\r\n"; 54 | $count ++; 55 | } 56 | } 57 | $action = 'add_to_server_list'; 58 | $notice_msg = "探测到{$count}个新数据源"; 59 | break; 60 | case 'add_to_server_list': 61 | if(empty($_POST['ip_list'])) 62 | { 63 | $err_msg = "保存的ip列表为空"; 64 | break; 65 | } 66 | $ip_list = explode("\n", $_POST['ip_list']); 67 | if($ip_list) 68 | { 69 | foreach($ip_list as $ip) 70 | { 71 | $ip = trim($ip); 72 | if(false !== ip2long($ip)) 73 | { 74 | \Statistics\Lib\Cache::$ServerIpList[$ip] = $ip; 75 | } 76 | } 77 | } 78 | $suc_msg = "添加成功"; 79 | foreach(\Statistics\Lib\Cache::$ServerIpList as $ip) 80 | { 81 | $ip_list_str .= $ip."\r\n"; 82 | } 83 | saveServerIpListToCache(); 84 | break; 85 | case 'save_server_list': 86 | if(empty($_POST['ip_list'])) 87 | { 88 | $err_msg = "保存的ip列表为空"; 89 | break; 90 | } 91 | \Statistics\Lib\Cache::$ServerIpList = array(); 92 | $ip_list = explode("\n", $_POST['ip_list']); 93 | if($ip_list) 94 | { 95 | foreach($ip_list as $ip) 96 | { 97 | $ip = trim($ip); 98 | if(false !== ip2long($ip)) 99 | { 100 | \Statistics\Lib\Cache::$ServerIpList[$ip] = $ip; 101 | } 102 | } 103 | } 104 | $suc_msg = "保存成功"; 105 | foreach(\Statistics\Lib\Cache::$ServerIpList as $ip) 106 | { 107 | $ip_list_str .= $ip."\r\n"; 108 | } 109 | saveServerIpListToCache(); 110 | break; 111 | default: 112 | foreach(\Statistics\Lib\Cache::$ServerIpList as $ip) 113 | { 114 | $ip_list_str .= $ip."\r\n"; 115 | } 116 | } 117 | 118 | include ST_ROOT . '/Views/header.tpl.php'; 119 | include ST_ROOT . '/Views/admin.tpl.php'; 120 | include ST_ROOT . '/Views/footer.tpl.php'; 121 | } 122 | 123 | function saveServerIpListToCache() 124 | { 125 | foreach(glob(ST_ROOT . '/Config/Cache/*.iplist.cache.php') as $php_file) 126 | { 127 | unlink($php_file); 128 | } 129 | file_put_contents(ST_ROOT . '/Config/Cache/'.time().'.iplist.cache.php', " 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | use Workerman\Worker; 15 | 16 | 17 | define('THRIFT_ROOT', __DIR__); 18 | require_once THRIFT_ROOT . '/Lib/Thrift/ClassLoader/ThriftClassLoader.php'; 19 | require_once THRIFT_ROOT . '/Lib/Statistics/StatisticClient.php'; 20 | 21 | use Thrift\ClassLoader\ThriftClassLoader; 22 | 23 | $loader = new ThriftClassLoader(); 24 | $loader->registerNamespace('Thrift', THRIFT_ROOT.'/Lib'); 25 | $loader->registerNamespace('Service', THRIFT_ROOT); 26 | $loader->register(); 27 | 28 | /** 29 | * 30 | * ThriftWorker 31 | * 32 | * @author walkor 33 | */ 34 | class ThriftWorker extends Worker 35 | { 36 | /** 37 | * Thrift processor 38 | * @var object 39 | */ 40 | protected $processor = null; 41 | 42 | /** 43 | * 使用的协议,默认TBinaryProtocol,可更改 44 | * @var string 45 | */ 46 | public $thriftProtocol = 'TBinaryProtocol'; 47 | 48 | /** 49 | * 使用的传输类,默认是TBufferedTransport,可更改 50 | * @var string 51 | */ 52 | public $thriftTransport = 'TBufferedTransport'; 53 | 54 | /** 55 | * 设置类名称 56 | * @var string 57 | */ 58 | public $class = ''; 59 | 60 | /** 61 | * 统计数据上报的地址 62 | * @var string 63 | */ 64 | public $statisticAddress = 'udp://127.0.0.1:55656'; 65 | 66 | /** 67 | * construct 68 | */ 69 | public function __construct($socket_name) 70 | { 71 | parent::__construct($socket_name); 72 | $this->onWorkerStart = array($this, 'onStart'); 73 | $this->onConnect = array($this, 'onConnect'); 74 | } 75 | 76 | /** 77 | * 进程启动时做的一些初始化工作 78 | * @see Man\Core.SocketWorker::onStart() 79 | * @return void 80 | */ 81 | public function onStart() 82 | { 83 | // 检查类是否设置 84 | if(!$this->class) 85 | { 86 | throw new \Exception('ThriftWorker->class not set'); 87 | } 88 | 89 | // 设置name 90 | if($this->name == 'none') 91 | { 92 | $this->name = $this->class; 93 | } 94 | 95 | // 载入该服务下的所有文件 96 | foreach(glob(THRIFT_ROOT . '/Services/'.$this->class.'/*.php') as $php_file) 97 | { 98 | require_once $php_file; 99 | } 100 | 101 | // 检查类是否存在 102 | $processor_class_name = "\\Services\\".$this->class."\\".$this->class.'Processor'; 103 | if(!class_exists($processor_class_name)) 104 | { 105 | ThriftWorker::log("Class $processor_class_name not found" ); 106 | return; 107 | } 108 | 109 | // 检查类是否存在 110 | $handler_class_name ="\\Services\\".$this->class."\\".$this->class.'Handler'; 111 | if(!class_exists($handler_class_name)) 112 | { 113 | ThriftWorker::log("Class $handler_class_name not found" ); 114 | return; 115 | } 116 | 117 | $handler = new $handler_class_name(); 118 | $this->processor = new $processor_class_name($handler); 119 | } 120 | 121 | /** 122 | * 处理受到的数据 123 | * @param TcpConnection $connection 124 | * @return void 125 | */ 126 | public function onConnect($connection) 127 | { 128 | $socket = $connection->getSocket(); 129 | $t_socket = new Thrift\Transport\TSocket($connection->getRemoteIp(), $connection->getRemotePort()); 130 | $t_socket->setHandle($socket); 131 | $transport_name = '\\Thrift\\Transport\\'.$this->thriftTransport; 132 | $transport = new $transport_name($t_socket); 133 | $protocol_name = '\\Thrift\\Protocol\\' . $this->thriftProtocol; 134 | $protocol = new $protocol_name($transport); 135 | 136 | // 执行处理 137 | try{ 138 | // 先初始化一个 139 | $protocol->fname = 'none'; 140 | // 统计开始时间 141 | \Thrift\Statistics\StatisticClient::tick(); 142 | // 业务处理 143 | $this->processor->process($protocol, $protocol); 144 | \Thrift\Statistics\StatisticClient::report($this->name, $protocol->fname, 1, 0, '', $this->statisticAddress); 145 | } 146 | catch(\Exception $e) 147 | { 148 | \Thrift\Statistics\StatisticClient::report($this->name, $protocol->fname, 0, $e->getCode(), $e, $this->statisticAddress); 149 | ThriftWorker::log('CODE:' . $e->getCode() . ' MESSAGE:' . $e->getMessage()."\n".$e->getTraceAsString()."\nCLIENT_IP:".$connection->getRemoteIp()."\n"); 150 | $connection->send($e->getMessage()); 151 | } 152 | 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/dropdowns.less: -------------------------------------------------------------------------------- 1 | // 2 | // Dropdown menus 3 | // -------------------------------------------------- 4 | 5 | 6 | // Dropdown arrow/caret 7 | .caret { 8 | display: inline-block; 9 | width: 0; 10 | height: 0; 11 | margin-left: 2px; 12 | vertical-align: middle; 13 | border-top: @caret-width-base solid @dropdown-caret-color; 14 | border-right: @caret-width-base solid transparent; 15 | border-left: @caret-width-base solid transparent; 16 | // Firefox fix for https://github.com/twbs/bootstrap/issues/9538. Once fixed, 17 | // we can just straight up remove this. 18 | border-bottom: 0 dotted; 19 | } 20 | 21 | // The dropdown wrapper (div) 22 | .dropdown { 23 | position: relative; 24 | } 25 | 26 | // Prevent the focus on the dropdown toggle when closing dropdowns 27 | .dropdown-toggle:focus { 28 | outline: 0; 29 | } 30 | 31 | // The dropdown menu (ul) 32 | .dropdown-menu { 33 | position: absolute; 34 | top: 100%; 35 | left: 0; 36 | z-index: @zindex-dropdown; 37 | display: none; // none by default, but block on "open" of the menu 38 | float: left; 39 | min-width: 160px; 40 | padding: 5px 0; 41 | margin: 2px 0 0; // override default ul 42 | list-style: none; 43 | font-size: @font-size-base; 44 | background-color: @dropdown-bg; 45 | border: 1px solid @dropdown-fallback-border; // IE8 fallback 46 | border: 1px solid @dropdown-border; 47 | border-radius: @border-radius-base; 48 | .box-shadow(0 6px 12px rgba(0,0,0,.175)); 49 | background-clip: padding-box; 50 | 51 | // Aligns the dropdown menu to right 52 | &.pull-right { 53 | right: 0; 54 | left: auto; 55 | } 56 | 57 | // Dividers (basically an hr) within the dropdown 58 | .divider { 59 | .nav-divider(@dropdown-divider-bg); 60 | } 61 | 62 | // Links within the dropdown menu 63 | > li > a { 64 | display: block; 65 | padding: 3px 20px; 66 | clear: both; 67 | font-weight: normal; 68 | line-height: @line-height-base; 69 | color: @dropdown-link-color; 70 | white-space: nowrap; // prevent links from randomly breaking onto new lines 71 | } 72 | } 73 | 74 | // Hover/Focus state 75 | .dropdown-menu > li > a { 76 | &:hover, 77 | &:focus { 78 | text-decoration: none; 79 | color: @dropdown-link-hover-color; 80 | background-color: @dropdown-link-hover-bg; 81 | } 82 | } 83 | 84 | // Active state 85 | .dropdown-menu > .active > a { 86 | &, 87 | &:hover, 88 | &:focus { 89 | color: @dropdown-link-active-color; 90 | text-decoration: none; 91 | outline: 0; 92 | background-color: @dropdown-link-active-bg; 93 | } 94 | } 95 | 96 | // Disabled state 97 | // 98 | // Gray out text and ensure the hover/focus state remains gray 99 | 100 | .dropdown-menu > .disabled > a { 101 | &, 102 | &:hover, 103 | &:focus { 104 | color: @dropdown-link-disabled-color; 105 | } 106 | } 107 | // Nuke hover/focus effects 108 | .dropdown-menu > .disabled > a { 109 | &:hover, 110 | &:focus { 111 | text-decoration: none; 112 | background-color: transparent; 113 | background-image: none; // Remove CSS gradient 114 | .reset-filter(); 115 | cursor: not-allowed; 116 | } 117 | } 118 | 119 | // Open state for the dropdown 120 | .open { 121 | // Show the menu 122 | > .dropdown-menu { 123 | display: block; 124 | } 125 | 126 | // Remove the outline when :focus is triggered 127 | > a { 128 | outline: 0; 129 | } 130 | } 131 | 132 | // Dropdown section headers 133 | .dropdown-header { 134 | display: block; 135 | padding: 3px 20px; 136 | font-size: @font-size-small; 137 | line-height: @line-height-base; 138 | color: @dropdown-header-color; 139 | } 140 | 141 | // Backdrop to catch body clicks on mobile, etc. 142 | .dropdown-backdrop { 143 | position: fixed; 144 | left: 0; 145 | right: 0; 146 | bottom: 0; 147 | top: 0; 148 | z-index: @zindex-dropdown - 10; 149 | } 150 | 151 | // Right aligned dropdowns 152 | .pull-right > .dropdown-menu { 153 | right: 0; 154 | left: auto; 155 | } 156 | 157 | // Allow for dropdowns to go bottom up (aka, dropup-menu) 158 | // 159 | // Just add .dropup after the standard .dropdown class and you're set, bro. 160 | // TODO: abstract this so that the navbar fixed styles are not placed here? 161 | 162 | .dropup, 163 | .navbar-fixed-bottom .dropdown { 164 | // Reverse the caret 165 | .caret { 166 | // Firefox fix for https://github.com/twbs/bootstrap/issues/9538. Once this 167 | // gets fixed, restore `border-top: 0;`. 168 | border-top: 0 dotted; 169 | border-bottom: @caret-width-base solid @dropdown-caret-color; 170 | content: ""; 171 | } 172 | // Different positioning for bottom up menu 173 | .dropdown-menu { 174 | top: auto; 175 | bottom: 100%; 176 | margin-bottom: 1px; 177 | } 178 | } 179 | 180 | 181 | // Component alignment 182 | // 183 | // Reiterate per navbar.less and the modified component alignment there. 184 | 185 | @media (min-width: @grid-float-breakpoint) { 186 | .navbar-right { 187 | .dropdown-menu { 188 | .pull-right > .dropdown-menu(); 189 | } 190 | } 191 | } 192 | 193 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Transport/TBufferedTransport.php: -------------------------------------------------------------------------------- 1 | transport_ = $transport; 42 | $this->rBufSize_ = $rBufSize; 43 | $this->wBufSize_ = $wBufSize; 44 | } 45 | 46 | /** 47 | * The underlying transport 48 | * 49 | * @var TTransport 50 | */ 51 | protected $transport_ = null; 52 | 53 | /** 54 | * The receive buffer size 55 | * 56 | * @var int 57 | */ 58 | protected $rBufSize_ = 512; 59 | 60 | /** 61 | * The write buffer size 62 | * 63 | * @var int 64 | */ 65 | protected $wBufSize_ = 512; 66 | 67 | /** 68 | * The write buffer. 69 | * 70 | * @var string 71 | */ 72 | protected $wBuf_ = ''; 73 | 74 | /** 75 | * The read buffer. 76 | * 77 | * @var string 78 | */ 79 | protected $rBuf_ = ''; 80 | 81 | public function isOpen() { 82 | return $this->transport_->isOpen(); 83 | } 84 | 85 | public function open() { 86 | $this->transport_->open(); 87 | } 88 | 89 | public function close() { 90 | $this->transport_->close(); 91 | } 92 | 93 | public function putBack($data) { 94 | if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { 95 | $this->rBuf_ = $data; 96 | } else { 97 | $this->rBuf_ = ($data . $this->rBuf_); 98 | } 99 | } 100 | 101 | /** 102 | * The reason that we customize readAll here is that the majority of PHP 103 | * streams are already internally buffered by PHP. The socket stream, for 104 | * example, buffers internally and blocks if you call read with $len greater 105 | * than the amount of data available, unlike recv() in C. 106 | * 107 | * Therefore, use the readAll method of the wrapped transport inside 108 | * the buffered readAll. 109 | */ 110 | public function readAll($len) { 111 | $have = TStringFuncFactory::create()->strlen($this->rBuf_); 112 | if ($have == 0) { 113 | $data = $this->transport_->readAll($len); 114 | } else if ($have < $len) { 115 | $data = $this->rBuf_; 116 | $this->rBuf_ = ''; 117 | $data .= $this->transport_->readAll($len - $have); 118 | } else if ($have == $len) { 119 | $data = $this->rBuf_; 120 | $this->rBuf_ = ''; 121 | } else if ($have > $len) { 122 | $data = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len); 123 | $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len); 124 | } 125 | return $data; 126 | } 127 | 128 | public function read($len) { 129 | if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { 130 | $this->rBuf_ = $this->transport_->read($this->rBufSize_); 131 | } 132 | 133 | if (TStringFuncFactory::create()->strlen($this->rBuf_) <= $len) { 134 | $ret = $this->rBuf_; 135 | $this->rBuf_ = ''; 136 | return $ret; 137 | } 138 | 139 | $ret = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len); 140 | $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len); 141 | return $ret; 142 | } 143 | 144 | public function write($buf) { 145 | $this->wBuf_ .= $buf; 146 | if (TStringFuncFactory::create()->strlen($this->wBuf_) >= $this->wBufSize_) { 147 | $out = $this->wBuf_; 148 | 149 | // Note that we clear the internal wBuf_ prior to the underlying write 150 | // to ensure we're in a sane state (i.e. internal buffer cleaned) 151 | // if the underlying write throws up an exception 152 | $this->wBuf_ = ''; 153 | $this->transport_->write($out); 154 | } 155 | } 156 | 157 | public function flush() { 158 | if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) { 159 | $this->transport_->write($this->wBuf_); 160 | $this->wBuf_ = ''; 161 | } 162 | $this->transport_->flush(); 163 | } 164 | 165 | } 166 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Transport/TFramedTransport.php: -------------------------------------------------------------------------------- 1 | transport_ = $transport; 78 | $this->read_ = $read; 79 | $this->write_ = $write; 80 | } 81 | 82 | public function isOpen() { 83 | return $this->transport_->isOpen(); 84 | } 85 | 86 | public function open() { 87 | $this->transport_->open(); 88 | } 89 | 90 | public function close() { 91 | $this->transport_->close(); 92 | } 93 | 94 | /** 95 | * Reads from the buffer. When more data is required reads another entire 96 | * chunk and serves future reads out of that. 97 | * 98 | * @param int $len How much data 99 | */ 100 | public function read($len) { 101 | if (!$this->read_) { 102 | return $this->transport_->read($len); 103 | } 104 | 105 | if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { 106 | $this->readFrame(); 107 | } 108 | 109 | // Just return full buff 110 | if ($len >= TStringFuncFactory::create()->strlen($this->rBuf_)) { 111 | $out = $this->rBuf_; 112 | $this->rBuf_ = null; 113 | return $out; 114 | } 115 | 116 | // Return TStringFuncFactory::create()->substr 117 | $out = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len); 118 | $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len); 119 | return $out; 120 | } 121 | 122 | /** 123 | * Put previously read data back into the buffer 124 | * 125 | * @param string $data data to return 126 | */ 127 | public function putBack($data) { 128 | if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { 129 | $this->rBuf_ = $data; 130 | } else { 131 | $this->rBuf_ = ($data . $this->rBuf_); 132 | } 133 | } 134 | 135 | /** 136 | * Reads a chunk of data into the internal read buffer. 137 | */ 138 | private function readFrame() { 139 | $buf = $this->transport_->readAll(4); 140 | $val = unpack('N', $buf); 141 | $sz = $val[1]; 142 | 143 | $this->rBuf_ = $this->transport_->readAll($sz); 144 | } 145 | 146 | /** 147 | * Writes some data to the pending output buffer. 148 | * 149 | * @param string $buf The data 150 | * @param int $len Limit of bytes to write 151 | */ 152 | public function write($buf, $len=null) { 153 | if (!$this->write_) { 154 | return $this->transport_->write($buf, $len); 155 | } 156 | 157 | if ($len !== null && $len < TStringFuncFactory::create()->strlen($buf)) { 158 | $buf = TStringFuncFactory::create()->substr($buf, 0, $len); 159 | } 160 | $this->wBuf_ .= $buf; 161 | } 162 | 163 | /** 164 | * Writes the output buffer to the stream in the format of a 4-byte length 165 | * followed by the actual data. 166 | */ 167 | public function flush() { 168 | if (!$this->write_ || TStringFuncFactory::create()->strlen($this->wBuf_) == 0) { 169 | return $this->transport_->flush(); 170 | } 171 | 172 | $out = pack('N', TStringFuncFactory::create()->strlen($this->wBuf_)); 173 | $out .= $this->wBuf_; 174 | 175 | // Note that we clear the internal wBuf_ prior to the underlying write 176 | // to ensure we're in a sane state (i.e. internal buffer cleaned) 177 | // if the underlying write throws up an exception 178 | $this->wBuf_ = ''; 179 | $this->transport_->write($out); 180 | $this->transport_->flush(); 181 | } 182 | 183 | } 184 | -------------------------------------------------------------------------------- /Applications/Statistics/Views/statistic.tpl.php: -------------------------------------------------------------------------------- 1 |
      2 |
      3 |
      4 | 32 |
      33 |
      34 |
      35 |
      36 |
      37 |
      38 |
      39 | 40 |
      41 | 42 | 43 |
      44 | 45 | 46 |
      47 |
      48 | 49 |
      50 |
      51 |
      52 |
      53 |
      54 |
      55 |
      56 |
      57 |
      58 |
      59 | 60 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 |
      时间调用总数平均耗时成功调用总数成功平均耗时失败调用总数失败平均耗时成功率
      193 | 194 |
      195 |
      196 |
      197 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/tables.less: -------------------------------------------------------------------------------- 1 | // 2 | // Tables 3 | // -------------------------------------------------- 4 | 5 | 6 | table { 7 | max-width: 100%; 8 | background-color: @table-bg; 9 | } 10 | th { 11 | text-align: left; 12 | } 13 | 14 | 15 | // Baseline styles 16 | 17 | .table { 18 | width: 100%; 19 | margin-bottom: @line-height-computed; 20 | // Cells 21 | > thead, 22 | > tbody, 23 | > tfoot { 24 | > tr { 25 | > th, 26 | > td { 27 | padding: @table-cell-padding; 28 | line-height: @line-height-base; 29 | vertical-align: top; 30 | border-top: 1px solid @table-border-color; 31 | } 32 | } 33 | } 34 | // Bottom align for column headings 35 | > thead > tr > th { 36 | vertical-align: bottom; 37 | border-bottom: 2px solid @table-border-color; 38 | } 39 | // Remove top border from thead by default 40 | > caption + thead, 41 | > colgroup + thead, 42 | > thead:first-child { 43 | > tr:first-child { 44 | > th, 45 | > td { 46 | border-top: 0; 47 | } 48 | } 49 | } 50 | // Account for multiple tbody instances 51 | > tbody + tbody { 52 | border-top: 2px solid @table-border-color; 53 | } 54 | 55 | // Nesting 56 | .table { 57 | background-color: @body-bg; 58 | } 59 | } 60 | 61 | 62 | // Condensed table w/ half padding 63 | 64 | .table-condensed { 65 | > thead, 66 | > tbody, 67 | > tfoot { 68 | > tr { 69 | > th, 70 | > td { 71 | padding: @table-condensed-cell-padding; 72 | } 73 | } 74 | } 75 | } 76 | 77 | 78 | // Bordered version 79 | // 80 | // Add borders all around the table and between all the columns. 81 | 82 | .table-bordered { 83 | border: 1px solid @table-border-color; 84 | > thead, 85 | > tbody, 86 | > tfoot { 87 | > tr { 88 | > th, 89 | > td { 90 | border: 1px solid @table-border-color; 91 | } 92 | } 93 | } 94 | > thead > tr { 95 | > th, 96 | > td { 97 | border-bottom-width: 2px; 98 | } 99 | } 100 | } 101 | 102 | 103 | // Zebra-striping 104 | // 105 | // Default zebra-stripe styles (alternating gray and transparent backgrounds) 106 | 107 | .table-striped > tbody > tr:nth-child(odd) { 108 | > td, 109 | > th { 110 | background-color: @table-bg-accent; 111 | } 112 | } 113 | 114 | 115 | // Hover effect 116 | // 117 | // Placed here since it has to come after the potential zebra striping 118 | 119 | .table-hover > tbody > tr:hover { 120 | > td, 121 | > th { 122 | background-color: @table-bg-hover; 123 | } 124 | } 125 | 126 | 127 | // Table cell sizing 128 | // 129 | // Reset default table behavior 130 | 131 | table col[class*="col-"] { 132 | float: none; 133 | display: table-column; 134 | } 135 | table { 136 | td, 137 | th { 138 | &[class*="col-"] { 139 | float: none; 140 | display: table-cell; 141 | } 142 | } 143 | } 144 | 145 | 146 | // Table backgrounds 147 | // 148 | // Exact selectors below required to override `.table-striped` and prevent 149 | // inheritance to nested tables. 150 | 151 | .table > thead > tr, 152 | .table > tbody > tr, 153 | .table > tfoot > tr { 154 | > td.active, 155 | > th.active, 156 | &.active > td, 157 | &.active > th { 158 | background-color: @table-bg-active; 159 | } 160 | } 161 | 162 | // Generate the contextual variants 163 | .table-row-variant(success; @state-success-bg; @state-success-border); 164 | .table-row-variant(danger; @state-danger-bg; @state-danger-border); 165 | .table-row-variant(warning; @state-warning-bg; @state-warning-border); 166 | 167 | 168 | // Responsive tables 169 | // 170 | // Wrap your tables in `.table-responsive` and we'll make them mobile friendly 171 | // by enabling horizontal scrolling. Only applies <768px. Everything above that 172 | // will display normally. 173 | 174 | @media (max-width: @screen-xs-max) { 175 | .table-responsive { 176 | width: 100%; 177 | margin-bottom: (@line-height-computed * 0.75); 178 | overflow-y: hidden; 179 | overflow-x: scroll; 180 | -ms-overflow-style: -ms-autohiding-scrollbar; 181 | border: 1px solid @table-border-color; 182 | -webkit-overflow-scrolling: touch; 183 | 184 | // Tighten up spacing 185 | > .table { 186 | margin-bottom: 0; 187 | 188 | // Ensure the content doesn't wrap 189 | > thead, 190 | > tbody, 191 | > tfoot { 192 | > tr { 193 | > th, 194 | > td { 195 | white-space: nowrap; 196 | } 197 | } 198 | } 199 | } 200 | 201 | // Special overrides for the bordered tables 202 | > .table-bordered { 203 | border: 0; 204 | 205 | // Nuke the appropriate borders so that the parent can handle them 206 | > thead, 207 | > tbody, 208 | > tfoot { 209 | > tr { 210 | > th:first-child, 211 | > td:first-child { 212 | border-left: 0; 213 | } 214 | > th:last-child, 215 | > td:last-child { 216 | border-right: 0; 217 | } 218 | } 219 | } 220 | 221 | // Only nuke the last row's bottom-border in `tbody` and `tfoot` since 222 | // chances are there will be only one `tr` in a `thead` and that would 223 | // remove the border altogether. 224 | > tbody, 225 | > tfoot { 226 | > tr:last-child { 227 | > th, 228 | > td { 229 | border-bottom: 0; 230 | } 231 | } 232 | } 233 | 234 | } 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/carousel.less: -------------------------------------------------------------------------------- 1 | // 2 | // Carousel 3 | // -------------------------------------------------- 4 | 5 | 6 | // Wrapper for the slide container and indicators 7 | .carousel { 8 | position: relative; 9 | } 10 | 11 | .carousel-inner { 12 | position: relative; 13 | overflow: hidden; 14 | width: 100%; 15 | 16 | > .item { 17 | display: none; 18 | position: relative; 19 | .transition(.6s ease-in-out left); 20 | 21 | // Account for jankitude on images 22 | > img, 23 | > a > img { 24 | .img-responsive(); 25 | line-height: 1; 26 | } 27 | } 28 | 29 | > .active, 30 | > .next, 31 | > .prev { display: block; } 32 | 33 | > .active { 34 | left: 0; 35 | } 36 | 37 | > .next, 38 | > .prev { 39 | position: absolute; 40 | top: 0; 41 | width: 100%; 42 | } 43 | 44 | > .next { 45 | left: 100%; 46 | } 47 | > .prev { 48 | left: -100%; 49 | } 50 | > .next.left, 51 | > .prev.right { 52 | left: 0; 53 | } 54 | 55 | > .active.left { 56 | left: -100%; 57 | } 58 | > .active.right { 59 | left: 100%; 60 | } 61 | 62 | } 63 | 64 | // Left/right controls for nav 65 | // --------------------------- 66 | 67 | .carousel-control { 68 | position: absolute; 69 | top: 0; 70 | left: 0; 71 | bottom: 0; 72 | width: @carousel-control-width; 73 | .opacity(@carousel-control-opacity); 74 | font-size: @carousel-control-font-size; 75 | color: @carousel-control-color; 76 | text-align: center; 77 | text-shadow: @carousel-text-shadow; 78 | // We can't have this transition here because WebKit cancels the carousel 79 | // animation if you trip this while in the middle of another animation. 80 | 81 | // Set gradients for backgrounds 82 | &.left { 83 | #gradient > .horizontal(@start-color: rgba(0,0,0,.5); @end-color: rgba(0,0,0,.0001)); 84 | } 85 | &.right { 86 | left: auto; 87 | right: 0; 88 | #gradient > .horizontal(@start-color: rgba(0,0,0,.0001); @end-color: rgba(0,0,0,.5)); 89 | } 90 | 91 | // Hover/focus state 92 | &:hover, 93 | &:focus { 94 | color: @carousel-control-color; 95 | text-decoration: none; 96 | .opacity(.9); 97 | } 98 | 99 | // Toggles 100 | .icon-prev, 101 | .icon-next, 102 | .glyphicon-chevron-left, 103 | .glyphicon-chevron-right { 104 | position: absolute; 105 | top: 50%; 106 | z-index: 5; 107 | display: inline-block; 108 | } 109 | .icon-prev, 110 | .glyphicon-chevron-left { 111 | left: 50%; 112 | } 113 | .icon-next, 114 | .glyphicon-chevron-right { 115 | right: 50%; 116 | } 117 | .icon-prev, 118 | .icon-next { 119 | width: 20px; 120 | height: 20px; 121 | margin-top: -10px; 122 | margin-left: -10px; 123 | font-family: serif; 124 | } 125 | 126 | .icon-prev { 127 | &:before { 128 | content: '\2039';// SINGLE LEFT-POINTING ANGLE QUOTATION MARK (U+2039) 129 | } 130 | } 131 | .icon-next { 132 | &:before { 133 | content: '\203a';// SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (U+203A) 134 | } 135 | } 136 | } 137 | 138 | // Optional indicator pips 139 | // 140 | // Add an unordered list with the following class and add a list item for each 141 | // slide your carousel holds. 142 | 143 | .carousel-indicators { 144 | position: absolute; 145 | bottom: 10px; 146 | left: 50%; 147 | z-index: 15; 148 | width: 60%; 149 | margin-left: -30%; 150 | padding-left: 0; 151 | list-style: none; 152 | text-align: center; 153 | 154 | li { 155 | display: inline-block; 156 | width: 10px; 157 | height: 10px; 158 | margin: 1px; 159 | text-indent: -999px; 160 | border: 1px solid @carousel-indicator-border-color; 161 | border-radius: 10px; 162 | cursor: pointer; 163 | 164 | // IE8-9 hack for event handling 165 | // 166 | // Internet Explorer 8-9 does not support clicks on elements without a set 167 | // `background-color`. We cannot use `filter` since that's not viewed as a 168 | // background color by the browser. Thus, a hack is needed. 169 | // 170 | // For IE8, we set solid black as it doesn't support `rgba()`. For IE9, we 171 | // set alpha transparency for the best results possible. 172 | background-color: #000 \9; // IE8 173 | background-color: rgba(0,0,0,0); // IE9 174 | } 175 | .active { 176 | margin: 0; 177 | width: 12px; 178 | height: 12px; 179 | background-color: @carousel-indicator-active-bg; 180 | } 181 | } 182 | 183 | // Optional captions 184 | // ----------------------------- 185 | // Hidden by default for smaller viewports 186 | .carousel-caption { 187 | position: absolute; 188 | left: 15%; 189 | right: 15%; 190 | bottom: 20px; 191 | z-index: 10; 192 | padding-top: 20px; 193 | padding-bottom: 20px; 194 | color: @carousel-caption-color; 195 | text-align: center; 196 | text-shadow: @carousel-text-shadow; 197 | & .btn { 198 | text-shadow: none; // No shadow for button elements in carousel-caption 199 | } 200 | } 201 | 202 | 203 | // Scale up controls for tablets and up 204 | @media screen and (min-width: @screen-sm-min) { 205 | 206 | // Scale up the controls a smidge 207 | .carousel-control { 208 | .glyphicons-chevron-left, 209 | .glyphicons-chevron-right, 210 | .icon-prev, 211 | .icon-next { 212 | width: 30px; 213 | height: 30px; 214 | margin-top: -15px; 215 | margin-left: -15px; 216 | font-size: 30px; 217 | } 218 | } 219 | 220 | // Show and left align the captions 221 | .carousel-caption { 222 | left: 20%; 223 | right: 20%; 224 | padding-bottom: 30px; 225 | } 226 | 227 | // Move up the indicators 228 | .carousel-indicators { 229 | bottom: 20px; 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/responsive-utilities.less: -------------------------------------------------------------------------------- 1 | // 2 | // Responsive: Utility classes 3 | // -------------------------------------------------- 4 | 5 | 6 | // IE10 in Windows (Phone) 8 7 | // 8 | // Support for responsive views via media queries is kind of borked in IE10, for 9 | // Surface/desktop in split view and for Windows Phone 8. This particular fix 10 | // must be accompanied by a snippet of JavaScript to sniff the user agent and 11 | // apply some conditional CSS to *only* the Surface/desktop Windows 8. Look at 12 | // our Getting Started page for more information on this bug. 13 | // 14 | // For more information, see the following: 15 | // 16 | // Issue: https://github.com/twbs/bootstrap/issues/10497 17 | // Docs: http://getbootstrap.com/getting-started/#browsers 18 | // Source: http://timkadlec.com/2012/10/ie10-snap-mode-and-responsive-design/ 19 | 20 | @-ms-viewport { 21 | width: device-width; 22 | } 23 | 24 | 25 | // Visibility utilities 26 | 27 | .visible-xs { 28 | .responsive-invisibility(); 29 | @media (max-width: @screen-xs-max) { 30 | .responsive-visibility(); 31 | } 32 | &.visible-sm { 33 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 34 | .responsive-visibility(); 35 | } 36 | } 37 | &.visible-md { 38 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 39 | .responsive-visibility(); 40 | } 41 | } 42 | &.visible-lg { 43 | @media (min-width: @screen-lg-min) { 44 | .responsive-visibility(); 45 | } 46 | } 47 | } 48 | .visible-sm { 49 | .responsive-invisibility(); 50 | &.visible-xs { 51 | @media (max-width: @screen-xs-max) { 52 | .responsive-visibility(); 53 | } 54 | } 55 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 56 | .responsive-visibility(); 57 | } 58 | &.visible-md { 59 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 60 | .responsive-visibility(); 61 | } 62 | } 63 | &.visible-lg { 64 | @media (min-width: @screen-lg-min) { 65 | .responsive-visibility(); 66 | } 67 | } 68 | } 69 | .visible-md { 70 | .responsive-invisibility(); 71 | &.visible-xs { 72 | @media (max-width: @screen-xs-max) { 73 | .responsive-visibility(); 74 | } 75 | } 76 | &.visible-sm { 77 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 78 | .responsive-visibility(); 79 | } 80 | } 81 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 82 | .responsive-visibility(); 83 | } 84 | &.visible-lg { 85 | @media (min-width: @screen-lg-min) { 86 | .responsive-visibility(); 87 | } 88 | } 89 | } 90 | .visible-lg { 91 | .responsive-invisibility(); 92 | &.visible-xs { 93 | @media (max-width: @screen-xs-max) { 94 | .responsive-visibility(); 95 | } 96 | } 97 | &.visible-sm { 98 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 99 | .responsive-visibility(); 100 | } 101 | } 102 | &.visible-md { 103 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 104 | .responsive-visibility(); 105 | } 106 | } 107 | @media (min-width: @screen-lg-min) { 108 | .responsive-visibility(); 109 | } 110 | } 111 | 112 | .hidden-xs { 113 | .responsive-visibility(); 114 | @media (max-width: @screen-xs-max) { 115 | .responsive-invisibility(); 116 | } 117 | &.hidden-sm { 118 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 119 | .responsive-invisibility(); 120 | } 121 | } 122 | &.hidden-md { 123 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 124 | .responsive-invisibility(); 125 | } 126 | } 127 | &.hidden-lg { 128 | @media (min-width: @screen-lg-min) { 129 | .responsive-invisibility(); 130 | } 131 | } 132 | } 133 | .hidden-sm { 134 | .responsive-visibility(); 135 | &.hidden-xs { 136 | @media (max-width: @screen-xs-max) { 137 | .responsive-invisibility(); 138 | } 139 | } 140 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 141 | .responsive-invisibility(); 142 | } 143 | &.hidden-md { 144 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 145 | .responsive-invisibility(); 146 | } 147 | } 148 | &.hidden-lg { 149 | @media (min-width: @screen-lg-min) { 150 | .responsive-invisibility(); 151 | } 152 | } 153 | } 154 | .hidden-md { 155 | .responsive-visibility(); 156 | &.hidden-xs { 157 | @media (max-width: @screen-xs-max) { 158 | .responsive-invisibility(); 159 | } 160 | } 161 | &.hidden-sm { 162 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 163 | .responsive-invisibility(); 164 | } 165 | } 166 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 167 | .responsive-invisibility(); 168 | } 169 | &.hidden-lg { 170 | @media (min-width: @screen-lg-min) { 171 | .responsive-invisibility(); 172 | } 173 | } 174 | } 175 | .hidden-lg { 176 | .responsive-visibility(); 177 | &.hidden-xs { 178 | @media (max-width: @screen-xs-max) { 179 | .responsive-invisibility(); 180 | } 181 | } 182 | &.hidden-sm { 183 | @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { 184 | .responsive-invisibility(); 185 | } 186 | } 187 | &.hidden-md { 188 | @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { 189 | .responsive-invisibility(); 190 | } 191 | } 192 | @media (min-width: @screen-lg-min) { 193 | .responsive-invisibility(); 194 | } 195 | } 196 | 197 | // Print utilities 198 | .visible-print { 199 | .responsive-invisibility(); 200 | } 201 | 202 | @media print { 203 | .visible-print { 204 | .responsive-visibility(); 205 | } 206 | .hidden-print { 207 | .responsive-invisibility(); 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /Applications/Statistics/Modules/statistic.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright walkor 11 | * @link http://www.workerman.net/ 12 | * @license http://www.opensource.org/licenses/mit-license.php MIT License 13 | */ 14 | namespace Statistics\Modules; 15 | function statistic($module, $interface, $date, $start_time, $offset) 16 | { 17 | $err_msg = ''; 18 | $today = date('Y-m-d'); 19 | $time_now = time(); 20 | multiRequestStAndModules($module, $interface, $date); 21 | $all_st_str = ''; 22 | if(is_array(\Statistics\Lib\Cache::$statisticDataCache['statistic'])) 23 | { 24 | foreach(\Statistics\Lib\Cache::$statisticDataCache['statistic'] as $ip=>$st_str) 25 | { 26 | $all_st_str .= $st_str; 27 | } 28 | } 29 | 30 | $code_map = array(); 31 | $data = formatSt($all_st_str, $date, $code_map); 32 | $interface_name = "$module::$interface"; 33 | $success_series_data = $fail_series_data = $success_time_series_data = $fail_time_series_data = array(); 34 | $total_count = $fail_count = 0; 35 | foreach($data as $time_point=>$item) 36 | { 37 | if($item['total_count']) 38 | { 39 | $success_series_data[] = "[".($time_point*1000).",{$item['total_count']}]"; 40 | $total_count += $item['total_count']; 41 | } 42 | $fail_series_data[] = "[".($time_point*1000).",{$item['fail_count']}]"; 43 | $fail_count += $item['fail_count']; 44 | if($item['total_avg_time']) 45 | { 46 | $success_time_series_data[] = "[".($time_point*1000).",{$item['total_avg_time']}]"; 47 | } 48 | $fail_time_series_data[] = "[".($time_point*1000).",{$item['fail_avg_time']}]"; 49 | } 50 | $success_series_data = implode(',', $success_series_data); 51 | $fail_series_data = implode(',', $fail_series_data); 52 | $success_time_series_data = implode(',', $success_time_series_data); 53 | $fail_time_series_data = implode(',', $fail_time_series_data); 54 | 55 | unset($_GET['start_time'], $_GET['end_time'], $_GET['date'], $_GET['fn']); 56 | $query = http_build_query($_GET); 57 | 58 | // 删除末尾0的记录 59 | if($today == $date) 60 | { 61 | while(!empty($data) && ($item = end($data)) && $item['total_count'] == 0 && ($key = key($data)) && $time_now < $key) 62 | { 63 | unset($data[$key]); 64 | } 65 | } 66 | 67 | $table_data = $html_class = ''; 68 | if($data) 69 | { 70 | $first_line = true; 71 | foreach($data as $item) 72 | { 73 | if($first_line) 74 | { 75 | $first_line = false; 76 | if($item['total_count'] == 0) 77 | { 78 | continue; 79 | } 80 | } 81 | $html_class = 'class="danger"'; 82 | if($item['total_count'] == 0) 83 | { 84 | $html_class = ''; 85 | } 86 | elseif($item['precent']>=99.99) 87 | { 88 | $html_class = 'class="success"'; 89 | } 90 | elseif($item['precent']>=99) 91 | { 92 | $html_class = ''; 93 | } 94 | elseif($item['precent']>=98) 95 | { 96 | $html_class = 'class="warning"'; 97 | } 98 | $table_data .= "\n 99 | {$item['time']} 100 | {$item['total_count']} 101 | {$item['total_avg_time']} 102 | {$item['suc_count']} 103 | {$item['suc_avg_time']} 104 | ".($item['fail_count']>0?("{$item['fail_count']}"):$item['fail_count'])." 105 | {$item['fail_avg_time']} 106 | {$item['precent']}% 107 | 108 | "; 109 | } 110 | } 111 | 112 | // date btn 113 | $date_btn_str = ''; 114 | for($i=13;$i>=1;$i--) 115 | { 116 | $the_time = strtotime("-$i day"); 117 | $the_date = date('Y-m-d',$the_time); 118 | $html_the_date = $date == $the_date ? "$the_date" : $the_date; 119 | $date_btn_str .= ''.$html_the_date.''; 120 | if($i == 7) 121 | { 122 | $date_btn_str .= '
      '; 123 | } 124 | } 125 | $the_date = date('Y-m-d'); 126 | $html_the_date = $date == $the_date ? "$the_date" : $the_date; 127 | $date_btn_str .= ''.$html_the_date.''; 128 | 129 | $module_str =''; 130 | foreach(\Statistics\Lib\Cache::$modulesDataCache as $mod => $interfaces) 131 | { 132 | if($mod == 'WorkerMan') 133 | { 134 | continue; 135 | } 136 | $module_str .= '
    5. '.$mod.'
    6. '; 137 | if($module == $mod) 138 | { 139 | foreach ($interfaces as $if) 140 | { 141 | $module_str .= '
    7.   '.$if.'
    8. '; 142 | } 143 | } 144 | } 145 | 146 | if( \Statistics\Lib\Cache::$lastFailedIpArray) 147 | { 148 | $err_msg = '无法从以下数据源获取数据:'; 149 | foreach (\Statistics\Lib\Cache::$lastFailedIpArray as $ip) 150 | { 151 | $err_msg .= $ip.'::'.\Statistics\Config::$ProviderPort . ' '; 152 | } 153 | } 154 | 155 | include ST_ROOT . '/Views/header.tpl.php'; 156 | include ST_ROOT . '/Views/statistic.tpl.php'; 157 | include ST_ROOT . '/Views/footer.tpl.php'; 158 | } 159 | -------------------------------------------------------------------------------- /Applications/Statistics/Web/less/type.less: -------------------------------------------------------------------------------- 1 | // 2 | // Typography 3 | // -------------------------------------------------- 4 | 5 | 6 | // Body text 7 | // ------------------------- 8 | 9 | p { 10 | margin: 0 0 (@line-height-computed / 2); 11 | } 12 | .lead { 13 | margin-bottom: @line-height-computed; 14 | font-size: floor(@font-size-base * 1.15); 15 | font-weight: 200; 16 | line-height: 1.4; 17 | 18 | @media (min-width: @screen-sm-min) { 19 | font-size: (@font-size-base * 1.5); 20 | } 21 | } 22 | 23 | 24 | // Emphasis & misc 25 | // ------------------------- 26 | 27 | // Ex: 14px base font * 85% = about 12px 28 | small, 29 | .small { font-size: 85%; } 30 | 31 | // Undo browser default styling 32 | cite { font-style: normal; } 33 | 34 | // Contextual emphasis 35 | .text-muted { 36 | color: @text-muted; 37 | } 38 | .text-primary { 39 | color: @brand-primary; 40 | &:hover { 41 | color: darken(@brand-primary, 10%); 42 | } 43 | } 44 | .text-warning { 45 | color: @state-warning-text; 46 | &:hover { 47 | color: darken(@state-warning-text, 10%); 48 | } 49 | } 50 | .text-danger { 51 | color: @state-danger-text; 52 | &:hover { 53 | color: darken(@state-danger-text, 10%); 54 | } 55 | } 56 | .text-success { 57 | color: @state-success-text; 58 | &:hover { 59 | color: darken(@state-success-text, 10%); 60 | } 61 | } 62 | .text-info { 63 | color: @state-info-text; 64 | &:hover { 65 | color: darken(@state-info-text, 10%); 66 | } 67 | } 68 | 69 | // Alignment 70 | .text-left { text-align: left; } 71 | .text-right { text-align: right; } 72 | .text-center { text-align: center; } 73 | 74 | 75 | // Headings 76 | // ------------------------- 77 | 78 | h1, h2, h3, h4, h5, h6, 79 | .h1, .h2, .h3, .h4, .h5, .h6 { 80 | font-family: @headings-font-family; 81 | font-weight: @headings-font-weight; 82 | line-height: @headings-line-height; 83 | color: @headings-color; 84 | 85 | small, 86 | .small { 87 | font-weight: normal; 88 | line-height: 1; 89 | color: @headings-small-color; 90 | } 91 | } 92 | 93 | h1, 94 | h2, 95 | h3 { 96 | margin-top: @line-height-computed; 97 | margin-bottom: (@line-height-computed / 2); 98 | 99 | small, 100 | .small { 101 | font-size: 65%; 102 | } 103 | } 104 | h4, 105 | h5, 106 | h6 { 107 | margin-top: (@line-height-computed / 2); 108 | margin-bottom: (@line-height-computed / 2); 109 | 110 | small, 111 | .small { 112 | font-size: 75%; 113 | } 114 | } 115 | 116 | h1, .h1 { font-size: @font-size-h1; } 117 | h2, .h2 { font-size: @font-size-h2; } 118 | h3, .h3 { font-size: @font-size-h3; } 119 | h4, .h4 { font-size: @font-size-h4; } 120 | h5, .h5 { font-size: @font-size-h5; } 121 | h6, .h6 { font-size: @font-size-h6; } 122 | 123 | 124 | // Page header 125 | // ------------------------- 126 | 127 | .page-header { 128 | padding-bottom: ((@line-height-computed / 2) - 1); 129 | margin: (@line-height-computed * 2) 0 @line-height-computed; 130 | border-bottom: 1px solid @page-header-border-color; 131 | } 132 | 133 | 134 | 135 | // Lists 136 | // -------------------------------------------------- 137 | 138 | // Unordered and Ordered lists 139 | ul, 140 | ol { 141 | margin-top: 0; 142 | margin-bottom: (@line-height-computed / 2); 143 | ul, 144 | ol { 145 | margin-bottom: 0; 146 | } 147 | } 148 | 149 | // List options 150 | 151 | // Unstyled keeps list items block level, just removes default browser padding and list-style 152 | .list-unstyled { 153 | padding-left: 0; 154 | list-style: none; 155 | } 156 | 157 | // Inline turns list items into inline-block 158 | .list-inline { 159 | .list-unstyled(); 160 | 161 | > li { 162 | display: inline-block; 163 | padding-left: 5px; 164 | padding-right: 5px; 165 | 166 | &:first-child { 167 | padding-left: 0; 168 | } 169 | } 170 | } 171 | 172 | // Description Lists 173 | dl { 174 | margin-bottom: @line-height-computed; 175 | } 176 | dt, 177 | dd { 178 | line-height: @line-height-base; 179 | } 180 | dt { 181 | font-weight: bold; 182 | } 183 | dd { 184 | margin-left: 0; // Undo browser default 185 | } 186 | 187 | // Horizontal description lists 188 | // 189 | // Defaults to being stacked without any of the below styles applied, until the 190 | // grid breakpoint is reached (default of ~768px). 191 | 192 | @media (min-width: @grid-float-breakpoint) { 193 | .dl-horizontal { 194 | dt { 195 | float: left; 196 | width: (@component-offset-horizontal - 20); 197 | clear: left; 198 | text-align: right; 199 | .text-overflow(); 200 | } 201 | dd { 202 | margin-left: @component-offset-horizontal; 203 | .clearfix(); // Clear the floated `dt` if an empty `dd` is present 204 | } 205 | } 206 | } 207 | 208 | // MISC 209 | // ---- 210 | 211 | // Abbreviations and acronyms 212 | abbr[title], 213 | // Add data-* attribute to help out our tooltip plugin, per https://github.com/twbs/bootstrap/issues/5257 214 | abbr[data-original-title] { 215 | cursor: help; 216 | border-bottom: 1px dotted @abbr-border-color; 217 | } 218 | abbr.initialism { 219 | font-size: 90%; 220 | text-transform: uppercase; 221 | } 222 | 223 | // Blockquotes 224 | blockquote { 225 | padding: (@line-height-computed / 2) @line-height-computed; 226 | margin: 0 0 @line-height-computed; 227 | border-left: 5px solid @blockquote-border-color; 228 | p { 229 | font-size: (@font-size-base * 1.25); 230 | font-weight: 300; 231 | line-height: 1.25; 232 | } 233 | p:last-child { 234 | margin-bottom: 0; 235 | } 236 | small { 237 | display: block; 238 | line-height: @line-height-base; 239 | color: @blockquote-small-color; 240 | &:before { 241 | content: '\2014 \00A0'; // EM DASH, NBSP 242 | } 243 | } 244 | 245 | // Float right with text-align: right 246 | &.pull-right { 247 | padding-right: 15px; 248 | padding-left: 0; 249 | border-right: 5px solid @blockquote-border-color; 250 | border-left: 0; 251 | p, 252 | small, 253 | .small { 254 | text-align: right; 255 | } 256 | small, 257 | .small { 258 | &:before { 259 | content: ''; 260 | } 261 | &:after { 262 | content: '\00A0 \2014'; // NBSP, EM DASH 263 | } 264 | } 265 | } 266 | } 267 | 268 | // Quotes 269 | blockquote:before, 270 | blockquote:after { 271 | content: ""; 272 | } 273 | 274 | // Addresses 275 | address { 276 | margin-bottom: @line-height-computed; 277 | font-style: normal; 278 | line-height: @line-height-base; 279 | } 280 | -------------------------------------------------------------------------------- /Applications/ThriftRpc/Lib/Thrift/Transport/THttpClient.php: -------------------------------------------------------------------------------- 1 | strlen($uri) > 0) && ($uri{0} != '/')) { 101 | $uri = '/'.$uri; 102 | } 103 | $this->scheme_ = $scheme; 104 | $this->host_ = $host; 105 | $this->port_ = $port; 106 | $this->uri_ = $uri; 107 | $this->buf_ = ''; 108 | $this->handle_ = null; 109 | $this->timeout_ = null; 110 | $this->headers_ = array(); 111 | } 112 | 113 | /** 114 | * Set read timeout 115 | * 116 | * @param float $timeout 117 | */ 118 | public function setTimeoutSecs($timeout) { 119 | $this->timeout_ = $timeout; 120 | } 121 | 122 | /** 123 | * Whether this transport is open. 124 | * 125 | * @return boolean true if open 126 | */ 127 | public function isOpen() { 128 | return true; 129 | } 130 | 131 | /** 132 | * Open the transport for reading/writing 133 | * 134 | * @throws TTransportException if cannot open 135 | */ 136 | public function open() {} 137 | 138 | /** 139 | * Close the transport. 140 | */ 141 | public function close() { 142 | if ($this->handle_) { 143 | @fclose($this->handle_); 144 | $this->handle_ = null; 145 | } 146 | } 147 | 148 | /** 149 | * Read some data into the array. 150 | * 151 | * @param int $len How much to read 152 | * @return string The data that has been read 153 | * @throws TTransportException if cannot read any more data 154 | */ 155 | public function read($len) { 156 | $data = @fread($this->handle_, $len); 157 | if ($data === FALSE || $data === '') { 158 | $md = stream_get_meta_data($this->handle_); 159 | if ($md['timed_out']) { 160 | throw new TTransportException('THttpClient: timed out reading '.$len.' bytes from '.$this->host_.':'.$this->port_.$this->uri_, TTransportException::TIMED_OUT); 161 | } else { 162 | throw new TTransportException('THttpClient: Could not read '.$len.' bytes from '.$this->host_.':'.$this->port_.$this->uri_, TTransportException::UNKNOWN); 163 | } 164 | } 165 | return $data; 166 | } 167 | 168 | /** 169 | * Writes some data into the pending buffer 170 | * 171 | * @param string $buf The data to write 172 | * @throws TTransportException if writing fails 173 | */ 174 | public function write($buf) { 175 | $this->buf_ .= $buf; 176 | } 177 | 178 | /** 179 | * Opens and sends the actual request over the HTTP connection 180 | * 181 | * @throws TTransportException if a writing error occurs 182 | */ 183 | public function flush() { 184 | // God, PHP really has some esoteric ways of doing simple things. 185 | $host = $this->host_.($this->port_ != 80 ? ':'.$this->port_ : ''); 186 | 187 | $headers = array(); 188 | $defaultHeaders = array('Host' => $host, 189 | 'Accept' => 'application/x-thrift', 190 | 'User-Agent' => 'PHP/THttpClient', 191 | 'Content-Type' => 'application/x-thrift', 192 | 'Content-Length' => TStringFuncFactory::create()->strlen($this->buf_)); 193 | foreach (array_merge($defaultHeaders, $this->headers_) as $key => $value) { 194 | $headers[] = "$key: $value"; 195 | } 196 | 197 | $options = array('method' => 'POST', 198 | 'header' => implode("\r\n", $headers), 199 | 'max_redirects' => 1, 200 | 'content' => $this->buf_); 201 | if ($this->timeout_ > 0) { 202 | $options['timeout'] = $this->timeout_; 203 | } 204 | $this->buf_ = ''; 205 | 206 | $contextid = stream_context_create(array('http' => $options)); 207 | $this->handle_ = @fopen($this->scheme_.'://'.$host.$this->uri_, 'r', false, $contextid); 208 | 209 | // Connect failed? 210 | if ($this->handle_ === FALSE) { 211 | $this->handle_ = null; 212 | $error = 'THttpClient: Could not connect to '.$host.$this->uri_; 213 | throw new TTransportException($error, TTransportException::NOT_OPEN); 214 | } 215 | } 216 | 217 | public function addHeaders($headers) { 218 | $this->headers_ = array_merge($this->headers_, $headers); 219 | } 220 | 221 | } 222 | --------------------------------------------------------------------------------