diff --git a/composer.json b/composer.json index 4df0562..96c4fb4 100755 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "require": { "matyhtf/framework": ">=3.0.0", "symfony/console": "^4.3", - "swoole/ide-helper": "~4.4.7" + "swoole/ide-helper": "~4.4.7", + "ext-json": "*" } } diff --git a/configs/db.php b/configs/db.php index 3a377c1..ad78d15 100755 --- a/configs/db.php +++ b/configs/db.php @@ -1,14 +1,14 @@ SPF\Database::TYPE_MYSQLi, - 'host' => "127.0.0.1", + 'host' => "mysql", 'port' => 3306, 'dbms' => 'mysql', - 'engine' => 'MyISAM', + 'engine' => 'InnoDB', 'user' => "root", 'password' => "root", 'database' => "webim", - 'charset' => "utf8", + 'charset' => "utf8mb4", 'setname' => true, 'persistent' => false, //MySQL长连接 ); diff --git a/configs/login.php b/configs/login.php index 7000880..375e7f5 100755 --- a/configs/login.php +++ b/configs/login.php @@ -1,6 +1,6 @@ BASE_URL . '/api/get_user_info/', - 'passport' => BASE_URL.'/page/login/', + 'get_user_info' => BASE_URL . '/api/get_user_info', + 'passport' => BASE_URL.'/page/login', ); \ No newline at end of file diff --git a/configs/redis.php b/configs/redis.php index b62bace..d01a61c 100755 --- a/configs/redis.php +++ b/configs/redis.php @@ -1,5 +1,5 @@ '127.0.0.1', + 'host' => 'redis', ); return $redis; \ No newline at end of file diff --git a/configs/webim.php b/configs/webim.php index 814e5df..00868e7 100755 --- a/configs/webim.php +++ b/configs/webim.php @@ -1,13 +1,13 @@ '127.0.0.1', + 'host' => '0.0.0.0', //监听的端口 'port' => '9503', //WebSocket的URL地址,供浏览器使用的 'url' => 'ws://127.0.0.1:9503', //用于Comet跨域,必须设置为html所在的URL - 'origin' => 'http://im.swoole.com:8888', + 'origin' => 'http://127.0.0.1:9503', ); $config['swoole'] = array( diff --git a/resources/static/facebox/README.txt b/resources/static/facebox/README.txt new file mode 100644 index 0000000..56bf703 --- /dev/null +++ b/resources/static/facebox/README.txt @@ -0,0 +1,23 @@ +Facebox for Prototype, version 2.0 +By Robert Gaal - http://wakoopa.com +-------------------------------------------------------------------------- + +Heavily based on Facebox by Chris Wanstrath - http://famspam.com/facebox +First ported to Prototype by Phil Burrows - http://blog.philburrows.com + +Licensed under the MIT: +http://www.opensource.org/licenses/mit-license.php + +Need help? Join the Google Groups mailing list: +http://groups.google.com/group/facebox/ + +-------------------------------------------------------------------------- + +Dependencies: prototype & script.aculo.us + images & CSS files from original facebox +Usage: Append 'rel="facebox"' to an element to call it inside a so-called facebox. + + You can also call it directly through the following code: + + facebox.loading(); + facebox.reveal('Facebox contents here', null); + new Effect.Appear(facebox.facebox, {duration: .3}); \ No newline at end of file diff --git a/resources/static/facebox/b.png b/resources/static/facebox/b.png new file mode 100644 index 0000000..f184e62 Binary files /dev/null and b/resources/static/facebox/b.png differ diff --git a/resources/static/facebox/bl.png b/resources/static/facebox/bl.png new file mode 100644 index 0000000..f627185 Binary files /dev/null and b/resources/static/facebox/bl.png differ diff --git a/resources/static/facebox/br.png b/resources/static/facebox/br.png new file mode 100644 index 0000000..31f204f Binary files /dev/null and b/resources/static/facebox/br.png differ diff --git a/resources/static/facebox/closelabel.gif b/resources/static/facebox/closelabel.gif new file mode 100755 index 0000000..87b4f8b Binary files /dev/null and b/resources/static/facebox/closelabel.gif differ diff --git a/resources/static/facebox/facebox.css b/resources/static/facebox/facebox.css new file mode 100644 index 0000000..1529036 --- /dev/null +++ b/resources/static/facebox/facebox.css @@ -0,0 +1,95 @@ +#facebox .b { + background:url(b.png); +} + +#facebox .tl { + background:url(tl.png); +} + +#facebox .tr { + background:url(tr.png); +} + +#facebox .bl { + background:url(bl.png); +} + +#facebox .br { + background:url(br.png); +} + +#facebox { + position: absolute; + top: 0; + left: 0; + z-index: 100; + text-align: left; +} + +#facebox .popup { + position: relative; +} + +#facebox table { + border-collapse: collapse; +} + +#facebox td { + border-bottom: 0; + padding: 0; +} + +#facebox .body { + padding: 10px; + background: #fff; + width: 370px; +} + +#facebox .loading { + text-align: center; +} + +#facebox .image { + text-align: center; +} + +#facebox img { + border: 0; + margin: 0; +} + +#facebox .footer { + border-top: 1px solid #DDDDDD; + padding-top: 5px; + margin-top: 10px; + text-align: right; +} + +#facebox .tl, #facebox .tr, #facebox .bl, #facebox .br { + height: 10px; + width: 10px; + overflow: hidden; + padding: 0; +} + +#facebox_overlay { + position: fixed; + top: 0px; + left: 0px; + height:100%; + width:100%; +} + +.facebox_hide { + z-index:-100; +} + +.facebox_overlayBG { + background-color: #000; + z-index: 99; +} + +* html #facebox_overlay { /* ie6 hack */ + position: absolute; + height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); +} diff --git a/resources/static/facebox/facebox.js b/resources/static/facebox/facebox.js new file mode 100644 index 0000000..43dafa6 --- /dev/null +++ b/resources/static/facebox/facebox.js @@ -0,0 +1,189 @@ +/* Facebox for Prototype, version 2.0 + * By Robert Gaal - http://wakoopa.com + * + * Heavily based on Facebox by Chris Wanstrath - http://famspam.com/facebox + * First ported to Prototype by Phil Burrows - http://blog.philburrows.com + * + * Licensed under the MIT: + * http://www.opensource.org/licenses/mit-license.php + * + * Need help? Join the Google Groups mailing list: + * http://groups.google.com/group/facebox/ + * + * Dependencies: prototype & script.aculo.us + images & CSS files from original facebox + * Usage: Append 'rel="facebox"' to an element to call it inside a so-called facebox + * + *--------------------------------------------------------------------------*/ + + +var Facebox = Class.create({ + initialize : function(extra_set){ + this.settings = { + loading_image : '/facebox/loading.gif', + close_image : '/facebox/closelabel.gif', + image_types : new RegExp('\.' + ['png', 'jpg', 'jpeg', 'gif'].join('|') + '$', 'i'), + inited : true, + facebox_html : '\ +
' + }; + if (extra_set) Object.extend(this.settings, extra_set); + $(document.body).insert({bottom: this.settings.facebox_html}); + + this.preload = [ new Image(), new Image() ]; + this.preload[0].src = this.settings.close_image; + this.preload[1].src = this.settings.loading_image; + + f = this; + $$('#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr').each(function(elem){ + f.preload.push(new Image()); + f.preload.slice(-1).src = elem.getStyle('background-image').replace(/url\((.+)\)/, '$1'); + }); + + this.facebox = $('facebox'); + this.keyPressListener = this.watchKeyPress.bindAsEventListener(this); + + this.watchClickEvents(); + fb = this; + Event.observe($$('#facebox .close').first(), 'click', function(e){ + Event.stop(e); + fb.close() + }); + Event.observe($$('#facebox .close_image').first(), 'click', function(e){ + Event.stop(e); + fb.close() + }); + }, + + watchKeyPress : function(e){ + // Close if espace is pressed or if there's a click outside of the facebox + if (e.keyCode == 27 || !Event.element(e).descendantOf(this.facebox)) this.close(); + }, + + watchClickEvents : function(e){ + var f = this; + $$('a[rel=facebox]').each(function(elem,i){ + Event.observe(elem, 'click', function(e){ + Event.stop(e); + f.click_handler(elem, e); + }); + }); + }, + + loading : function() { + if ($$('#facebox .loading').length == 1) return true; + + contentWrapper = $$('#facebox .content').first(); + contentWrapper.childElements().each(function(elem, i){ + elem.remove(); + }); + contentWrapper.insert({bottom: ''}); + + var pageScroll = document.viewport.getScrollOffsets(); + this.facebox.setStyle({ + 'top': pageScroll.top + (document.viewport.getHeight() / 10) + 'px', + 'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px' + }); + + Event.observe(document, 'keypress', this.keyPressListener); + Event.observe(document, 'click', this.keyPressListener); + }, + + reveal : function(data, klass){ + this.loading(); + load = $$('#facebox .loading').first(); + if(load) load.remove(); + + contentWrapper = $$('#facebox .content').first(); + if (klass) contentWrapper.addClassName(klass); + contentWrapper.insert({bottom: data}); + + $$('#facebox .body').first().childElements().each(function(elem,i){ + elem.show(); + }); + + if(!this.facebox.visible()) new Effect.Appear(this.facebox, {duration: .3}); + this.facebox.setStyle({ + 'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px' + }); + + Event.observe(document, 'keypress', this.keyPressListener); + Event.observe(document, 'click', this.keyPressListener); + }, + + close : function(){ + new Effect.Fade('facebox', {duration: .3}); + }, + + click_handler : function(elem, e){ + this.loading(); + Event.stop(e); + + // support for rel="facebox[.inline_popup]" syntax, to add a class + var klass = elem.rel.match(/facebox\[\.(\w+)\]/); + if (klass) klass = klass[1]; + + new Effect.Appear(this.facebox, {duration: .3}); + + if (elem.href.match(/#/)){ + var url = window.location.href.split('#')[0]; + var target = elem.href.replace(url+'#',''); + // var data = $$(target).first(); + var d = $(target); + // create a new element so as to not delete the original on close() + var data = new Element(d.tagName); + data.innerHTML = d.innerHTML; + this.reveal(data, klass); + } else if (elem.href.match(this.settings.image_types)) { + var image = new Image(); + fb = this; + image.onload = function() { + fb.reveal('', klass) + } + image.src = elem.href; + } else { + var fb = this; + var url = elem.href; + new Ajax.Request(url, { + method : 'get', + onFailure : function(transport){ + fb.reveal(transport.responseText, klass); + }, + onSuccess : function(transport){ + fb.reveal(transport.responseText, klass); + } + }); + + } + } +}); + +var facebox; +document.observe('dom:loaded', function(){ + facebox = new Facebox(); +}); \ No newline at end of file diff --git a/resources/static/facebox/loading.gif b/resources/static/facebox/loading.gif new file mode 100755 index 0000000..f864d5f Binary files /dev/null and b/resources/static/facebox/loading.gif differ diff --git a/resources/static/facebox/tl.png b/resources/static/facebox/tl.png new file mode 100644 index 0000000..d99c8f6 Binary files /dev/null and b/resources/static/facebox/tl.png differ diff --git a/resources/static/facebox/tr.png b/resources/static/facebox/tr.png new file mode 100644 index 0000000..e99b6ec Binary files /dev/null and b/resources/static/facebox/tr.png differ diff --git a/resources/static/js/chat.js b/resources/static/js/chat.js index 3e4a0ae..0dfd7e9 100755 --- a/resources/static/js/chat.js +++ b/resources/static/js/chat.js @@ -3,7 +3,6 @@ var client_id = 0; var userlist = {}; var GET = getRequest(); var face_count = 19; - $(document).ready(function() { //使用原生WebSocket //if (false) diff --git a/resources/static/js/test.js b/resources/static/js/test.js new file mode 100644 index 0000000..17aa9fe --- /dev/null +++ b/resources/static/js/test.js @@ -0,0 +1,33 @@ +// function Person() { +// +// } +// Person.prototype.name = 'Kevin'; +// Person.name1 = 'Kevin1'; +// var person = new Person(); +// person.name = 'Daisy'; +// +// console.log(Person.__proto__) +// console.log(person.__proto__.name) +// console.log(Person.prototype.__proto__.__proto__) +// console.log(person.name); +// delete person.name; +// console.log(person.name); +// console.log(Person === Person.prototype.constructor); +// console.log(person.__proto__.constructor == Person); +function DOMEval( code, doc, node ) { + doc = doc || document; + + var i, + script = doc.createElement( "script" ); + + script.text = code; + if ( node ) { + for ( i in preservedScriptAttributes ) { + if ( node[ i ] ) { + script[ i ] = node[ i ]; + } + } + } + doc.head.appendChild( script ).parentNode.removeChild( script ); +} +DOMEval('console.log("dd")'); \ No newline at end of file diff --git a/resources/templates/chatroom.php b/resources/templates/chatroom.php index cc42bf0..0df95e0 100755 --- a/resources/templates/chatroom.php +++ b/resources/templates/chatroom.php @@ -1,174 +1,175 @@ - -