forked from verdnatura/hedera-web
Alpha version
This commit is contained in:
parent
1c5612a840
commit
25ddb17f35
|
@ -6,7 +6,7 @@ Vn.Contact = new Class
|
||||||
,activate: function ()
|
,activate: function ()
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
var form = this.$('contact-form').onsubmit = function ()
|
this.$('contact-form').onsubmit = function ()
|
||||||
{ self.onSubmit (); return false; };
|
{ self.onSubmit (); return false; };
|
||||||
|
|
||||||
this.refreshCaptcha ();
|
this.refreshCaptcha ();
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/hedera/hedera.php');
|
|
||||||
require_once ('vn/lib/cli-app.php');
|
require_once ('vn/lib/cli-app.php');
|
||||||
|
|
||||||
$cliApp = new Vn\Lib\CliApp (Vn\Hedera\APP_NAME, 'rest');
|
$cliApp = new Vn\Lib\CliApp ('hedera-web', 'rest');
|
||||||
$cliApp->run ();
|
$cliApp->run ();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/hedera/hedera.php');
|
|
||||||
require_once ('vn/web/html-app.php');
|
require_once ('vn/web/html-app.php');
|
||||||
|
|
||||||
$htmlApp = new Vn\Web\HtmlApp (Vn\Hedera\APP_NAME, 'pages');
|
$htmlApp = new Vn\Web\HtmlApp ('hedera-web', 'pages');
|
||||||
$htmlApp->run ();
|
$htmlApp->run ();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -41,7 +41,7 @@ Vn.Tpv = new Class
|
||||||
,'company': company
|
,'company': company
|
||||||
};
|
};
|
||||||
|
|
||||||
var request = new Vn.JsonRequest ('tpv');
|
var request = new Vn.JsonRequest ('tpv/transaction');
|
||||||
request.send (params,
|
request.send (params,
|
||||||
this._onTransactionStart.bind (this));
|
this._onTransactionStart.bind (this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ Htk.Image = new Class
|
||||||
,_onFileUpload: function (cell, editor)
|
,_onFileUpload: function (cell, editor)
|
||||||
{
|
{
|
||||||
this._stamp = new Date ().getTime ();
|
this._stamp = new Date ().getTime ();
|
||||||
this.setSrc (cell);
|
this._refreshSrc (cell);
|
||||||
this.popup.hide ();
|
this.popup.hide ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ Htk.ImageEditor = new Class
|
||||||
{
|
{
|
||||||
this.builderInit (this.constructor.Xml);
|
this.builderInit (this.constructor.Xml);
|
||||||
|
|
||||||
this.$('max-size').value = 10 /* MB */ * 1048576;
|
var self = this;
|
||||||
this.$('form').action =
|
this.$('form').onsubmit = function ()
|
||||||
'//'+ Vn.Config['image_host'] +'/rest.php?action=image';
|
{ self.onSubmit (); return false; };
|
||||||
|
|
||||||
this.parent (props);
|
this.parent (props);
|
||||||
}
|
}
|
||||||
|
@ -31,30 +31,28 @@ Htk.ImageEditor = new Class
|
||||||
this.signalEmit ('name-changed', newValue);
|
this.signalEmit ('name-changed', newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
,onFormSubmit: function ()
|
,onSubmit: function ()
|
||||||
{
|
{
|
||||||
this.$('submit').disabled = true;
|
this.$('submit').disabled = true;
|
||||||
this.$('spinner').start ();
|
this.$('spinner').start ();
|
||||||
|
|
||||||
|
var request = new Vn.JsonRequest ();
|
||||||
|
request.sendFormMultipart (this.$('form'),
|
||||||
|
this.onResponse.bind (this));
|
||||||
}
|
}
|
||||||
|
|
||||||
,onIframeLoad: function ()
|
,onResponse: function (request, json, error)
|
||||||
{
|
{
|
||||||
this.$('submit').disabled = false;
|
this.$('submit').disabled = false;
|
||||||
this.$('spinner').stop ();
|
this.$('spinner').stop ();
|
||||||
|
|
||||||
try {
|
if (json)
|
||||||
var responseText = this.$('iframe').contentDocument.body.textContent;
|
{
|
||||||
var response = eval ('('+ responseText +')');
|
Htk.Toast.showMessage (_('ImageAdded'));
|
||||||
|
this.signalEmit ('file-uploaded', this.$('name').value);
|
||||||
if (response.data)
|
|
||||||
{
|
|
||||||
this.signalEmit ('file-uploaded', this.$('name').value);
|
|
||||||
Htk.Toast.showMessage (_('ImageAdded'));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Htk.Toast.showError (response.error.message +' ('+ response.error.code +')');
|
|
||||||
}
|
}
|
||||||
catch (e) {}
|
else
|
||||||
|
Htk.Toast.showError (error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
,setData: function (image, directory)
|
,setData: function (image, directory)
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
<form
|
<form
|
||||||
id="form"
|
id="form"
|
||||||
method="post"
|
method="post"
|
||||||
target="image-editor"
|
action="json.php?method=image/upload"
|
||||||
enctype="multipart/form-data"
|
enctype="multipart/form-data">
|
||||||
on-submit="onFormSubmit">
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name"><t>FileName</t></label>
|
<label for="name"><t>FileName</t></label>
|
||||||
<input id="name" type="text" name="name" on-change="onNameChange"/>
|
<input id="name" type="text" name="name" on-change="onNameChange"/>
|
||||||
|
@ -22,9 +21,5 @@
|
||||||
<input id="schema" type="hidden" name="schema"/>
|
<input id="schema" type="hidden" name="schema"/>
|
||||||
<input id="max-size" type="hidden" name="MAX_FILE_SIZE"/>
|
<input id="max-size" type="hidden" name="MAX_FILE_SIZE"/>
|
||||||
</form>
|
</form>
|
||||||
<iframe
|
|
||||||
id="iframe"
|
|
||||||
name="image-editor"
|
|
||||||
on-load="onIframeLoad"/>
|
|
||||||
</div>
|
</div>
|
||||||
</vn>
|
</vn>
|
||||||
|
|
|
@ -75,5 +75,14 @@ Vn.JsonRequest = new Class
|
||||||
|
|
||||||
this.sendWithUrl (params, callback, form.method, form.action);
|
this.sendWithUrl (params, callback, form.method, form.action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
,sendFormMultipart: function (form, callback)
|
||||||
|
{
|
||||||
|
var request = new XMLHttpRequest ();
|
||||||
|
request.open (form.method, form.action, true);
|
||||||
|
request.onreadystatechange =
|
||||||
|
this._onStateChange.bind (this, request, callback);
|
||||||
|
request.send (new FormData (form));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
3
json.php
3
json.php
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/hedera/hedera.php');
|
|
||||||
require_once ('vn/web/json-app.php');
|
require_once ('vn/web/json-app.php');
|
||||||
|
|
||||||
$restApp = new Vn\Web\JsonApp (Vn\Hedera\APP_NAME, 'rest');
|
$restApp = new Vn\Web\JsonApp ('hedera-web', 'rest');
|
||||||
$restApp->run ();
|
$restApp->run ();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -11,6 +11,6 @@ Vn.include ('js/hedera/main');
|
||||||
|
|
||||||
Vn.main (function ()
|
Vn.main (function ()
|
||||||
{
|
{
|
||||||
app = new Vn.App ();
|
hederaWeb = new Vn.App ();
|
||||||
app.run ();
|
hederaWeb.run ();
|
||||||
});
|
});
|
||||||
|
|
3
rest.php
3
rest.php
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/hedera/hedera.php');
|
|
||||||
require_once ('vn/web/rest-app.php');
|
require_once ('vn/web/rest-app.php');
|
||||||
|
|
||||||
$restApp = new Vn\Web\RestApp (Vn\Hedera\APP_NAME, 'rest');
|
$restApp = new Vn\Web\RestApp ('hedera-web', 'rest');
|
||||||
$restApp->run ();
|
$restApp->run ();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/http-request.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');
|
||||||
|
|
||||||
class Captcha extends Vn\Web\HttpRequest
|
class Captcha extends Vn\Web\RestRequest
|
||||||
{
|
{
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,8 +20,10 @@ class Log extends Vn\Web\JsonRequest
|
||||||
|
|
||||||
if (!$this->checkParams ($_REQUEST, $params))
|
if (!$this->checkParams ($_REQUEST, $params))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
error_log (sprintf ('Browser: %s(%d): %s. Stack: %s'
|
$user = isset ($_SESSION['user']) ? $_SESSION['user'] : 'guest';
|
||||||
|
error_log (sprintf ("Javascript: User: %s: %s(%d): %s.\n%s"
|
||||||
|
,$user
|
||||||
,$_REQUEST['file']
|
,$_REQUEST['file']
|
||||||
,$_REQUEST['line']
|
,$_REQUEST['line']
|
||||||
,$_REQUEST['message']
|
,$_REQUEST['message']
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Login extends Vn\Web\JsonRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escapes the double cuotes from an string.
|
* Escapes the double quotes from an string.
|
||||||
**/
|
**/
|
||||||
function escape ($str)
|
function escape ($str)
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,7 +128,7 @@ class Query extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
if ($row['Code'] == 1265
|
if ($row['Code'] == 1265
|
||||||
&& ($warning = $db->getRow ($sql)))
|
&& ($warning = $db->getRow ($sql)))
|
||||||
$this->app->addWarning ($warning['description'], $warning['code']);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ class Query extends Vn\Web\JsonRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row)
|
if ($row)
|
||||||
throw new Lib\Exception ($row['description'], $row['code']);
|
throw new Lib\UserException ($row['description'], $row['code']);
|
||||||
else
|
else
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
require_once ('vn/web/rest-request.php');
|
||||||
require_once ('vn/web/util.php');
|
require_once ('vn/web/util.php');
|
||||||
|
|
||||||
class Invoice extends Vn\Web\JsonRequest
|
class Invoice extends Vn\Web\RestRequest
|
||||||
{
|
{
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Vn\Hedera;
|
class Image
|
||||||
|
|
||||||
static class Image
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates an image resource from a valid image file.
|
* Creates an image resource from a valid image file.
|
||||||
|
@ -140,7 +138,7 @@ static class Image
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$saved)
|
if (!$saved)
|
||||||
throw new Exception (sprintf (s('File save error: %s'), $dstFile), 'saveError', ));
|
throw new Exception (sprintf (s('File save error: %s'), $dstFile), 'saveError');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once (__DIR__.'/image-method.php');
|
require_once ('vn/lib/method.php');
|
||||||
|
require_once (__DIR__.'/lib.php');
|
||||||
use Vn\Hedera\Image;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resizes all images allocated in a directory.
|
* Resizes all images allocated in a directory.
|
||||||
|
@ -13,7 +12,7 @@ use Vn\Hedera\Image;
|
||||||
* @param integer $maxWidth The maximum width of resized image in pixels
|
* @param integer $maxWidth The maximum width of resized image in pixels
|
||||||
* @param boolean $rewrite Wether to rewrite the destination file if it exits
|
* @param boolean $rewrite Wether to rewrite the destination file if it exits
|
||||||
**/
|
**/
|
||||||
class Resize extends ImageMethod
|
class Resize extends Vn\Lib\Method
|
||||||
{
|
{
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
|
@ -65,7 +64,7 @@ class Resize extends ImageMethod
|
||||||
catch (\Exception $e) {}
|
catch (\Exception $e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $count;
|
echo "$count files resized";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once (__DIR__.'/image-request.php');
|
require_once ('vn/lib/method.php');
|
||||||
|
require_once (__DIR__.'/util.php');
|
||||||
use Vn\Hedera\Image;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Syncronizes the data directory with the database, this may take
|
* Syncronizes the data directory with the database, this may take
|
||||||
* some time.
|
* some time.
|
||||||
**/
|
**/
|
||||||
class Sync extends ImageRequest
|
class Sync extends Vn\Lib\Method
|
||||||
{
|
{
|
||||||
private $trashSubdir;
|
private $trashSubdir;
|
||||||
|
private $util;
|
||||||
|
|
||||||
|
function __construct ($app)
|
||||||
|
{
|
||||||
|
parent::__construct ($app);
|
||||||
|
$this->util = new Util ($app);
|
||||||
|
$this->dataDir = $this->util->dataDir;
|
||||||
|
}
|
||||||
|
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
|
@ -79,7 +86,7 @@ class Sync extends ImageRequest
|
||||||
$this->cleanImages ($schema, $size, $map);
|
$this->cleanImages ($schema, $size, $map);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
echo "Syncronization finished";
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanImages ($schema, $size, &$map)
|
function cleanImages ($schema, $size, &$map)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once (__DIR__.'/image-request.php');
|
require_once ('vn/web/rest-request.php');
|
||||||
|
require_once (__DIR__.'/util.php');
|
||||||
use Vn\Hedera\Image;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a thumb from an existing full image.
|
* Creates a thumb from an existing full image.
|
||||||
|
@ -12,7 +11,7 @@ use Vn\Hedera\Image;
|
||||||
* @param integer $width The width of the thumb
|
* @param integer $width The width of the thumb
|
||||||
* @param integer $height The height of the thumb
|
* @param integer $height The height of the thumb
|
||||||
**/
|
**/
|
||||||
class Thumb extends ImageRequest
|
class Thumb extends Vn\Web\RestRequest
|
||||||
{
|
{
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
|
@ -67,7 +66,9 @@ class Thumb extends ImageRequest
|
||||||
|
|
||||||
// Creates the thumb.
|
// Creates the thumb.
|
||||||
|
|
||||||
$baseDir = "{$this->dataDir}/$schema";
|
|
||||||
|
$util = new Util ($this->app);
|
||||||
|
$baseDir = "{$util->dataDir}/$schema";
|
||||||
$srcFile = "$baseDir/full/$file";
|
$srcFile = "$baseDir/full/$file";
|
||||||
$dstFile = "$baseDir/{$width}x{$height}/$file";
|
$dstFile = "$baseDir/{$width}x{$height}/$file";
|
||||||
$symbolicSrc = "../full/$file";
|
$symbolicSrc = "../full/$file";
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once (__DIR__.'/image-request.php');
|
require_once ('vn/web/json-request.php');
|
||||||
|
require_once (__DIR__.'/util.php');
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
use Vn\Hedera\Image;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads a file creating its corresponding sizes.
|
* Uploads a file creating its corresponding sizes.
|
||||||
**/
|
**/
|
||||||
class Upload extends ImageRequest
|
class Upload extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
static function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
$db = $this->login ();
|
$db = $this->login ();
|
||||||
|
$util = new Util ($this->app);
|
||||||
|
|
||||||
// Checks schema.
|
// Checks schema.
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ class Upload extends ImageRequest
|
||||||
throw new Lib\UserException (s('BadSchemaName'), 'badSchemaName');
|
throw new Lib\UserException (s('BadSchemaName'), 'badSchemaName');
|
||||||
|
|
||||||
$schema = $_REQUEST['schema'];
|
$schema = $_REQUEST['schema'];
|
||||||
$info = $this->loadInfo ($schema);
|
$info = $util->loadInfo ($schema);
|
||||||
|
|
||||||
if (!$info)
|
if (!$info)
|
||||||
throw new Lib\UserException (s('SchemaNotExists'), 'schemaNotExists');
|
throw new Lib\UserException (s('SchemaNotExists'), 'schemaNotExists');
|
||||||
|
@ -126,12 +127,11 @@ class Upload extends ImageRequest
|
||||||
// Resizes and saves the image.
|
// Resizes and saves the image.
|
||||||
|
|
||||||
$fileName = "{$_REQUEST['name']}.png";
|
$fileName = "{$_REQUEST['name']}.png";
|
||||||
$schemaPath = "{$this->dataDir}/$schema";
|
$schemaPath = "{$util->dataDir}/$schema";
|
||||||
$fullFile = "$schemaPath/full/$fileName";
|
$fullFile = "$schemaPath/full/$fileName";
|
||||||
$symbolicSrc = "../full/$fileName";
|
$symbolicSrc = "../full/$fileName";
|
||||||
|
|
||||||
$image = Image::create ($_FILES['image']['tmp_name']);
|
$image = Image::create ($_FILES['image']['tmp_name']);
|
||||||
|
|
||||||
Image::resizeSave ($image, $fullFile, $info['max_height'], $info['max_width']);
|
Image::resizeSave ($image, $fullFile, $info['max_height'], $info['max_width']);
|
||||||
|
|
||||||
foreach ($info['sizes'] as $size => $i)
|
foreach ($info['sizes'] as $size => $i)
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
|
||||||
require_once (__DIR__.'/image.php');
|
require_once (__DIR__.'/image.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for image methods.
|
* Base class for image methods.
|
||||||
**/
|
**/
|
||||||
abstract class ImageRequest extends Vn\Web\JsonRequest
|
class Util
|
||||||
{
|
{
|
||||||
protected $dataDir;
|
var $app;
|
||||||
|
var $dataDir;
|
||||||
|
|
||||||
function __construct ($app)
|
function __construct ($app)
|
||||||
{
|
{
|
||||||
parent::__construct ($app);
|
$this->app = $app;
|
||||||
$this->dataDir = _DATA_DIR .'/'. $app->getName () .'/image';
|
$this->dataDir = _DATA_DIR .'/'. $app->getName () .'/image';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ abstract class ImageRequest extends Vn\Web\JsonRequest
|
||||||
**/
|
**/
|
||||||
function loadInfo ($schema)
|
function loadInfo ($schema)
|
||||||
{
|
{
|
||||||
$db = $this->getSysConn ();
|
$db = $this->app->getSysConn ();
|
||||||
|
|
||||||
$info = $conn->getRow (
|
$info = $db->getRow (
|
||||||
'SELECT id, max_width, max_height, `schema`, `table`, `column`
|
'SELECT id, max_width, max_height, `schema`, `table`, `column`
|
||||||
FROM image_schema WHERE name = #schema'
|
FROM image_schema WHERE name = #schema'
|
||||||
,['schema' => $schema]
|
,['schema' => $schema]
|
||||||
|
@ -34,7 +34,7 @@ abstract class ImageRequest extends Vn\Web\JsonRequest
|
||||||
if (!$info)
|
if (!$info)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
$res = $conn->query (
|
$res = $db->query (
|
||||||
'SELECT width, height, crop
|
'SELECT width, height, crop
|
||||||
FROM image_schema_size WHERE image_schema_id = #id'
|
FROM image_schema_size WHERE image_schema_id = #id'
|
||||||
,['id' => $info['id']]
|
,['id' => $info['id']]
|
|
@ -1,13 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
require_once ('vn/lib/method.php');
|
||||||
|
|
||||||
class VisitsSync extends Vn\Web\JsonRequest
|
class VisitsSync extends Vn\Lib\Method
|
||||||
{
|
{
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
$this->login ();
|
|
||||||
|
|
||||||
$db = $this->getSysConn ();
|
$db = $this->getSysConn ();
|
||||||
$result = $db->query ("SELECT id, agent FROM visit_agent
|
$result = $db->query ("SELECT id, agent FROM visit_agent
|
||||||
WHERE version = '0.0' OR platform = 'unknown' OR cookies IS NULL ORDER BY id DESC");
|
WHERE version = '0.0' OR platform = 'unknown' OR cookies IS NULL ORDER BY id DESC");
|
||||||
|
@ -29,6 +27,8 @@ class VisitsSync extends Vn\Web\JsonRequest
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update the visit info using browscap
|
// Update the visit info using browscap
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
while ($row = $result->fetch_assoc ())
|
while ($row = $result->fetch_assoc ())
|
||||||
{
|
{
|
||||||
|
@ -40,19 +40,17 @@ class VisitsSync extends Vn\Web\JsonRequest
|
||||||
$cookies = $info->cookies;
|
$cookies = $info->cookies;
|
||||||
$id = $row['id'];
|
$id = $row['id'];
|
||||||
$stmt->execute ();
|
$stmt->execute ();
|
||||||
|
|
||||||
|
$count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = TRUE;
|
echo "$count records updated";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$result = FALSE;
|
|
||||||
|
|
||||||
if ($stmt)
|
if ($stmt)
|
||||||
$stmt->close ();
|
$stmt->close ();
|
||||||
if ($result)
|
if ($result)
|
||||||
$result->free ();
|
$result->free ();
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/http-request.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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets transaction confirmation from SOAP service.
|
* Gets transaction confirmation from SOAP service.
|
||||||
**/
|
**/
|
||||||
class ConfirmSoap extends Vn\Web\HttpRequest
|
class ConfirmSoap extends Vn\Web\RestRequest
|
||||||
{
|
{
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Vn\Tpv;
|
class Tpv
|
||||||
|
|
||||||
static class Tpv
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Tryes to confirm a transaction with the given params.
|
* Tryes to confirm a transaction with the given params.
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once ('vn/web/json-request.php');
|
require_once ('vn/web/json-request.php');
|
||||||
require_once ('vn/tpv/tpv.php');
|
|
||||||
|
|
||||||
use Vn\Lib;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new TPV transaction and returns the params.
|
* Starts a new TPV transaction and returns the params.
|
||||||
|
@ -12,15 +9,14 @@ class Transaction extends Vn\Web\JsonRequest
|
||||||
{
|
{
|
||||||
function run ()
|
function run ()
|
||||||
{
|
{
|
||||||
$this->login ();
|
$db = $this->login ();
|
||||||
|
|
||||||
if (empty ($_REQUEST['amount']))
|
if (empty ($_REQUEST['amount']))
|
||||||
throw new Exception ('Amount parameter not defined');
|
throw new Exception ('Amount parameter not defined');
|
||||||
|
|
||||||
$amount = (int) $_REQUEST['amount'];
|
$amount = (int) $_REQUEST['amount'];
|
||||||
$companyId = empty ($_REQUEST['company']) ? NULL : $_REQUEST['company'];
|
$companyId = empty ($_REQUEST['company']) ? NULL : $_REQUEST['company'];
|
||||||
|
|
||||||
$db = $this->getSysConn ();
|
|
||||||
$row = $db->getRow ('CALL transaction_start_sha256 (#, #)',
|
$row = $db->getRow ('CALL transaction_start_sha256 (#, #)',
|
||||||
[$amount, $companyId]);
|
[$amount, $companyId]);
|
||||||
|
|
||||||
|
@ -55,11 +51,11 @@ class Transaction extends Vn\Web\JsonRequest
|
||||||
$signature = base64_encode (hash_hmac ('sha256', $encodedParams, $key, TRUE));
|
$signature = base64_encode (hash_hmac ('sha256', $encodedParams, $key, TRUE));
|
||||||
$url = $row['url'];
|
$url = $row['url'];
|
||||||
|
|
||||||
$this->json ([
|
return [
|
||||||
'url' => $url
|
'url' => $url
|
||||||
,'params' => $encodedParams
|
,'params' => $encodedParams
|
||||||
,'signature' => $signature
|
,'signature' => $signature
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Vn\Hedera;
|
|
||||||
|
|
||||||
require_once ('vn/web/app.php');
|
|
||||||
|
|
||||||
const APP_NAME = 'hedera-web';
|
|
||||||
|
|
||||||
?>
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Vn\Web;
|
|
||||||
|
|
||||||
require_once (__DIR__.'/rest-app.php');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class for REST services.
|
|
||||||
**/
|
|
||||||
abstract class HttpRequest extends \Vn\Lib\Method {}
|
|
||||||
|
|
||||||
?>
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/rest-app.php');
|
require_once (__DIR__.'/rest-app.php');
|
||||||
|
require_once (__DIR__.'/json-request.php');
|
||||||
require_once (__DIR__.'/json-reply.php');
|
require_once (__DIR__.'/json-reply.php');
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/json-app.php');
|
require_once (__DIR__.'/json-app.php');
|
||||||
|
require_once (__DIR__.'/rest-request.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for JSON services.
|
* Base class for JSON services.
|
||||||
**/
|
**/
|
||||||
abstract class JsonRequest extends \Vn\Lib\Method {}
|
abstract class JsonRequest extends RestRequest {}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Vn\Web;
|
namespace Vn\Web;
|
||||||
|
|
||||||
require_once (__DIR__.'/app.php');
|
require_once (__DIR__.'/app.php');
|
||||||
|
require_once (__DIR__.'/rest-request.php');
|
||||||
|
|
||||||
use Vn\Lib;
|
use Vn\Lib;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Vn\Web;
|
||||||
|
|
||||||
|
require_once (__DIR__.'/rest-app.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for REST services.
|
||||||
|
**/
|
||||||
|
abstract class RestRequest extends \Vn\Lib\Method
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Authenticates the user agaisnt database and returns its associated
|
||||||
|
* database connection.
|
||||||
|
*
|
||||||
|
* return Db\Conn The database connection
|
||||||
|
**/
|
||||||
|
function login ()
|
||||||
|
{
|
||||||
|
return $this->app->login ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logouts the current user.
|
||||||
|
**/
|
||||||
|
function logout ()
|
||||||
|
{
|
||||||
|
$this->app->logout ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue