forked from verdnatura/hedera-web
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
|
||||
|
||||
require_once ('vn/lib/cli-app.php');
|
||||
require_once 'vn-autoload.php';
|
||||
|
||||
$cliApp = new Vn\Lib\CliApp ('hedera-web', __DIR__.'/rest');
|
||||
$cliApp->run ();
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@
|
|||
directory="catalog"
|
||||
subdir="200x200"
|
||||
form="item"
|
||||
conn="conn"
|
||||
column="Foto"
|
||||
full-dir="900x900"/>
|
||||
<div class="item-info">
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
<htk-bar-button
|
||||
icon="basket"
|
||||
tip="_ShoppingBasket"
|
||||
show-text="false"
|
||||
on-click="onBasketClick"/>
|
||||
<htk-bar-button
|
||||
id="pay-button"
|
||||
icon="pay"
|
||||
tip="_MakePayment"
|
||||
show-text="false"
|
||||
on-click="onPayButtonClick"/>
|
||||
<div class="balance">
|
||||
<span class="label">
|
||||
|
@ -37,7 +39,7 @@
|
|||
</htk-text>
|
||||
</span>
|
||||
<img
|
||||
src="image/dark/info.svg"
|
||||
src="image/icon/dark/info.svg"
|
||||
title="_PaymentInfo"
|
||||
class="info"
|
||||
alt="Info"/>
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
directory="news"
|
||||
subdir="200x200"
|
||||
full-dir="full"
|
||||
editable="true"/>
|
||||
editable="true"
|
||||
conn="conn"/>
|
||||
<p class="important">
|
||||
<htk-text form="iter" column="title"/>
|
||||
</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
|
||||
|
||||
require_once ('vn/web/app.php');
|
||||
require_once 'vn-autoload.php';
|
||||
|
||||
$webApp = new Vn\Web\App ('hedera-web');
|
||||
$webApp->run ();
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -3,7 +3,7 @@ Vn.include ('js/sql/main');
|
|||
Vn.includeLib ('db',
|
||||
[
|
||||
'db'
|
||||
,'conn'
|
||||
,'connection'
|
||||
,'result'
|
||||
,'result-set'
|
||||
,'model'
|
||||
|
|
|
@ -45,7 +45,7 @@ Db.Model.implement
|
|||
**/
|
||||
conn:
|
||||
{
|
||||
type: Db.Conn
|
||||
type: Db.Connection
|
||||
,set: function (x)
|
||||
{
|
||||
this._conn = x;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ Vn.Gui = new Class
|
|||
{
|
||||
conn:
|
||||
{
|
||||
type: Db.Conn
|
||||
type: Db.Connection
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_conn: x},
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
<div id="left-panel" class="left-panel">
|
||||
<div class="menu-overflow">
|
||||
<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">
|
||||
<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>
|
||||
<p id="user-name"/>
|
||||
</div>
|
||||
|
@ -29,18 +29,18 @@
|
|||
<ul id="main-menu" class="main-menu"></ul>
|
||||
</div>
|
||||
<div class="links">
|
||||
<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="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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="body">
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -50,32 +50,7 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<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 id="social" class="social"/>
|
||||
<div class="contact">
|
||||
<p><t>Login mail</t></p>
|
||||
<p><t>Login phone</t></p>
|
||||
|
|
|
@ -8,8 +8,8 @@ Vn.Tpv = new Class
|
|||
|
||||
,check: function (callback)
|
||||
{
|
||||
this.tpvOrder = Vn.Hash.get ('tpv_order');
|
||||
this.tpvStatus = Vn.Hash.get ('tpv_status');
|
||||
this.tpvOrder = Vn.Hash.get ('tpvOrder');
|
||||
this.tpvStatus = Vn.Hash.get ('tpvStatus');
|
||||
|
||||
if (this.tpvStatus)
|
||||
{
|
||||
|
@ -41,15 +41,14 @@ Vn.Tpv = new Class
|
|||
,'company': company
|
||||
};
|
||||
|
||||
var request = new Vn.JsonRequest ('tpv/transaction');
|
||||
request.send (params,
|
||||
this.conn.send ('tpv/transaction', params,
|
||||
this._onTransactionStart.bind (this));
|
||||
}
|
||||
else if (!isNaN (amount))
|
||||
Htk.Toast.showError (_('AmountError'));
|
||||
}
|
||||
|
||||
,_onTransactionStart: function (request, json, error)
|
||||
,_onTransactionStart: function (json, error)
|
||||
{
|
||||
if (json)
|
||||
{
|
||||
|
@ -113,8 +112,8 @@ Vn.Tpv = new Class
|
|||
path += location.search ? location.search : '';
|
||||
path += Vn.Hash.make ({
|
||||
'form': 'ecomerce/orders',
|
||||
'tpv_status': status,
|
||||
'tpv_order': '%s'
|
||||
'tpvStatus': status,
|
||||
'tpvOrder': '%s'
|
||||
}, true);
|
||||
|
||||
return path;
|
||||
|
|
|
@ -27,6 +27,13 @@ Htk.ColumnImage = new Class
|
|||
{
|
||||
type: String
|
||||
,value: null
|
||||
},
|
||||
/**
|
||||
* The REST connection used to upload the image.
|
||||
**/
|
||||
conn:
|
||||
{
|
||||
type: Vn.JsonConnection
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +49,8 @@ Htk.ColumnImage = new Class
|
|||
directory: this.directory
|
||||
,subdir: this.subdir
|
||||
,fullDir: this.fullDir
|
||||
,value: this.value
|
||||
,value: this.value
|
||||
,conn: this.conn
|
||||
});
|
||||
|
||||
var td = this.parent (tr);
|
||||
|
|
|
@ -13,7 +13,7 @@ Htk.Button = new Class
|
|||
}
|
||||
|
||||
},
|
||||
icon:
|
||||
/* icon:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
|
@ -22,7 +22,7 @@ Htk.Button = new Class
|
|||
}
|
||||
|
||||
},
|
||||
tip:
|
||||
*/ tip:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
|
|
|
@ -54,6 +54,13 @@ Htk.Image = new Class
|
|||
{
|
||||
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 ();
|
||||
|
||||
var editor = new Htk.ImageEditor ();
|
||||
var editor = new Htk.ImageEditor ({conn: this.conn});
|
||||
editor.setData (this.value, this._directory);
|
||||
editor.on ('name-changed', this._onNameChange, this);
|
||||
editor.on ('file-uploaded', this._onFileUpload, this);
|
||||
|
|
|
@ -9,6 +9,16 @@ Vn.define (function () {
|
|||
Htk.ImageEditor = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
,Properties:
|
||||
{
|
||||
/**
|
||||
* The REST connection used to upload the image.
|
||||
**/
|
||||
conn:
|
||||
{
|
||||
type: Vn.JsonConnection
|
||||
}
|
||||
}
|
||||
|
||||
,initialize: function (props)
|
||||
{
|
||||
|
@ -16,7 +26,7 @@ Htk.ImageEditor = new Class
|
|||
|
||||
var self = this;
|
||||
this.$('form').onsubmit = function ()
|
||||
{ self.onSubmit (); return false; };
|
||||
{ self._onSubmit (); return false; };
|
||||
|
||||
this.parent (props);
|
||||
}
|
||||
|
@ -31,17 +41,16 @@ Htk.ImageEditor = new Class
|
|||
this.signalEmit ('name-changed', newValue);
|
||||
}
|
||||
|
||||
,onSubmit: function ()
|
||||
,_onSubmit: function ()
|
||||
{
|
||||
this.$('submit').disabled = true;
|
||||
this.$('spinner').start ();
|
||||
|
||||
var request = new Vn.JsonRequest ();
|
||||
request.sendFormMultipart (this.$('form'),
|
||||
this.onResponse.bind (this));
|
||||
this.conn.sendFormMultipart (this.$('form'),
|
||||
this._onResponse.bind (this));
|
||||
}
|
||||
|
||||
,onResponse: function (request, json, error)
|
||||
,_onResponse: function (request, json, error)
|
||||
{
|
||||
this.$('submit').disabled = false;
|
||||
this.$('spinner').stop ();
|
||||
|
|
|
@ -16,10 +16,10 @@ Vn.JsonConnection = new Class
|
|||
{
|
||||
this.parent ();
|
||||
|
||||
if (localStorage.getItem ('token'))
|
||||
this._token = localStorage.getItem ('token');
|
||||
if (sessionStorage.getItem ('token'))
|
||||
this._token = sessionStorage.getItem ('token');
|
||||
if (localStorage.getItem ('vnToken'))
|
||||
this._token = localStorage.getItem ('vnToken');
|
||||
if (sessionStorage.getItem ('vnToken'))
|
||||
this._token = sessionStorage.getItem ('vnToken');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,10 +58,12 @@ Vn.JsonConnection = new Class
|
|||
this._token = json.token;
|
||||
|
||||
var storage = remember ? localStorage : sessionStorage;
|
||||
storage.setItem ('token', this._token);
|
||||
storage.setItem ('vnToken', this._token);
|
||||
|
||||
this.signalEmit ('openned');
|
||||
}
|
||||
else
|
||||
this._closeClient ();
|
||||
|
||||
if (callback)
|
||||
callback (this, this._connected, error);
|
||||
|
@ -74,6 +76,7 @@ Vn.JsonConnection = new Class
|
|||
**/
|
||||
,close: function (callback)
|
||||
{
|
||||
this._closeClient ();
|
||||
this.send ('core/logout', null,
|
||||
this._onClose.bind (this, callback));
|
||||
}
|
||||
|
@ -83,12 +86,20 @@ Vn.JsonConnection = new Class
|
|||
*/
|
||||
,_onClose: function (callback, json, error)
|
||||
{
|
||||
this._connected = false;
|
||||
this.signalEmit ('closed');
|
||||
|
||||
if (callback)
|
||||
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
|
||||
|
@ -180,7 +191,7 @@ Vn.JsonConnection = new Class
|
|||
if (request.status == 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ();
|
||||
}
|
||||
|
||||
$this->includeJs ('js/vn/vn.js');
|
||||
$this->includeJs ('js/vn/locale.js');
|
||||
$this->includeJs ('pages/main/main.js');
|
||||
$this->includeJs ('hedera-web.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 name="viewport" content="user-scalable=no"/>
|
||||
<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>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<meta name="viewport" content="user-scalable=no"/>
|
||||
<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>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<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>
|
||||
</div>
|
||||
<div id="continue">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<meta name="viewport" content="user-scalable=no"/>
|
||||
<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>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<div>
|
||||
<a href="https://test-www.verdnatura.es/">
|
||||
<div>
|
||||
<img src="<?=__DIR__?>/new-web.svg" alt=""></img>
|
||||
<img src="<?=$dir?>/new-web.svg" alt=""></img>
|
||||
<p>
|
||||
<?=s('New website')?>
|
||||
</p>
|
||||
|
@ -27,7 +27,7 @@
|
|||
<div>
|
||||
<a href="?skipVersion=true">
|
||||
<div>
|
||||
<img src="<?=__DIR__?>/old-web.svg" alt=""></img>
|
||||
<img src="<?=$dir?>/old-web.svg" alt=""></img>
|
||||
<p>
|
||||
<?=s('Old website')?>
|
||||
</p>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/rest-request.php');
|
||||
require_once ('PEAR.php');
|
||||
require_once ('Text/CAPTCHA.php');
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
|
||||
class Log extends Vn\Web\JsonRequest
|
||||
{
|
||||
const PARAMS = [
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
require_once ('vn/web/jwt.php');
|
||||
|
||||
const MIN = 60;
|
||||
const HOUR = 60 * MIN;
|
||||
const DAY = 24 * HOUR;
|
||||
|
@ -14,16 +11,17 @@ class Login extends Vn\Web\JsonRequest
|
|||
{
|
||||
$this->updateCredentials ($db);
|
||||
|
||||
if (isset ($_POST['remember']))
|
||||
if (!empty ($_POST['remember']))
|
||||
$tokenLife = WEEK;
|
||||
else
|
||||
$tokenLife = 30 * MIN;
|
||||
|
||||
$token = Vn\Web\Jwt::encode ([
|
||||
'userName' => $_SESSION['user'],
|
||||
'timestamp' => time (),
|
||||
$payload = [
|
||||
'sub' => $_SESSION['user'],
|
||||
'exp' => time () + $tokenLife
|
||||
]);
|
||||
];
|
||||
$key = $db->getValue ('SELECT jwtKey FROM config');
|
||||
$token = Vn\Web\Jwt::encode ($payload, $key);
|
||||
|
||||
return [
|
||||
'login' => TRUE,
|
||||
|
@ -36,6 +34,9 @@ class Login extends Vn\Web\JsonRequest
|
|||
**/
|
||||
function updateCredentials ($db)
|
||||
{
|
||||
if (empty ($_POST['password']))
|
||||
return;
|
||||
|
||||
$hasAccount = $db->getValue (
|
||||
'SELECT COUNT(*) > 0
|
||||
FROM account.user u
|
||||
|
@ -60,7 +61,7 @@ class Login extends Vn\Web\JsonRequest
|
|||
}
|
||||
|
||||
$user = $this->escape ($_SESSION['user']);
|
||||
$pass = $this->escape ($_SESSION['password']);
|
||||
$pass = $this->escape ($_POST['password']);
|
||||
ssh2_exec ($ssh, "samba-tool user create \"$user\" \"$pass\"");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
|
||||
class Logout extends Vn\Web\JsonRequest
|
||||
{
|
||||
function run ($db)
|
||||
{
|
||||
$this->logout ();
|
||||
$this->service->logout ();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
|
||||
use Vn\Lib;
|
||||
use Vn\Web\Security;
|
||||
|
||||
|
@ -15,10 +13,10 @@ class Query extends Vn\Web\JsonRequest
|
|||
$results = [];
|
||||
|
||||
try {
|
||||
$userDb->multiQuery ($_REQUEST['sql']);
|
||||
$db->multiQuery ($_REQUEST['sql']);
|
||||
|
||||
do {
|
||||
$result = $userDb->storeResult ();
|
||||
$result = $db->storeResult ();
|
||||
|
||||
if ($result !== FALSE)
|
||||
{
|
||||
|
@ -28,12 +26,12 @@ class Query extends Vn\Web\JsonRequest
|
|||
else
|
||||
$results[] = TRUE;
|
||||
}
|
||||
while ($userDb->moreResults () && $userDb->nextResult ());
|
||||
while ($db->moreResults () && $db->nextResult ());
|
||||
|
||||
// Checks for warnings
|
||||
|
||||
if ($userDb->checkWarnings ()
|
||||
&& ($result = $userDb->query ('SHOW WARNINGS')))
|
||||
if ($db->checkWarnings ()
|
||||
&& ($result = $db->query ('SHOW WARNINGS')))
|
||||
{
|
||||
$sql = 'SELECT description, @warn code '.
|
||||
'FROM sql_message WHERE code = @warn';
|
||||
|
@ -41,7 +39,7 @@ class Query extends Vn\Web\JsonRequest
|
|||
while ($row = $result->fetch_assoc ())
|
||||
{
|
||||
if ($row['Code'] == 1265
|
||||
&& ($warning = $userDb->getRow ($sql)))
|
||||
&& ($warning = $db->getRow ($sql)))
|
||||
trigger_error ("{$warning['code']}: {$warning['description']}", E_USER_WARNING);
|
||||
else
|
||||
trigger_error ("{$row['Code']}: {$row['Message']}", E_USER_WARNING);
|
||||
|
@ -50,7 +48,7 @@ class Query extends Vn\Web\JsonRequest
|
|||
|
||||
// Checks for errors
|
||||
|
||||
$userDb->checkError ();
|
||||
$db->checkError ();
|
||||
}
|
||||
catch (Vn\Db\Exception $e)
|
||||
{
|
||||
|
@ -64,7 +62,7 @@ class Query extends Vn\Web\JsonRequest
|
|||
{
|
||||
$sql = 'SELECT description, #code code '.
|
||||
'FROM sql_message WHERE code = #code';
|
||||
$row = $userDb->getRow ($sql, ['code' => $message]);
|
||||
$row = $db->getRow ($sql, ['code' => $message]);
|
||||
break;
|
||||
}
|
||||
case 1305: // ER_SP_DOES_NOT_EXIST
|
||||
|
@ -74,7 +72,7 @@ class Query extends Vn\Web\JsonRequest
|
|||
|
||||
$sql = 'SELECT description, @err code '.
|
||||
'FROM sql_message WHERE code = @err';
|
||||
$row = $userDb->getRow ($sql);
|
||||
$row = $db->getRow ($sql);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
|
||||
class RecoverPassword extends Vn\Web\JsonRequest
|
||||
{
|
||||
const PARAMS = ['user'];
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
|
||||
use Vn\Lib;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/rest-request.php');
|
||||
require_once ('vn/web/util.php');
|
||||
|
||||
use Vn\Web\Security;
|
||||
use Vn\Web\Util;
|
||||
|
||||
class Invoice extends Vn\Web\RestRequest
|
||||
{
|
||||
|
@ -18,7 +16,7 @@ class Invoice extends Vn\Web\RestRequest
|
|||
if (!$pdfPath)
|
||||
throw new Exception (s('Invoice id not found'));
|
||||
|
||||
Vn\Web\printFile ($pdfPath);
|
||||
Util::printFile ($pdfPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once (__DIR__.'/lib/method.php');
|
||||
require_once __DIR__.'/lib/method.php';
|
||||
|
||||
class Clean extends Edi\Method
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/lib/method.php');
|
||||
require_once (__DIR__.'/lib.php');
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/lib/method.php');
|
||||
require_once (__DIR__.'/util.php');
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/rest-request.php');
|
||||
require_once (__DIR__.'/util.php');
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
require_once (__DIR__.'/util.php');
|
||||
|
||||
use Vn\Lib;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
require_once ('libphp-phpmailer/PHPMailerAutoload.php');
|
||||
|
||||
use Vn\Lib;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/lib/method.php');
|
||||
|
||||
/**
|
||||
* Ejemplo:
|
||||
* <Cube><Cube time="2010-12-10"><Cube currency="USD" rate="1.3244"/>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/lib/method.php');
|
||||
require_once ('libphp-phpmailer/PHPMailerAutoload.php');
|
||||
|
||||
class Mail extends Vn\Lib\Method
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
|
||||
use Vn\Lib;
|
||||
|
||||
class Sms extends Vn\Web\JsonRequest
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/lib/method.php');
|
||||
|
||||
class VisitsSync extends Vn\Lib\Method
|
||||
{
|
||||
function run ($db)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/lib/method.php');
|
||||
require_once (__DIR__.'/tpv.php');
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/rest-request.php');
|
||||
require_once (__DIR__.'/tpv.php');
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/rest-request.php');
|
||||
require_once ('vn/web/util.php');
|
||||
require_once (__DIR__.'/tpv.php');
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/tpv/tpv.php');
|
||||
|
||||
if (isset ($_POST['key']))
|
||||
{
|
||||
ini_set ('soap.wsdl_cache_enabled', FALSE);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require_once ('vn/web/json-request.php');
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
require_once ('vn/lib/app.php');
|
||||
|
||||
/**
|
||||
* 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
|
||||
* or the default config file if isn't defined a file for the vhost.
|
||||
*
|
||||
* @return string The config file name
|
||||
**/
|
||||
function getConfigFile ()
|
||||
{
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Vn\Web;
|
||||
|
||||
require_once (__DIR__.'/service.php');
|
||||
|
||||
use Vn\Lib\Locale;
|
||||
|
||||
/**
|
||||
|
@ -86,6 +84,7 @@ class HtmlService extends Service
|
|||
require ($phpFile);
|
||||
|
||||
$this->printHeader ();
|
||||
$dir = $basePath;
|
||||
include ("$basePath/html.php");
|
||||
}
|
||||
else
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Vn\Web;
|
||||
|
||||
require_once (__DIR__.'/json-exception.php');
|
||||
|
||||
/**
|
||||
* Class used for replies.
|
||||
*
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Vn\Web;
|
||||
|
||||
require_once (__DIR__.'/json-service.php');
|
||||
require_once (__DIR__.'/rest-request.php');
|
||||
|
||||
/**
|
||||
* Base class for JSON services.
|
||||
**/
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
namespace Vn\Web;
|
||||
|
||||
require_once (__DIR__.'/rest-service.php');
|
||||
require_once (__DIR__.'/json-request.php');
|
||||
require_once (__DIR__.'/json-reply.php');
|
||||
|
||||
use Vn\Lib;
|
||||
|
||||
/**
|
|
@ -71,7 +71,7 @@ class Jwt
|
|||
|
||||
static function jsonB64Decode ($data)
|
||||
{
|
||||
return json_decode (self::base64UrlDecode ($data));
|
||||
return json_decode (self::base64UrlDecode ($data), TRUE);
|
||||
}
|
||||
|
||||
static function base64UrlEncode ($data)
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Vn\Web;
|
||||
|
||||
require_once (__DIR__.'/rest-service.php');
|
||||
|
||||
class Security
|
||||
{
|
||||
const DEFINER = 1;
|
||||
|
@ -17,6 +15,8 @@ abstract class RestRequest extends \Vn\Lib\Method
|
|||
{
|
||||
const PARAMS = NULL;
|
||||
const SECURITY = Security::DEFINER;
|
||||
|
||||
var $service;
|
||||
}
|
||||
|
||||
?>
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Vn\Web;
|
||||
|
||||
require_once (__DIR__.'/service.php');
|
||||
require_once (__DIR__.'/rest-request.php');
|
||||
|
||||
use Vn\Lib;
|
||||
|
||||
/**
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
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\UserException;
|
||||
|
||||
|
@ -46,9 +42,8 @@ abstract class Service
|
|||
{
|
||||
$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.cookie_path', 'cookies');
|
||||
ini_set ('session.hash_function', 'sha256');
|
||||
|
||||
session_set_save_handler (new DbSessionHandler ($db));
|
||||
|
@ -159,15 +154,15 @@ abstract class Service
|
|||
$token = $_POST['token'];
|
||||
if (isset ($_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);
|
||||
$expiration = $jwtPayload['exp'];
|
||||
|
||||
if (isset ($expiration) && $expiration > time())
|
||||
if (empty ($expiration) || $expiration <= time())
|
||||
throw new SessionExpiredException ();
|
||||
|
||||
$user = $jwtPayload['user'];
|
||||
$user = $jwtPayload['sub'];
|
||||
}
|
||||
else
|
||||
$user = $db->getValue ('SELECT guest_user FROM config');
|
||||
|
@ -211,9 +206,9 @@ abstract class Service
|
|||
if ($this->userDb)
|
||||
return $this->userDb;
|
||||
|
||||
$password = $sysDb->getValue (
|
||||
'SELECT password FROM user WHERE name = #', [$user]);
|
||||
return $this->userDb = $this->createConnection ($user, $password);
|
||||
$password = $this->db->getValue (
|
||||
'SELECT password FROM account.user WHERE name = #', [$user]);
|
||||
return $this->userDb = $this->app->createConnection ($user, $password);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,6 +221,7 @@ abstract class Service
|
|||
|
||||
$method = $this->app->loadMethod (
|
||||
$_REQUEST['method'], $class, './rest');
|
||||
$method->service = $this;
|
||||
|
||||
if ($method::SECURITY == Security::DEFINER)
|
||||
{
|
||||
|
@ -238,7 +234,7 @@ abstract class Service
|
|||
$methodDb = $db;
|
||||
}
|
||||
else
|
||||
$methodDb = $this->getUserDb ();
|
||||
$methodDb = $this->getUserDb ($_SESSION['user']);
|
||||
|
||||
|
||||
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
|
||||
* modification date of the main script.
|
||||
*
|
||||
* @return string The version number
|
||||
**/
|
||||
function getVersion ()
|
||||
{
|
||||
return (int) strftime ('%G%m%d%H%M%S',
|
||||
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