From c2c0a8dde1261f684b42c6a22481e10bcdd954e8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sat, 24 Sep 2016 16:32:31 +0200 Subject: [PATCH] Backup --- app.js | 9 ++++ cli.php | 2 +- configure.php | 8 ++-- forms/admin/photos/photos.js | 13 +++--- forms/cms/contact/contact.js | 13 +++--- forms/ecomerce/catalog/ui.xml | 1 + forms/ecomerce/orders/ui.xml | 4 +- forms/news/news/ui.xml | 3 +- image/icon/dark/logo.png | Bin 3929 -> 0 bytes image/{icon/dark/logo.svg => logo-dark.svg} | 0 index.php | 2 +- js/db/{conn.js => connection.js} | 18 +++++--- js/db/main.js | 2 +- js/db/model.js | 2 +- js/hedera/app.js | 40 ++++++++++------- js/hedera/gui.js | 2 +- js/hedera/gui.xml | 28 ++++++------ js/hedera/login.js | 16 ++++--- js/hedera/login.xml | 27 +----------- js/hedera/tpv.js | 13 +++--- js/htk/column/image.js | 10 ++++- js/htk/field/button.js | 4 +- js/htk/field/image.js | 9 +++- js/htk/image-editor.js | 21 ++++++--- js/vn/json-connection.js | 25 ++++++++--- package.json | 9 ++++ pages/main/head.php | 4 +- pages/main/main.js | 16 ------- pages/tpv/html.php | 2 +- pages/update-browser/html.php | 4 +- pages/version-menu/html.php | 6 +-- rest/core/captcha.php | 1 - rest/core/log.php | 2 - rest/core/login.php | 19 +++++---- rest/core/logout.php | 4 +- rest/core/query.php | 20 ++++----- rest/core/recover-password.php | 2 - rest/dms/add.php | 2 - rest/dms/invoice.php | 6 +-- rest/edi/clean.php | 2 +- rest/image/resize.php | 1 - rest/image/sync.php | 1 - rest/image/thumb.php | 1 - rest/image/upload.php | 1 - rest/misc/contact.php | 1 - rest/misc/exchange-rate.php | 2 - rest/misc/mail.php | 1 - rest/misc/sms.php | 2 - rest/misc/visits-sync.php | 2 - rest/tpv/confirm-mail.php | 1 - rest/tpv/confirm-post.php | 1 - rest/tpv/confirm-soap.php | 1 - rest/tpv/soap-test.php | 2 - rest/tpv/transaction.php | 2 - vn/web/util.php | 42 ------------------ {vn/web => web}/app.php | 4 +- {vn/web => web}/db-session-handler.php | 0 {vn/web => web}/html-service.php | 3 +- {vn/web => web}/json-exception.php | 0 {vn/web => web}/json-reply.php | 2 - {vn/web => web}/json-request.php | 3 -- {vn/web => web}/json-service.php | 4 -- {vn/web => web}/jwt.php | 2 +- {vn/web => web}/rest-request.php | 4 +- {vn/web => web}/rest-service.php | 3 -- {vn/web => web}/service.php | 42 ++++++++++++------ {vn/web => web}/unavailable.html | 0 web/util.php | 45 ++++++++++++++++++++ webpack.config.js | 12 ++++++ webpack.sh | 4 ++ 70 files changed, 287 insertions(+), 273 deletions(-) create mode 100644 app.js delete mode 100644 image/icon/dark/logo.png rename image/{icon/dark/logo.svg => logo-dark.svg} (100%) rename js/db/{conn.js => connection.js} (81%) create mode 100644 package.json delete mode 100644 pages/main/main.js delete mode 100644 vn/web/util.php rename {vn/web => web}/app.php (97%) rename {vn/web => web}/db-session-handler.php (100%) rename {vn/web => web}/html-service.php (98%) rename {vn/web => web}/json-exception.php (100%) rename {vn/web => web}/json-reply.php (83%) rename {vn/web => web}/json-request.php (57%) rename {vn/web => web}/json-service.php (94%) rename {vn/web => web}/jwt.php (97%) rename {vn/web => web}/rest-request.php (84%) rename {vn/web => web}/rest-service.php (92%) rename {vn/web => web}/service.php (86%) rename {vn/web => web}/unavailable.html (100%) create mode 100644 web/util.php create mode 100644 webpack.config.js create mode 100755 webpack.sh diff --git a/app.js b/app.js new file mode 100644 index 00000000..5009b804 --- /dev/null +++ b/app.js @@ -0,0 +1,9 @@ + +//Vn.includeCss ('pages/main/style.css'); + +var Hedera = require ('./js/hedera/main'); +var App = require ('./js/hedera/app'); + +hederaWeb = new App (); +hederaWeb.run (); +window.hederaWeb = hederaWeb; diff --git a/cli.php b/cli.php index e626490c..acc4bd45 100755 --- a/cli.php +++ b/cli.php @@ -1,6 +1,6 @@ run (); diff --git a/configure.php b/configure.php index cd206f86..74e1f384 100644 --- a/configure.php +++ b/configure.php @@ -2,11 +2,9 @@ require_once (__DIR__.'/../php-vn-lib/configure.php'); -set_include_path -( - get_include_path () - .PATH_SEPARATOR.__DIR__ -); +set_include_path (__DIR__.PATH_SEPARATOR.get_include_path ()); + +$vnAutoloadMap['vn/web'] = __DIR__.'/web'; const _DEBUG_MODE = TRUE; const _CONFIG_DIR = '/home/juan/.config'; diff --git a/forms/admin/photos/photos.js b/forms/admin/photos/photos.js index a391a31d..e158aad2 100644 --- a/forms/admin/photos/photos.js +++ b/forms/admin/photos/photos.js @@ -10,23 +10,20 @@ Vn.Photos = new Class var self = this; this.$('html-form').onsubmit = function () - { self.onSubmit (); return false; }; + { self._onSubmit (); return false; }; } - ,onSubmit: function () + ,_onSubmit: function () { this.$('schema-field').value = this.$('schema').value; this.$('submit').disabled = true; - this.gui.loaderPush (); - var request = new Vn.JsonRequest (); - request.sendFormMultipart (this.$('html-form'), - this.onResponse.bind (this)); + this.conn.sendFormMultipart (this.$('html-form'), + this._onResponse.bind (this)); } - ,onResponse: function (request, json, error) + ,_onResponse: function (request, json, error) { - this.gui.loaderPop (); this.$('submit').disabled = false; if (json) diff --git a/forms/cms/contact/contact.js b/forms/cms/contact/contact.js index 8dee47e2..c95892a8 100644 --- a/forms/cms/contact/contact.js +++ b/forms/cms/contact/contact.js @@ -7,7 +7,7 @@ Vn.Contact = new Class { var self = this; this.$('contact-form').onsubmit = function () - { self.onSubmit (); return false; }; + { self._onSubmit (); return false; }; this.refreshCaptcha (); } @@ -19,18 +19,15 @@ Vn.Contact = new Class 'stamp': new Date ().getTime () }; this.$('captcha-img').src = '?'+ Vn.Url.makeUri (params); - - Vn.Url.makeUri (params) } - ,onSubmit: function () + ,_onSubmit: function () { - var request = new Vn.JsonRequest (); - request.sendForm (this.$('contact-form'), - this.onResponse.bind (this)); + this.conn.sendForm (this.$('contact-form'), + this._onResponse.bind (this)); } - ,onResponse: function (request, json, error) + ,_onResponse: function (json, error) { var form = this.$('contact-form'); diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index dc0eb5ce..4722fd6b 100755 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -152,6 +152,7 @@ directory="catalog" subdir="200x200" form="item" + conn="conn" column="Foto" full-dir="900x900"/>
diff --git a/forms/ecomerce/orders/ui.xml b/forms/ecomerce/orders/ui.xml index d3fb343a..b8f53fa1 100755 --- a/forms/ecomerce/orders/ui.xml +++ b/forms/ecomerce/orders/ui.xml @@ -15,11 +15,13 @@
@@ -37,7 +39,7 @@ Info diff --git a/forms/news/news/ui.xml b/forms/news/news/ui.xml index 8724e636..cf11a2c7 100755 --- a/forms/news/news/ui.xml +++ b/forms/news/news/ui.xml @@ -40,7 +40,8 @@ directory="news" subdir="200x200" full-dir="full" - editable="true"/> + editable="true" + conn="conn"/>

