Backup
This commit is contained in:
parent
ee3e4cf041
commit
c2c0a8dde1
|
@ -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;
|
2
cli.php
2
cli.php
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/lib/cli-app.php');
|
require_once 'vn-autoload.php';
|
||||||
|
|
||||||
$cliApp = new Vn\Lib\CliApp ('hedera-web', __DIR__.'/rest');
|
$cliApp = new Vn\Lib\CliApp ('hedera-web', __DIR__.'/rest');
|
||||||
$cliApp->run ();
|
$cliApp->run ();
|
||||||
|
|
|
@ -2,11 +2,9 @@
|
||||||
|
|
||||||
require_once (__DIR__.'/../php-vn-lib/configure.php');
|
require_once (__DIR__.'/../php-vn-lib/configure.php');
|
||||||
|
|
||||||
set_include_path
|
set_include_path (__DIR__.PATH_SEPARATOR.get_include_path ());
|
||||||
(
|
|
||||||
get_include_path ()
|
$vnAutoloadMap['vn/web'] = __DIR__.'/web';
|
||||||
.PATH_SEPARATOR.__DIR__
|
|
||||||
);
|
|
||||||
|
|
||||||
const _DEBUG_MODE = TRUE;
|
const _DEBUG_MODE = TRUE;
|
||||||
const _CONFIG_DIR = '/home/juan/.config';
|
const _CONFIG_DIR = '/home/juan/.config';
|
||||||
|
|
|
@ -10,23 +10,20 @@ Vn.Photos = new Class
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.$('html-form').onsubmit = function ()
|
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.$('schema-field').value = this.$('schema').value;
|
||||||
this.$('submit').disabled = true;
|
this.$('submit').disabled = true;
|
||||||
this.gui.loaderPush ();
|
|
||||||
|
|
||||||
var request = new Vn.JsonRequest ();
|
this.conn.sendFormMultipart (this.$('html-form'),
|
||||||
request.sendFormMultipart (this.$('html-form'),
|
this._onResponse.bind (this));
|
||||||
this.onResponse.bind (this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,onResponse: function (request, json, error)
|
,_onResponse: function (request, json, error)
|
||||||
{
|
{
|
||||||
this.gui.loaderPop ();
|
|
||||||
this.$('submit').disabled = false;
|
this.$('submit').disabled = false;
|
||||||
|
|
||||||
if (json)
|
if (json)
|
||||||
|
|
|
@ -7,7 +7,7 @@ Vn.Contact = new Class
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
this.$('contact-form').onsubmit = function ()
|
this.$('contact-form').onsubmit = function ()
|
||||||
{ self.onSubmit (); return false; };
|
{ self._onSubmit (); return false; };
|
||||||
|
|
||||||
this.refreshCaptcha ();
|
this.refreshCaptcha ();
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,15 @@ Vn.Contact = new Class
|
||||||
'stamp': new Date ().getTime ()
|
'stamp': new Date ().getTime ()
|
||||||
};
|
};
|
||||||
this.$('captcha-img').src = '?'+ Vn.Url.makeUri (params);
|
this.$('captcha-img').src = '?'+ Vn.Url.makeUri (params);
|
||||||
|
|
||||||
Vn.Url.makeUri (params)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,onSubmit: function ()
|
,_onSubmit: function ()
|
||||||
{
|
{
|
||||||
var request = new Vn.JsonRequest ();
|
this.conn.sendForm (this.$('contact-form'),
|
||||||
request.sendForm (this.$('contact-form'),
|
this._onResponse.bind (this));
|
||||||
this.onResponse.bind (this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,onResponse: function (request, json, error)
|
,_onResponse: function (json, error)
|
||||||
{
|
{
|
||||||
var form = this.$('contact-form');
|
var form = this.$('contact-form');
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@
|
||||||
directory="catalog"
|
directory="catalog"
|
||||||
subdir="200x200"
|
subdir="200x200"
|
||||||
form="item"
|
form="item"
|
||||||
|
conn="conn"
|
||||||
column="Foto"
|
column="Foto"
|
||||||
full-dir="900x900"/>
|
full-dir="900x900"/>
|
||||||
<div class="item-info">
|
<div class="item-info">
|
||||||
|
|
|
@ -15,11 +15,13 @@
|
||||||
<htk-bar-button
|
<htk-bar-button
|
||||||
icon="basket"
|
icon="basket"
|
||||||
tip="_ShoppingBasket"
|
tip="_ShoppingBasket"
|
||||||
|
show-text="false"
|
||||||
on-click="onBasketClick"/>
|
on-click="onBasketClick"/>
|
||||||
<htk-bar-button
|
<htk-bar-button
|
||||||
id="pay-button"
|
id="pay-button"
|
||||||
icon="pay"
|
icon="pay"
|
||||||
tip="_MakePayment"
|
tip="_MakePayment"
|
||||||
|
show-text="false"
|
||||||
on-click="onPayButtonClick"/>
|
on-click="onPayButtonClick"/>
|
||||||
<div class="balance">
|
<div class="balance">
|
||||||
<span class="label">
|
<span class="label">
|
||||||
|
@ -37,7 +39,7 @@
|
||||||
</htk-text>
|
</htk-text>
|
||||||
</span>
|
</span>
|
||||||
<img
|
<img
|
||||||
src="image/dark/info.svg"
|
src="image/icon/dark/info.svg"
|
||||||
title="_PaymentInfo"
|
title="_PaymentInfo"
|
||||||
class="info"
|
class="info"
|
||||||
alt="Info"/>
|
alt="Info"/>
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
directory="news"
|
directory="news"
|
||||||
subdir="200x200"
|
subdir="200x200"
|
||||||
full-dir="full"
|
full-dir="full"
|
||||||
editable="true"/>
|
editable="true"
|
||||||
|
conn="conn"/>
|
||||||
<p class="important">
|
<p class="important">
|
||||||
<htk-text form="iter" column="title"/>
|
<htk-text form="iter" column="title"/>
|
||||||
</p>
|
</p>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/app.php');
|
require_once 'vn-autoload.php';
|
||||||
|
|
||||||
$webApp = new Vn\Web\App ('hedera-web');
|
$webApp = new Vn\Web\App ('hedera-web');
|
||||||
$webApp->run ();
|
$webApp->run ();
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
/**
|
/**
|
||||||
* Simulates a connection to a database by making asynchronous http requests to
|
* Simulates a connection to a database by making asynchronous requests to a
|
||||||
* a remote PHP script that returns the results in JSON format.
|
* remote REST service that returns the results in JSON format.
|
||||||
* Using this class can perform any operation that can be done with a database,
|
* Using this class can perform any operation that can be done with a database,
|
||||||
* like open/close a connection or selecion/updating queries.
|
* 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:
|
Flag:
|
||||||
{
|
{
|
||||||
|
@ -24,7 +28,7 @@ Db.Conn = new Class ().extend
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Db.Conn.implement
|
Db.Connection.implement
|
||||||
({
|
({
|
||||||
Extends: Vn.JsonConnection
|
Extends: Vn.JsonConnection
|
||||||
|
|
||||||
|
@ -92,9 +96,9 @@ Db.Conn.implement
|
||||||
|
|
||||||
switch (columns[j].type)
|
switch (columns[j].type)
|
||||||
{
|
{
|
||||||
case Db.Conn.Type.DATE:
|
case Db.Connection.Type.DATE:
|
||||||
case Db.Conn.Type.DATE_TIME:
|
case Db.Connection.Type.DATE_TIME:
|
||||||
case Db.Conn.Type.TIMESTAMP:
|
case Db.Connection.Type.TIMESTAMP:
|
||||||
castFunc = this.valueToDate;
|
castFunc = this.valueToDate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@ Vn.include ('js/sql/main');
|
||||||
Vn.includeLib ('db',
|
Vn.includeLib ('db',
|
||||||
[
|
[
|
||||||
'db'
|
'db'
|
||||||
,'conn'
|
,'connection'
|
||||||
,'result'
|
,'result'
|
||||||
,'result-set'
|
,'result-set'
|
||||||
,'model'
|
,'model'
|
||||||
|
|
|
@ -45,7 +45,7 @@ Db.Model.implement
|
||||||
**/
|
**/
|
||||||
conn:
|
conn:
|
||||||
{
|
{
|
||||||
type: Db.Conn
|
type: Db.Connection
|
||||||
,set: function (x)
|
,set: function (x)
|
||||||
{
|
{
|
||||||
this._conn = x;
|
this._conn = x;
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
|
|
||||||
Vn.App = new Class
|
Vn.App = new Class
|
||||||
({
|
({
|
||||||
Extends: Vn.Object
|
Extends: Vn.Object,
|
||||||
|
Properties:
|
||||||
|
{
|
||||||
|
conn:
|
||||||
|
{
|
||||||
|
type: Db.Connection
|
||||||
|
,get: function ()
|
||||||
|
{
|
||||||
|
return this._conn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
,initialize: function ()
|
,initialize: function ()
|
||||||
{
|
{
|
||||||
|
@ -16,18 +27,18 @@ Vn.App = new Class
|
||||||
});
|
});
|
||||||
this._isGuest.on ('changed', this._onGuestChange, this);
|
this._isGuest.on ('changed', this._onGuestChange, this);
|
||||||
|
|
||||||
var conn = new Db.Conn ();
|
var conn = new Db.Connection ();
|
||||||
this.link ({_conn: conn}, {'error': this._onConnError});
|
this.link ({_conn: conn}, {'error': this._onConnError});
|
||||||
}
|
}
|
||||||
|
|
||||||
,run: function ()
|
,run: function ()
|
||||||
{
|
{
|
||||||
var guest = Vn.Cookie.check ('hedera_guest');
|
var guest = localStorage.getItem ('hederaGuest');
|
||||||
|
|
||||||
if (guest)
|
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._conn.open (null, null, null,
|
||||||
this._onAutoLogin.bind (this));
|
this._onAutoLogin.bind (this));
|
||||||
|
@ -67,7 +78,7 @@ Vn.App = new Class
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
Vn.Cookie.set ('hedera_guest', true);
|
localStorage.setItem ('hederaGuest', true);
|
||||||
this._onLogin ();
|
this._onLogin ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -77,10 +88,7 @@ Vn.App = new Class
|
||||||
,_onAutoLogin: function (success)
|
,_onAutoLogin: function (success)
|
||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
|
||||||
Vn.Cookie.unset ('vn_pass');
|
|
||||||
this.run ();
|
this.run ();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
this._onLogin ();
|
this._onLogin ();
|
||||||
}
|
}
|
||||||
|
@ -97,8 +105,7 @@ Vn.App = new Class
|
||||||
,_onLogout: function (gui)
|
,_onLogout: function (gui)
|
||||||
{
|
{
|
||||||
this._freeGui ();
|
this._freeGui ();
|
||||||
Vn.Cookie.unset ('hedera_guest');
|
localStorage.removeItem ('hederaGuest');
|
||||||
Vn.Cookie.unset ('vn_pass');
|
|
||||||
this.run ();
|
this.run ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,10 +126,13 @@ Vn.App = new Class
|
||||||
{
|
{
|
||||||
if (error instanceof Vn.JsonException)
|
if (error instanceof Vn.JsonException)
|
||||||
{
|
{
|
||||||
|
if (error.exception)
|
||||||
var exception = error.exception
|
var exception = error.exception
|
||||||
.replace (/\\/g, '.')
|
.replace (/\\/g, '.')
|
||||||
.replace (/Exception$/, '')
|
.replace (/Exception$/, '')
|
||||||
.replace (/^Vn\.Web\./, '');
|
.replace (/^Vn\.Web\./, '');
|
||||||
|
else
|
||||||
|
var exception = null;
|
||||||
|
|
||||||
switch (exception)
|
switch (exception)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ Vn.Gui = new Class
|
||||||
{
|
{
|
||||||
conn:
|
conn:
|
||||||
{
|
{
|
||||||
type: Db.Conn
|
type: Db.Connection
|
||||||
,set: function (x)
|
,set: function (x)
|
||||||
{
|
{
|
||||||
this.link ({_conn: x},
|
this.link ({_conn: x},
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
<div id="left-panel" class="left-panel">
|
<div id="left-panel" class="left-panel">
|
||||||
<div class="menu-overflow">
|
<div class="menu-overflow">
|
||||||
<div class="menu-header" id="menu-header">
|
<div class="menu-header" id="menu-header">
|
||||||
<img class="logo" src="image/dark/logo.svg" alt="Verdnatura"/>
|
<img class="logo" src="image/logo-dark.svg" alt="Verdnatura"/>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<button class="logout" on-click="onLogoutClick" title="_Exit">
|
<button class="logout" on-click="onLogoutClick" title="_Exit">
|
||||||
<img src="image/dark/exit.svg" alt="_Exit"/>
|
<img src="image/icon/dark/exit.svg" alt="_Exit"/>
|
||||||
</button>
|
</button>
|
||||||
<p id="user-name"/>
|
<p id="user-name"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,12 +10,13 @@ Vn.Login = new Class
|
||||||
{
|
{
|
||||||
conn:
|
conn:
|
||||||
{
|
{
|
||||||
type: Db.Conn
|
type: Db.Connection
|
||||||
,set: function (x)
|
,set: function (x)
|
||||||
{
|
{
|
||||||
this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange});
|
this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange});
|
||||||
x.execQuery (
|
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));
|
this._onSocialQueryDone.bind (this));
|
||||||
}
|
}
|
||||||
,get: function ()
|
,get: function ()
|
||||||
|
@ -60,8 +61,10 @@ Vn.Login = new Class
|
||||||
{
|
{
|
||||||
document.body.appendChild (this.node);
|
document.body.appendChild (this.node);
|
||||||
|
|
||||||
if (Vn.Cookie.check ('vn_user'))
|
var lastUser = localStorage.getItem ('hederaLastUser');
|
||||||
this.$('user').value = Vn.Cookie.get ('vn_user');
|
|
||||||
|
if (lastUser)
|
||||||
|
this.$('user').value = lastUser;
|
||||||
|
|
||||||
this._focusUserInput ();
|
this._focusUserInput ();
|
||||||
}
|
}
|
||||||
|
@ -93,7 +96,10 @@ Vn.Login = new Class
|
||||||
this.$('pass').value = '';
|
this.$('pass').value = '';
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
|
{
|
||||||
|
localStorage.setItem ('hederaLastUser', this.$('user').value);
|
||||||
this.signalEmit ('login');
|
this.signalEmit ('login');
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this._focusUserInput ();
|
this._focusUserInput ();
|
||||||
}
|
}
|
||||||
|
@ -130,7 +136,7 @@ Vn.Login = new Class
|
||||||
social.appendChild (a);
|
social.appendChild (a);
|
||||||
|
|
||||||
var img = document.createElement ('img');
|
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.alt = res.get ('title');
|
||||||
img.title = res.get ('title');
|
img.title = res.get ('title');
|
||||||
a.appendChild (img);
|
a.appendChild (img);
|
||||||
|
|
|
@ -50,32 +50,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div id="social" class="social">
|
<div id="social" class="social"/>
|
||||||
<a target="_blank" href="http://www.facebook.com/verdnatura">
|
|
||||||
<img alt="Facebook" src="image/social/facebook.svg" title="Facebook"/>
|
|
||||||
</a>
|
|
||||||
<a target="_blank" href="https://twitter.com/Verdnatura">
|
|
||||||
<img alt="Twitter" src="image/social/twitter.svg" title="Twitter"/>
|
|
||||||
</a>
|
|
||||||
<a target="_blank" href="https://www.instagram.com/verdnatura">
|
|
||||||
<img alt="Instagram" src="image/social/instagram.svg" title="Instagram"/>
|
|
||||||
</a>
|
|
||||||
<a target="_blank" href="http://www.youtube.com/user/verdnatura">
|
|
||||||
<img alt="YouTube" src="image/social/youtube.svg" title="YouTube"/>
|
|
||||||
</a>
|
|
||||||
<a target="_blank" href="https://plus.google.com/u/1/112915460747485233678">
|
|
||||||
<img alt="Google+" src="image/social/gplus.svg" title="Google+"/>
|
|
||||||
</a>
|
|
||||||
<a target="_blank" href="https://www.linkedin.com/company/verdnatura">
|
|
||||||
<img alt="Linkedin" src="image/social/linkedin.svg" title="Linkedin"/>
|
|
||||||
</a>
|
|
||||||
<a target="_blank" href="https://es.pinterest.com/verdnatura/">
|
|
||||||
<img alt="Pinterest" src="image/social/pinterest.svg" title="Pinterest"/>
|
|
||||||
</a>
|
|
||||||
<!-- <a target="_blank" href="https://blog.verdnatura.es/">
|
|
||||||
<img alt="Blog" src="image/social/blog.svg" title="Blog"/>
|
|
||||||
</a>
|
|
||||||
--> </div>
|
|
||||||
<div class="contact">
|
<div class="contact">
|
||||||
<p><t>Login mail</t></p>
|
<p><t>Login mail</t></p>
|
||||||
<p><t>Login phone</t></p>
|
<p><t>Login phone</t></p>
|
||||||
|
|
|
@ -8,8 +8,8 @@ Vn.Tpv = new Class
|
||||||
|
|
||||||
,check: function (callback)
|
,check: function (callback)
|
||||||
{
|
{
|
||||||
this.tpvOrder = Vn.Hash.get ('tpv_order');
|
this.tpvOrder = Vn.Hash.get ('tpvOrder');
|
||||||
this.tpvStatus = Vn.Hash.get ('tpv_status');
|
this.tpvStatus = Vn.Hash.get ('tpvStatus');
|
||||||
|
|
||||||
if (this.tpvStatus)
|
if (this.tpvStatus)
|
||||||
{
|
{
|
||||||
|
@ -41,15 +41,14 @@ Vn.Tpv = new Class
|
||||||
,'company': company
|
,'company': company
|
||||||
};
|
};
|
||||||
|
|
||||||
var request = new Vn.JsonRequest ('tpv/transaction');
|
this.conn.send ('tpv/transaction', params,
|
||||||
request.send (params,
|
|
||||||
this._onTransactionStart.bind (this));
|
this._onTransactionStart.bind (this));
|
||||||
}
|
}
|
||||||
else if (!isNaN (amount))
|
else if (!isNaN (amount))
|
||||||
Htk.Toast.showError (_('AmountError'));
|
Htk.Toast.showError (_('AmountError'));
|
||||||
}
|
}
|
||||||
|
|
||||||
,_onTransactionStart: function (request, json, error)
|
,_onTransactionStart: function (json, error)
|
||||||
{
|
{
|
||||||
if (json)
|
if (json)
|
||||||
{
|
{
|
||||||
|
@ -113,8 +112,8 @@ Vn.Tpv = new Class
|
||||||
path += location.search ? location.search : '';
|
path += location.search ? location.search : '';
|
||||||
path += Vn.Hash.make ({
|
path += Vn.Hash.make ({
|
||||||
'form': 'ecomerce/orders',
|
'form': 'ecomerce/orders',
|
||||||
'tpv_status': status,
|
'tpvStatus': status,
|
||||||
'tpv_order': '%s'
|
'tpvOrder': '%s'
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -27,6 +27,13 @@ Htk.ColumnImage = new Class
|
||||||
{
|
{
|
||||||
type: String
|
type: String
|
||||||
,value: null
|
,value: null
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* The REST connection used to upload the image.
|
||||||
|
**/
|
||||||
|
conn:
|
||||||
|
{
|
||||||
|
type: Vn.JsonConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +50,7 @@ Htk.ColumnImage = new Class
|
||||||
,subdir: this.subdir
|
,subdir: this.subdir
|
||||||
,fullDir: this.fullDir
|
,fullDir: this.fullDir
|
||||||
,value: this.value
|
,value: this.value
|
||||||
|
,conn: this.conn
|
||||||
});
|
});
|
||||||
|
|
||||||
var td = this.parent (tr);
|
var td = this.parent (tr);
|
||||||
|
|
|
@ -13,7 +13,7 @@ Htk.Button = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
icon:
|
/* icon:
|
||||||
{
|
{
|
||||||
type: String
|
type: String
|
||||||
,set: function (x)
|
,set: function (x)
|
||||||
|
@ -22,7 +22,7 @@ Htk.Button = new Class
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
tip:
|
*/ tip:
|
||||||
{
|
{
|
||||||
type: String
|
type: String
|
||||||
,set: function (x)
|
,set: function (x)
|
||||||
|
|
|
@ -54,6 +54,13 @@ Htk.Image = new Class
|
||||||
{
|
{
|
||||||
return this._fullDir;
|
return this._fullDir;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* The REST connection used to upload the image.
|
||||||
|
**/
|
||||||
|
conn:
|
||||||
|
{
|
||||||
|
type: Vn.JsonConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +183,7 @@ Htk.Image = new Class
|
||||||
{
|
{
|
||||||
event.stopPropagation ();
|
event.stopPropagation ();
|
||||||
|
|
||||||
var editor = new Htk.ImageEditor ();
|
var editor = new Htk.ImageEditor ({conn: this.conn});
|
||||||
editor.setData (this.value, this._directory);
|
editor.setData (this.value, this._directory);
|
||||||
editor.on ('name-changed', this._onNameChange, this);
|
editor.on ('name-changed', this._onNameChange, this);
|
||||||
editor.on ('file-uploaded', this._onFileUpload, this);
|
editor.on ('file-uploaded', this._onFileUpload, this);
|
||||||
|
|
|
@ -9,6 +9,16 @@ Vn.define (function () {
|
||||||
Htk.ImageEditor = new Class
|
Htk.ImageEditor = new Class
|
||||||
({
|
({
|
||||||
Extends: Htk.Widget
|
Extends: Htk.Widget
|
||||||
|
,Properties:
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The REST connection used to upload the image.
|
||||||
|
**/
|
||||||
|
conn:
|
||||||
|
{
|
||||||
|
type: Vn.JsonConnection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
,initialize: function (props)
|
,initialize: function (props)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +26,7 @@ Htk.ImageEditor = new Class
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.$('form').onsubmit = function ()
|
this.$('form').onsubmit = function ()
|
||||||
{ self.onSubmit (); return false; };
|
{ self._onSubmit (); return false; };
|
||||||
|
|
||||||
this.parent (props);
|
this.parent (props);
|
||||||
}
|
}
|
||||||
|
@ -31,17 +41,16 @@ Htk.ImageEditor = new Class
|
||||||
this.signalEmit ('name-changed', newValue);
|
this.signalEmit ('name-changed', newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
,onSubmit: function ()
|
,_onSubmit: function ()
|
||||||
{
|
{
|
||||||
this.$('submit').disabled = true;
|
this.$('submit').disabled = true;
|
||||||
this.$('spinner').start ();
|
this.$('spinner').start ();
|
||||||
|
|
||||||
var request = new Vn.JsonRequest ();
|
this.conn.sendFormMultipart (this.$('form'),
|
||||||
request.sendFormMultipart (this.$('form'),
|
this._onResponse.bind (this));
|
||||||
this.onResponse.bind (this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,onResponse: function (request, json, error)
|
,_onResponse: function (request, json, error)
|
||||||
{
|
{
|
||||||
this.$('submit').disabled = false;
|
this.$('submit').disabled = false;
|
||||||
this.$('spinner').stop ();
|
this.$('spinner').stop ();
|
||||||
|
|
|
@ -16,10 +16,10 @@ Vn.JsonConnection = new Class
|
||||||
{
|
{
|
||||||
this.parent ();
|
this.parent ();
|
||||||
|
|
||||||
if (localStorage.getItem ('token'))
|
if (localStorage.getItem ('vnToken'))
|
||||||
this._token = localStorage.getItem ('token');
|
this._token = localStorage.getItem ('vnToken');
|
||||||
if (sessionStorage.getItem ('token'))
|
if (sessionStorage.getItem ('vnToken'))
|
||||||
this._token = sessionStorage.getItem ('token');
|
this._token = sessionStorage.getItem ('vnToken');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,10 +58,12 @@ Vn.JsonConnection = new Class
|
||||||
this._token = json.token;
|
this._token = json.token;
|
||||||
|
|
||||||
var storage = remember ? localStorage : sessionStorage;
|
var storage = remember ? localStorage : sessionStorage;
|
||||||
storage.setItem ('token', this._token);
|
storage.setItem ('vnToken', this._token);
|
||||||
|
|
||||||
this.signalEmit ('openned');
|
this.signalEmit ('openned');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
this._closeClient ();
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
callback (this, this._connected, error);
|
callback (this, this._connected, error);
|
||||||
|
@ -74,6 +76,7 @@ Vn.JsonConnection = new Class
|
||||||
**/
|
**/
|
||||||
,close: function (callback)
|
,close: function (callback)
|
||||||
{
|
{
|
||||||
|
this._closeClient ();
|
||||||
this.send ('core/logout', null,
|
this.send ('core/logout', null,
|
||||||
this._onClose.bind (this, callback));
|
this._onClose.bind (this, callback));
|
||||||
}
|
}
|
||||||
|
@ -83,13 +86,21 @@ Vn.JsonConnection = new Class
|
||||||
*/
|
*/
|
||||||
,_onClose: function (callback, json, error)
|
,_onClose: function (callback, json, error)
|
||||||
{
|
{
|
||||||
this._connected = false;
|
|
||||||
this.signalEmit ('closed');
|
this.signalEmit ('closed');
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
callback (this, json == true, error);
|
callback (this, json == true, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
,_closeClient: function ()
|
||||||
|
{
|
||||||
|
this._connected = false;
|
||||||
|
this._token = null;
|
||||||
|
|
||||||
|
localStorage.removeItem ('vnToken');
|
||||||
|
sessionStorage.removeItem ('vnToken');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the specified REST service with the given params and calls
|
* Executes the specified REST service with the given params and calls
|
||||||
* the callback when response is received.
|
* the callback when response is received.
|
||||||
|
@ -180,7 +191,7 @@ Vn.JsonConnection = new Class
|
||||||
if (request.status == 0)
|
if (request.status == 0)
|
||||||
{
|
{
|
||||||
var ex = new Vn.JsonException ();
|
var ex = new Vn.JsonException ();
|
||||||
ex.message = _('The server does not respond');
|
ex.message = _('The server does not respond, please check you Internet connection');
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "hedera-web"
|
||||||
|
,"version": "1.0.0"
|
||||||
|
,"description": "Verdnatura web page"
|
||||||
|
,"devDependencies": {
|
||||||
|
"webpack": "*"
|
||||||
|
,"webpack-dev-server": "*"
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,8 +12,6 @@ if ($result = $db->query ('SELECT name, content FROM metatag'))
|
||||||
$result->free ();
|
$result->free ();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->includeJs ('js/vn/vn.js');
|
$this->includeJs ('hedera-web.js');
|
||||||
$this->includeJs ('js/vn/locale.js');
|
|
||||||
$this->includeJs ('pages/main/main.js');
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
Vn.includeCss ('pages/main/style.css');
|
|
||||||
|
|
||||||
Vn.include ('js/misc/main');
|
|
||||||
Vn.include ('js/vn/locale');
|
|
||||||
Vn.include ('js/vn/main');
|
|
||||||
Vn.include ('js/sql/main');
|
|
||||||
Vn.include ('js/db/main');
|
|
||||||
Vn.include ('js/htk/main');
|
|
||||||
Vn.include ('js/hedera/main');
|
|
||||||
|
|
||||||
Vn.main (function ()
|
|
||||||
{
|
|
||||||
hederaWeb = new Vn.App ();
|
|
||||||
hederaWeb.run ();
|
|
||||||
});
|
|
|
@ -5,7 +5,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
<meta name="viewport" content="user-scalable=no"/>
|
<meta name="viewport" content="user-scalable=no"/>
|
||||||
<link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"/>
|
<link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<?=__DIR__?>/style.css"/>
|
<link rel="stylesheet" type="text/css" href="<?=$dir?>/style.css"/>
|
||||||
<title>Verdnatura</title>
|
<title>Verdnatura</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
<meta name="viewport" content="user-scalable=no"/>
|
<meta name="viewport" content="user-scalable=no"/>
|
||||||
<link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"/>
|
<link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<?=__DIR__?>/style.css"/>
|
<link rel="stylesheet" type="text/css" href="<?=$dir?>/style.css"/>
|
||||||
<title>Verdnatura</title>
|
<title>Verdnatura</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<a href="http://www.mozilla.org/es-ES/firefox/new/" target="_blank">
|
<a href="http://www.mozilla.org/es-ES/firefox/new/" target="_blank">
|
||||||
<img src="<?=__DIR__?>/update-browser.png" alt="<?=s('UpdateYourBrowser')?>"></img>
|
<img src="<?=$dir?>/update-browser.png" alt="<?=s('UpdateYourBrowser')?>"></img>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="continue">
|
<div id="continue">
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
<meta name="viewport" content="user-scalable=no"/>
|
<meta name="viewport" content="user-scalable=no"/>
|
||||||
<link href="//fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"/>
|
<link href="//fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="<?=__DIR__?>/style.css?version"/>
|
<link rel="stylesheet" type="text/css" href="<?=$dir?>/style.css?version"/>
|
||||||
<title>Verdnatura</title>
|
<title>Verdnatura</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
<div>
|
<div>
|
||||||
<a href="https://test-www.verdnatura.es/">
|
<a href="https://test-www.verdnatura.es/">
|
||||||
<div>
|
<div>
|
||||||
<img src="<?=__DIR__?>/new-web.svg" alt=""></img>
|
<img src="<?=$dir?>/new-web.svg" alt=""></img>
|
||||||
<p>
|
<p>
|
||||||
<?=s('New website')?>
|
<?=s('New website')?>
|
||||||
</p>
|
</p>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<div>
|
<div>
|
||||||
<a href="?skipVersion=true">
|
<a href="?skipVersion=true">
|
||||||
<div>
|
<div>
|
||||||
<img src="<?=__DIR__?>/old-web.svg" alt=""></img>
|
<img src="<?=$dir?>/old-web.svg" alt=""></img>
|
||||||
<p>
|
<p>
|
||||||
<?=s('Old website')?>
|
<?=s('Old website')?>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/rest-request.php');
|
|
||||||
require_once ('PEAR.php');
|
require_once ('PEAR.php');
|
||||||
require_once ('Text/CAPTCHA.php');
|
require_once ('Text/CAPTCHA.php');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
|
|
||||||
class Log extends Vn\Web\JsonRequest
|
class Log extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
const PARAMS = [
|
const PARAMS = [
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
require_once ('vn/web/jwt.php');
|
|
||||||
|
|
||||||
const MIN = 60;
|
const MIN = 60;
|
||||||
const HOUR = 60 * MIN;
|
const HOUR = 60 * MIN;
|
||||||
const DAY = 24 * HOUR;
|
const DAY = 24 * HOUR;
|
||||||
|
@ -14,16 +11,17 @@ class Login extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
$this->updateCredentials ($db);
|
$this->updateCredentials ($db);
|
||||||
|
|
||||||
if (isset ($_POST['remember']))
|
if (!empty ($_POST['remember']))
|
||||||
$tokenLife = WEEK;
|
$tokenLife = WEEK;
|
||||||
else
|
else
|
||||||
$tokenLife = 30 * MIN;
|
$tokenLife = 30 * MIN;
|
||||||
|
|
||||||
$token = Vn\Web\Jwt::encode ([
|
$payload = [
|
||||||
'userName' => $_SESSION['user'],
|
'sub' => $_SESSION['user'],
|
||||||
'timestamp' => time (),
|
|
||||||
'exp' => time () + $tokenLife
|
'exp' => time () + $tokenLife
|
||||||
]);
|
];
|
||||||
|
$key = $db->getValue ('SELECT jwtKey FROM config');
|
||||||
|
$token = Vn\Web\Jwt::encode ($payload, $key);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'login' => TRUE,
|
'login' => TRUE,
|
||||||
|
@ -36,6 +34,9 @@ class Login extends Vn\Web\JsonRequest
|
||||||
**/
|
**/
|
||||||
function updateCredentials ($db)
|
function updateCredentials ($db)
|
||||||
{
|
{
|
||||||
|
if (empty ($_POST['password']))
|
||||||
|
return;
|
||||||
|
|
||||||
$hasAccount = $db->getValue (
|
$hasAccount = $db->getValue (
|
||||||
'SELECT COUNT(*) > 0
|
'SELECT COUNT(*) > 0
|
||||||
FROM account.user u
|
FROM account.user u
|
||||||
|
@ -60,7 +61,7 @@ class Login extends Vn\Web\JsonRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->escape ($_SESSION['user']);
|
$user = $this->escape ($_SESSION['user']);
|
||||||
$pass = $this->escape ($_SESSION['password']);
|
$pass = $this->escape ($_POST['password']);
|
||||||
ssh2_exec ($ssh, "samba-tool user create \"$user\" \"$pass\"");
|
ssh2_exec ($ssh, "samba-tool user create \"$user\" \"$pass\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
|
|
||||||
class Logout extends Vn\Web\JsonRequest
|
class Logout extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
function run ($db)
|
function run ($db)
|
||||||
{
|
{
|
||||||
$this->logout ();
|
$this->service->logout ();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
use Vn\Web\Security;
|
use Vn\Web\Security;
|
||||||
|
|
||||||
|
@ -15,10 +13,10 @@ class Query extends Vn\Web\JsonRequest
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userDb->multiQuery ($_REQUEST['sql']);
|
$db->multiQuery ($_REQUEST['sql']);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$result = $userDb->storeResult ();
|
$result = $db->storeResult ();
|
||||||
|
|
||||||
if ($result !== FALSE)
|
if ($result !== FALSE)
|
||||||
{
|
{
|
||||||
|
@ -28,12 +26,12 @@ class Query extends Vn\Web\JsonRequest
|
||||||
else
|
else
|
||||||
$results[] = TRUE;
|
$results[] = TRUE;
|
||||||
}
|
}
|
||||||
while ($userDb->moreResults () && $userDb->nextResult ());
|
while ($db->moreResults () && $db->nextResult ());
|
||||||
|
|
||||||
// Checks for warnings
|
// Checks for warnings
|
||||||
|
|
||||||
if ($userDb->checkWarnings ()
|
if ($db->checkWarnings ()
|
||||||
&& ($result = $userDb->query ('SHOW WARNINGS')))
|
&& ($result = $db->query ('SHOW WARNINGS')))
|
||||||
{
|
{
|
||||||
$sql = 'SELECT description, @warn code '.
|
$sql = 'SELECT description, @warn code '.
|
||||||
'FROM sql_message WHERE code = @warn';
|
'FROM sql_message WHERE code = @warn';
|
||||||
|
@ -41,7 +39,7 @@ class Query extends Vn\Web\JsonRequest
|
||||||
while ($row = $result->fetch_assoc ())
|
while ($row = $result->fetch_assoc ())
|
||||||
{
|
{
|
||||||
if ($row['Code'] == 1265
|
if ($row['Code'] == 1265
|
||||||
&& ($warning = $userDb->getRow ($sql)))
|
&& ($warning = $db->getRow ($sql)))
|
||||||
trigger_error ("{$warning['code']}: {$warning['description']}", E_USER_WARNING);
|
trigger_error ("{$warning['code']}: {$warning['description']}", E_USER_WARNING);
|
||||||
else
|
else
|
||||||
trigger_error ("{$row['Code']}: {$row['Message']}", E_USER_WARNING);
|
trigger_error ("{$row['Code']}: {$row['Message']}", E_USER_WARNING);
|
||||||
|
@ -50,7 +48,7 @@ class Query extends Vn\Web\JsonRequest
|
||||||
|
|
||||||
// Checks for errors
|
// Checks for errors
|
||||||
|
|
||||||
$userDb->checkError ();
|
$db->checkError ();
|
||||||
}
|
}
|
||||||
catch (Vn\Db\Exception $e)
|
catch (Vn\Db\Exception $e)
|
||||||
{
|
{
|
||||||
|
@ -64,7 +62,7 @@ class Query extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
$sql = 'SELECT description, #code code '.
|
$sql = 'SELECT description, #code code '.
|
||||||
'FROM sql_message WHERE code = #code';
|
'FROM sql_message WHERE code = #code';
|
||||||
$row = $userDb->getRow ($sql, ['code' => $message]);
|
$row = $db->getRow ($sql, ['code' => $message]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1305: // ER_SP_DOES_NOT_EXIST
|
case 1305: // ER_SP_DOES_NOT_EXIST
|
||||||
|
@ -74,7 +72,7 @@ class Query extends Vn\Web\JsonRequest
|
||||||
|
|
||||||
$sql = 'SELECT description, @err code '.
|
$sql = 'SELECT description, @err code '.
|
||||||
'FROM sql_message WHERE code = @err';
|
'FROM sql_message WHERE code = @err';
|
||||||
$row = $userDb->getRow ($sql);
|
$row = $db->getRow ($sql);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
|
|
||||||
class RecoverPassword extends Vn\Web\JsonRequest
|
class RecoverPassword extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
const PARAMS = ['user'];
|
const PARAMS = ['user'];
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/rest-request.php');
|
|
||||||
require_once ('vn/web/util.php');
|
|
||||||
|
|
||||||
use Vn\Web\Security;
|
use Vn\Web\Security;
|
||||||
|
use Vn\Web\Util;
|
||||||
|
|
||||||
class Invoice extends Vn\Web\RestRequest
|
class Invoice extends Vn\Web\RestRequest
|
||||||
{
|
{
|
||||||
|
@ -18,7 +16,7 @@ class Invoice extends Vn\Web\RestRequest
|
||||||
if (!$pdfPath)
|
if (!$pdfPath)
|
||||||
throw new Exception (s('Invoice id not found'));
|
throw new Exception (s('Invoice id not found'));
|
||||||
|
|
||||||
Vn\Web\printFile ($pdfPath);
|
Util::printFile ($pdfPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once (__DIR__.'/lib/method.php');
|
require_once __DIR__.'/lib/method.php';
|
||||||
|
|
||||||
class Clean extends Edi\Method
|
class Clean extends Edi\Method
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/lib/method.php');
|
|
||||||
require_once (__DIR__.'/lib.php');
|
require_once (__DIR__.'/lib.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/lib/method.php');
|
|
||||||
require_once (__DIR__.'/util.php');
|
require_once (__DIR__.'/util.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/rest-request.php');
|
|
||||||
require_once (__DIR__.'/util.php');
|
require_once (__DIR__.'/util.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
require_once (__DIR__.'/util.php');
|
require_once (__DIR__.'/util.php');
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
require_once ('libphp-phpmailer/PHPMailerAutoload.php');
|
require_once ('libphp-phpmailer/PHPMailerAutoload.php');
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/lib/method.php');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ejemplo:
|
* Ejemplo:
|
||||||
* <Cube><Cube time="2010-12-10"><Cube currency="USD" rate="1.3244"/>
|
* <Cube><Cube time="2010-12-10"><Cube currency="USD" rate="1.3244"/>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/lib/method.php');
|
|
||||||
require_once ('libphp-phpmailer/PHPMailerAutoload.php');
|
require_once ('libphp-phpmailer/PHPMailerAutoload.php');
|
||||||
|
|
||||||
class Mail extends Vn\Lib\Method
|
class Mail extends Vn\Lib\Method
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
||||||
class Sms extends Vn\Web\JsonRequest
|
class Sms extends Vn\Web\JsonRequest
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/lib/method.php');
|
|
||||||
|
|
||||||
class VisitsSync extends Vn\Lib\Method
|
class VisitsSync extends Vn\Lib\Method
|
||||||
{
|
{
|
||||||
function run ($db)
|
function run ($db)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/lib/method.php');
|
|
||||||
require_once (__DIR__.'/tpv.php');
|
require_once (__DIR__.'/tpv.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/rest-request.php');
|
|
||||||
require_once (__DIR__.'/tpv.php');
|
require_once (__DIR__.'/tpv.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/rest-request.php');
|
|
||||||
require_once ('vn/web/util.php');
|
require_once ('vn/web/util.php');
|
||||||
require_once (__DIR__.'/tpv.php');
|
require_once (__DIR__.'/tpv.php');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/tpv/tpv.php');
|
|
||||||
|
|
||||||
if (isset ($_POST['key']))
|
if (isset ($_POST['key']))
|
||||||
{
|
{
|
||||||
ini_set ('soap.wsdl_cache_enabled', FALSE);
|
ini_set ('soap.wsdl_cache_enabled', FALSE);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new TPV transaction and returns the params.
|
* Starts a new TPV transaction and returns the params.
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Vn\Web;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a file and writes it to the output buffer.
|
|
||||||
*
|
|
||||||
* @param string file The file path
|
|
||||||
* @param boolean useXsendfile Wether to use the apache module Xsendfile
|
|
||||||
**/
|
|
||||||
function printFile ($file, $useXsendfile = FALSE)
|
|
||||||
{
|
|
||||||
if (!file_exists ($file))
|
|
||||||
{
|
|
||||||
http_response_code (404);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$finfo = new \finfo (FILEINFO_MIME_TYPE);
|
|
||||||
$mimeType = $finfo->file ($file);
|
|
||||||
|
|
||||||
if ($useXsendfile)
|
|
||||||
{
|
|
||||||
header ("X-Sendfile: $file");
|
|
||||||
header ("Content-Type: $mimeType");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
header ('Content-Description: File Transfer');
|
|
||||||
header ("Content-Type: $mimeType");
|
|
||||||
header ('Content-Disposition: attachment; filename="'. basename ($file) .'"');
|
|
||||||
header ('Expires: 0');
|
|
||||||
header ('Cache-Control: must-revalidate');
|
|
||||||
header ('Pragma: public');
|
|
||||||
header ('Content-Length: '. filesize ($file));
|
|
||||||
|
|
||||||
set_time_limit (0);
|
|
||||||
readfile ($file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once ('vn/lib/app.php');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class for web applications.
|
* Main class for web applications.
|
||||||
*
|
*
|
||||||
|
@ -52,6 +50,8 @@ class App extends \Vn\Lib\App
|
||||||
/**
|
/**
|
||||||
* Gets the configuration file name associated to the current vhost
|
* Gets the configuration file name associated to the current vhost
|
||||||
* or the default config file if isn't defined a file for the vhost.
|
* or the default config file if isn't defined a file for the vhost.
|
||||||
|
*
|
||||||
|
* @return string The config file name
|
||||||
**/
|
**/
|
||||||
function getConfigFile ()
|
function getConfigFile ()
|
||||||
{
|
{
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/service.php');
|
|
||||||
|
|
||||||
use Vn\Lib\Locale;
|
use Vn\Lib\Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,6 +84,7 @@ class HtmlService extends Service
|
||||||
require ($phpFile);
|
require ($phpFile);
|
||||||
|
|
||||||
$this->printHeader ();
|
$this->printHeader ();
|
||||||
|
$dir = $basePath;
|
||||||
include ("$basePath/html.php");
|
include ("$basePath/html.php");
|
||||||
}
|
}
|
||||||
else
|
else
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/json-exception.php');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used for replies.
|
* Class used for replies.
|
||||||
*
|
*
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/json-service.php');
|
|
||||||
require_once (__DIR__.'/rest-request.php');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for JSON services.
|
* Base class for JSON services.
|
||||||
**/
|
**/
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/rest-service.php');
|
|
||||||
require_once (__DIR__.'/json-request.php');
|
|
||||||
require_once (__DIR__.'/json-reply.php');
|
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -71,7 +71,7 @@ class Jwt
|
||||||
|
|
||||||
static function jsonB64Decode ($data)
|
static function jsonB64Decode ($data)
|
||||||
{
|
{
|
||||||
return json_decode (self::base64UrlDecode ($data));
|
return json_decode (self::base64UrlDecode ($data), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function base64UrlEncode ($data)
|
static function base64UrlEncode ($data)
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/rest-service.php');
|
|
||||||
|
|
||||||
class Security
|
class Security
|
||||||
{
|
{
|
||||||
const DEFINER = 1;
|
const DEFINER = 1;
|
||||||
|
@ -17,6 +15,8 @@ abstract class RestRequest extends \Vn\Lib\Method
|
||||||
{
|
{
|
||||||
const PARAMS = NULL;
|
const PARAMS = NULL;
|
||||||
const SECURITY = Security::DEFINER;
|
const SECURITY = Security::DEFINER;
|
||||||
|
|
||||||
|
var $service;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/service.php');
|
|
||||||
require_once (__DIR__.'/rest-request.php');
|
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -2,10 +2,6 @@
|
||||||
|
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once ('vn/lib/app.php');
|
|
||||||
require_once (__DIR__.'/jwt.php');
|
|
||||||
require_once (__DIR__.'/db-session-handler.php');
|
|
||||||
|
|
||||||
use Vn\Lib\Locale;
|
use Vn\Lib\Locale;
|
||||||
use Vn\Lib\UserException;
|
use Vn\Lib\UserException;
|
||||||
|
|
||||||
|
@ -46,9 +42,8 @@ abstract class Service
|
||||||
{
|
{
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
|
|
||||||
ini_set ('session.cookie_secure', TRUE);
|
ini_set ('session.cookie_secure', $this->isHttps ());
|
||||||
ini_set ('session.use_only_cookies', FALSE);
|
ini_set ('session.use_only_cookies', FALSE);
|
||||||
ini_set ('session.cookie_path', 'cookies');
|
|
||||||
ini_set ('session.hash_function', 'sha256');
|
ini_set ('session.hash_function', 'sha256');
|
||||||
|
|
||||||
session_set_save_handler (new DbSessionHandler ($db));
|
session_set_save_handler (new DbSessionHandler ($db));
|
||||||
|
@ -160,14 +155,14 @@ abstract class Service
|
||||||
if (isset ($_GET['token']))
|
if (isset ($_GET['token']))
|
||||||
$token = $_GET['token'];
|
$token = $_GET['token'];
|
||||||
|
|
||||||
$key = $db->getValue ('SELECT jwt_key FROM config');
|
$key = $db->getValue ('SELECT jwtKey FROM config');
|
||||||
$jwtPayload = Jwt::decode ($token, $key);
|
$jwtPayload = Jwt::decode ($token, $key);
|
||||||
$expiration = $jwtPayload['exp'];
|
$expiration = $jwtPayload['exp'];
|
||||||
|
|
||||||
if (isset ($expiration) && $expiration > time())
|
if (empty ($expiration) || $expiration <= time())
|
||||||
throw new SessionExpiredException ();
|
throw new SessionExpiredException ();
|
||||||
|
|
||||||
$user = $jwtPayload['user'];
|
$user = $jwtPayload['sub'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$user = $db->getValue ('SELECT guest_user FROM config');
|
$user = $db->getValue ('SELECT guest_user FROM config');
|
||||||
|
@ -211,9 +206,9 @@ abstract class Service
|
||||||
if ($this->userDb)
|
if ($this->userDb)
|
||||||
return $this->userDb;
|
return $this->userDb;
|
||||||
|
|
||||||
$password = $sysDb->getValue (
|
$password = $this->db->getValue (
|
||||||
'SELECT password FROM user WHERE name = #', [$user]);
|
'SELECT password FROM account.user WHERE name = #', [$user]);
|
||||||
return $this->userDb = $this->createConnection ($user, $password);
|
return $this->userDb = $this->app->createConnection ($user, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,6 +221,7 @@ abstract class Service
|
||||||
|
|
||||||
$method = $this->app->loadMethod (
|
$method = $this->app->loadMethod (
|
||||||
$_REQUEST['method'], $class, './rest');
|
$_REQUEST['method'], $class, './rest');
|
||||||
|
$method->service = $this;
|
||||||
|
|
||||||
if ($method::SECURITY == Security::DEFINER)
|
if ($method::SECURITY == Security::DEFINER)
|
||||||
{
|
{
|
||||||
|
@ -238,7 +234,7 @@ abstract class Service
|
||||||
$methodDb = $db;
|
$methodDb = $db;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$methodDb = $this->getUserDb ();
|
$methodDb = $this->getUserDb ($_SESSION['user']);
|
||||||
|
|
||||||
|
|
||||||
if ($method::PARAMS !== NULL && !$method->checkParams ($_REQUEST, $method::PARAMS))
|
if ($method::PARAMS !== NULL && !$method->checkParams ($_REQUEST, $method::PARAMS))
|
||||||
|
@ -263,12 +259,30 @@ abstract class Service
|
||||||
/**
|
/**
|
||||||
* Obtains the application version number. It is based on de last
|
* Obtains the application version number. It is based on de last
|
||||||
* modification date of the main script.
|
* modification date of the main script.
|
||||||
|
*
|
||||||
|
* @return string The version number
|
||||||
**/
|
**/
|
||||||
function getVersion ()
|
function getVersion ()
|
||||||
{
|
{
|
||||||
return (int) strftime ('%G%m%d%H%M%S',
|
return (int) strftime ('%G%m%d%H%M%S',
|
||||||
filectime ($_SERVER['SCRIPT_FILENAME']));
|
filectime ($_SERVER['SCRIPT_FILENAME']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains the relative path to document root from an absolute path.
|
||||||
|
*
|
||||||
|
* @return string The relative path
|
||||||
|
**/
|
||||||
|
function getDir ($absoluteDir)
|
||||||
|
{
|
||||||
|
error_log ("Absolute: $absoluteDir");
|
||||||
|
error_log ("Root: {$_SERVER['DOCUMENT_ROOT']}");
|
||||||
|
error_log ("Script: {$_SERVER['SCRIPT_FILENAME']}");
|
||||||
|
error_log ("Self: {$_SERVER['PHP_SELF']}");
|
||||||
|
|
||||||
|
$rootLen = strlen ($_SERVER['DOCUMENT_ROOT']);
|
||||||
|
return substr ($absoluteDir, $rootLen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Vn\Web;
|
||||||
|
|
||||||
|
class Util
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Reads a file and writes it to the output buffer.
|
||||||
|
*
|
||||||
|
* @param string file The file path
|
||||||
|
* @param boolean useXsendfile Wether to use the apache module Xsendfile
|
||||||
|
**/
|
||||||
|
static function printFile ($file, $useXsendfile = FALSE)
|
||||||
|
{
|
||||||
|
if (!file_exists ($file))
|
||||||
|
{
|
||||||
|
http_response_code (404);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$finfo = new \finfo (FILEINFO_MIME_TYPE);
|
||||||
|
$mimeType = $finfo->file ($file);
|
||||||
|
|
||||||
|
if ($useXsendfile)
|
||||||
|
{
|
||||||
|
header ("X-Sendfile: $file");
|
||||||
|
header ("Content-Type: $mimeType");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
header ('Content-Description: File Transfer');
|
||||||
|
header ("Content-Type: $mimeType");
|
||||||
|
header ('Content-Disposition: attachment; filename="'. basename ($file) .'"');
|
||||||
|
header ('Expires: 0');
|
||||||
|
header ('Cache-Control: must-revalidate');
|
||||||
|
header ('Pragma: public');
|
||||||
|
header ('Content-Length: '. filesize ($file));
|
||||||
|
|
||||||
|
set_time_limit (0);
|
||||||
|
readfile ($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
var webpack = require ('webpack');
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
{
|
||||||
|
entry: './app.js',
|
||||||
|
output: {
|
||||||
|
path: __dirname,
|
||||||
|
filename: 'hedera-web.js'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export NODE_PATH="/usr/local/lib/node_modules" &&
|
||||||
|
webpack --progress --colors --watch
|
Loading…
Reference in New Issue