0
1
Fork 0
This commit is contained in:
Juan Ferrer Toribio 2016-08-23 15:15:19 +02:00
parent a7ed0a662a
commit 1c5612a840
14 changed files with 60 additions and 18 deletions

View File

@ -14,7 +14,7 @@ Vn.Contact = new Class
,refreshCaptcha: function ()
{
var url = 'rest.php?method=captcha';
var url = 'rest.php?method=core/captcha';
this.$('captcha-img').src = url +'&stamp='+ new Date ().getTime ();
}

View File

@ -14,7 +14,7 @@
<form
id="contact-form"
method="post"
action="rest.php?method=contact">
action="json.php?method=misc/contact">
<div class="form-group">
<label><t>Name</t></label>
<input type="text" name="name"/>

View File

@ -169,7 +169,7 @@ Vn.App = new Class
,'stack': error.stack
};
var request = new Vn.JsonRequest ('log');
var request = new Vn.JsonRequest ('core/log');
request.send (params);
}

View File

@ -7,8 +7,52 @@ class Login extends Vn\Web\JsonRequest
function run ()
{
$this->login ();
$this->updateCredentials ();
return TRUE;
}
/**
* Updates the user credentials in other user databases like Samba.
**/
function updateCredentials ()
{
$db = $this->getSysConn ();
$hasAccount = $db->getValue (
'SELECT COUNT(*) > 0
FROM account.user u
JOIN account.account a ON u.id = a.user_id
WHERE u.name = #',
[$_SESSION['user']]
);
if (!$hasAccount)
return;
$sshConf = $db->getRow ('SELECT host, user, password FROM ssh_config');
$ssh = ssh2_connect ($sshConf['host']);
$sshOk = $ssh && ssh2_auth_password ($ssh,
$sshConf['user'], base64_decode ($sshConf['password']));
if (!$sshOk)
{
error_log ("Can't connect to SSH server {$sshConf['host']}");
return;
}
$user = $this->escape ($_SESSION['user']);
$pass = $this->escape ($_SESSION['password']);
ssh2_exec ($ssh, "samba-tool user add \"$user\" \"$pass\"");
}
/**
* Escapes the double cuotes from an string.
**/
function escape ($str)
{
return str_replace ('"', '\\"', $str);
}
}
?>

View File

@ -7,7 +7,7 @@ use Vn\Lib;
/**
* Adds a document to the Document Management System.
**/
class DmsAdd extends Vn\Web\JsonRequest
class Add extends Vn\Web\JsonRequest
{
function run ()
{

View File

@ -13,7 +13,7 @@ use Vn\Hedera\Image;
* @param integer $maxWidth The maximum width of resized image in pixels
* @param boolean $rewrite Wether to rewrite the destination file if it exits
**/
class ImageResize extends ImageMethod
class Resize extends ImageMethod
{
function run ()
{

View File

@ -8,7 +8,7 @@ use Vn\Hedera\Image;
* Syncronizes the data directory with the database, this may take
* some time.
**/
class ImageSync extends ImageRequest
class Sync extends ImageRequest
{
private $trashSubdir;

View File

@ -12,7 +12,7 @@ use Vn\Hedera\Image;
* @param integer $width The width of the thumb
* @param integer $height The height of the thumb
**/
class ImageThumb extends ImageRequest
class Thumb extends ImageRequest
{
function run ()
{

View File

@ -8,7 +8,7 @@ use Vn\Hedera\Image;
/**
* Uploads a file creating its corresponding sizes.
**/
class ImageUpload extends ImageRequest
class Upload extends ImageRequest
{
static function run ()
{

View File

@ -17,21 +17,19 @@ class Contact extends Vn\Web\JsonRequest
,'phone'
,'email'
,'message'
,'captcha'
];
if (!$this->checkParams ($_REQUEST, $params)
|| !isset ($_SESSION['captcha']))
if (!$this->checkParams ($_REQUEST, $params))
throw new Lib\UserException (s('Missing parameters'), 'missingParams');
// Checks the antispam code
$lastCaptcha = $_SESSION['captcha'];
unset ($_SESSION['captcha']);
if ($_REQUEST['captcha'] !== $lastCaptcha)
if (empty ($_REQUEST['captcha']) || $_REQUEST['captcha'] !== $lastCaptcha)
throw new Lib\UserException (s('Wrong captcha'), 'wrongCaptcha');
// Sends the mail
$db = $this->getSysConn ();

View File

@ -6,7 +6,7 @@ require_once (__DIR__.'/tpv.php');
/**
* Gets transaction confirmations from the IMAP mailbox.
**/
class TpvConfirmMail extends Vn\Lib\Method
class ConfirmMail extends Vn\Lib\Method
{
function run ()
{

View File

@ -6,7 +6,7 @@ require_once (__DIR__.'/tpv.php');
/**
* Gets transaction confirmation from HTTP POST.
**/
class TpvConfirmPost extends Vn\Web\HttpRequest
class ConfirmPost extends Vn\Web\HttpRequest
{
function run ()
{

View File

@ -7,7 +7,7 @@ require_once (__DIR__.'/tpv.php');
/**
* Gets transaction confirmation from SOAP service.
**/
class TpvConfirmSoap extends Vn\Web\HttpRequest
class ConfirmSoap extends Vn\Web\HttpRequest
{
function run ()
{

View File

@ -8,7 +8,7 @@ use Vn\Lib;
/**
* Starts a new TPV transaction and returns the params.
**/
class TpvTransaction extends Vn\Web\JsonRequest
class Transaction extends Vn\Web\JsonRequest
{
function run ()
{