diff --git a/image/icon/dark/logo.png b/image/icon/dark/logo.png deleted file mode 100644 index 6c4853523e46d0ff83f166b9ad0a033c0dca0fc8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3929 zcmV-f52o;mP)X1^@s6oVwIM00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2j2)2 z3IG65_cA;H01nwnL_t(|+U=ZskX6-{#(!(y+duqJQmF3G2hbL{b*^xL z|1V{iEbs*IFGk%2RqZVzpQqeE#RF=91;@esRC%s1kAJCCDuHT+u2y4#uK`b{y(kA) zIT&VCZ9dkZUZPwra8>fUgI~=Q)*lbRcEF<0Fqoj9RO0^2JlD61$oAu4eujCj|0FSq z6YzjK0`|nTm((de9gOx=KmEV3=re(F$xjY;9xoQ#iOBoF>nRpFtz7Q8zWC35VpMe! zP+?T<7m+;);7(3^mcT?+Tnf<62Qro+Z-uqTa$GBv6BI@nRXc0sI0AO`Z>^_(YRbY7 z15UH5fQ84w+V*NsvX8#n@C~9@x-y?zz&T1 zA*%YtPSTJD5&5WuHSDRXV^wvos$Q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js/db/connection.js index 3cb637af..b18e99be 100644 --- a/js/db/conn.js +++ b/js/db/connection.js @@ -1,10 +1,14 @@ /** - * Simulates a connection to a database by making asynchronous http requests to - * a remote PHP script that returns the results in JSON format. + * Simulates a connection to a database by making asynchronous requests to a + * remote REST service that returns the results in JSON format. * Using this class can perform any operation that can be done with a database, * like open/close a connection or selecion/updating queries. + * + * Warning! You should set a well defined dababase level privileges to use this + * class or you could have a serious security hole in you application becasuse + * the user can send any statement to the server. For example: DROP DATABASE **/ -Db.Conn = new Class ().extend +Db.Connection = new Class ().extend ({ Flag: { @@ -24,7 +28,7 @@ Db.Conn = new Class ().extend } }); -Db.Conn.implement +Db.Connection.implement ({ Extends: Vn.JsonConnection @@ -92,9 +96,9 @@ Db.Conn.implement switch (columns[j].type) { - case Db.Conn.Type.DATE: - case Db.Conn.Type.DATE_TIME: - case Db.Conn.Type.TIMESTAMP: + case Db.Connection.Type.DATE: + case Db.Connection.Type.DATE_TIME: + case Db.Connection.Type.TIMESTAMP: castFunc = this.valueToDate; break; } diff --git a/js/db/main.js b/js/db/main.js index 16692b54..2897d938 100644 --- a/js/db/main.js +++ b/js/db/main.js @@ -3,7 +3,7 @@ Vn.include ('js/sql/main'); Vn.includeLib ('db', [ 'db' - ,'conn' + ,'connection' ,'result' ,'result-set' ,'model' diff --git a/js/db/model.js b/js/db/model.js index 3afde179..f610a297 100644 --- a/js/db/model.js +++ b/js/db/model.js @@ -45,7 +45,7 @@ Db.Model.implement **/ conn: { - type: Db.Conn + type: Db.Connection ,set: function (x) { this._conn = x; diff --git a/js/hedera/app.js b/js/hedera/app.js index 61a3adda..ecbeb266 100644 --- a/js/hedera/app.js +++ b/js/hedera/app.js @@ -1,7 +1,18 @@ Vn.App = new Class ({ - Extends: Vn.Object + Extends: Vn.Object, + Properties: + { + conn: + { + type: Db.Connection + ,get: function () + { + return this._conn; + } + } + } ,initialize: function () { @@ -16,18 +27,18 @@ Vn.App = new Class }); this._isGuest.on ('changed', this._onGuestChange, this); - var conn = new Db.Conn (); + var conn = new Db.Connection (); this.link ({_conn: conn}, {'error': this._onConnError}); } ,run: function () { - var guest = Vn.Cookie.check ('hedera_guest'); + var guest = localStorage.getItem ('hederaGuest'); if (guest) - Vn.Cookie.unset ('hedera_guest'); + localStorage.removeItem ('hederaGuest'); - if (Vn.Cookie.check ('vn_pass')) + if (localStorage.getItem ('vnToken')) { this._conn.open (null, null, null, this._onAutoLogin.bind (this)); @@ -67,7 +78,7 @@ Vn.App = new Class if (success) { - Vn.Cookie.set ('hedera_guest', true); + localStorage.setItem ('hederaGuest', true); this._onLogin (); } else @@ -77,10 +88,7 @@ Vn.App = new Class ,_onAutoLogin: function (success) { if (!success) - { - Vn.Cookie.unset ('vn_pass'); this.run (); - } else this._onLogin (); } @@ -97,8 +105,7 @@ Vn.App = new Class ,_onLogout: function (gui) { this._freeGui (); - Vn.Cookie.unset ('hedera_guest'); - Vn.Cookie.unset ('vn_pass'); + localStorage.removeItem ('hederaGuest'); this.run (); } @@ -119,10 +126,13 @@ Vn.App = new Class { if (error instanceof Vn.JsonException) { - var exception = error.exception - .replace (/\\/g, '.') - .replace (/Exception$/, '') - .replace (/^Vn\.Web\./, ''); + if (error.exception) + var exception = error.exception + .replace (/\\/g, '.') + .replace (/Exception$/, '') + .replace (/^Vn\.Web\./, ''); + else + var exception = null; switch (exception) { diff --git a/js/hedera/gui.js b/js/hedera/gui.js index b28a5fda..75f1903e 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -9,7 +9,7 @@ Vn.Gui = new Class { conn: { - type: Db.Conn + type: Db.Connection ,set: function (x) { this.link ({_conn: x}, diff --git a/js/hedera/gui.xml b/js/hedera/gui.xml index 2576bf32..0a825ded 100755 --- a/js/hedera/gui.xml +++ b/js/hedera/gui.xml @@ -11,10 +11,10 @@
diff --git a/js/hedera/login.js b/js/hedera/login.js index 2e640484..149e19fa 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -10,12 +10,13 @@ Vn.Login = new Class { conn: { - type: Db.Conn + type: Db.Connection ,set: function (x) { this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange}); x.execQuery ( - 'SELECT title, link, icon FROM social ORDER BY priority', + 'SELECT title, link, icon FROM social ' + +'WHERE priority ORDER BY priority', this._onSocialQueryDone.bind (this)); } ,get: function () @@ -60,8 +61,10 @@ Vn.Login = new Class { document.body.appendChild (this.node); - if (Vn.Cookie.check ('vn_user')) - this.$('user').value = Vn.Cookie.get ('vn_user'); + var lastUser = localStorage.getItem ('hederaLastUser'); + + if (lastUser) + this.$('user').value = lastUser; this._focusUserInput (); } @@ -93,7 +96,10 @@ Vn.Login = new Class this.$('pass').value = ''; if (success) + { + localStorage.setItem ('hederaLastUser', this.$('user').value); this.signalEmit ('login'); + } else this._focusUserInput (); } @@ -130,7 +136,7 @@ Vn.Login = new Class social.appendChild (a); var img = document.createElement ('img'); - imt.src = 'image/social/'+ res.get ('icon'); + img.src = 'image/social/'+ res.get ('icon'); img.alt = res.get ('title'); img.title = res.get ('title'); a.appendChild (img); diff --git a/js/hedera/login.xml b/js/hedera/login.xml index 2f2d2014..ed3f51c8 100755 --- a/js/hedera/login.xml +++ b/js/hedera/login.xml @@ -50,32 +50,7 @@