forked from verdnatura/hedera-web
PHP linting, bugs fixed
This commit is contained in:
parent
a57498548f
commit
d19438bad1
|
@ -1,4 +1,4 @@
|
||||||
hedera-web (1.406.03) stable; urgency=low
|
hedera-web (1.406.04) stable; urgency=low
|
||||||
|
|
||||||
* Initial Release.
|
* Initial Release.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "hedera-web",
|
"name": "hedera-web",
|
||||||
"version": "1.406.03",
|
"version": "1.406.04",
|
||||||
"description": "Verdnatura web page",
|
"description": "Verdnatura web page",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -121,8 +121,7 @@ class Account {
|
||||||
'modtype' => LDAP_MODIFY_BATCH_REPLACE,
|
'modtype' => LDAP_MODIFY_BATCH_REPLACE,
|
||||||
'values' => [$value]
|
'values' => [$value]
|
||||||
];
|
];
|
||||||
}
|
} elseif (isset($curAttrs[$attribute])) {
|
||||||
elseif (isset($curAttrs[$attribute])) {
|
|
||||||
$modifs[] = [
|
$modifs[] = [
|
||||||
'attrib' => $attribute,
|
'attrib' => $attribute,
|
||||||
'modtype' => LDAP_MODIFY_BATCH_REMOVE_ALL
|
'modtype' => LDAP_MODIFY_BATCH_REMOVE_ALL
|
||||||
|
@ -130,8 +129,7 @@ class Account {
|
||||||
}
|
}
|
||||||
|
|
||||||
$updated = ldap_modify_batch($ds, $dn, $modifs);
|
$updated = ldap_modify_batch($ds, $dn, $modifs);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$addAttrs = [];
|
$addAttrs = [];
|
||||||
|
|
||||||
foreach($attrs as $attribute => $value)
|
foreach($attrs as $attribute => $value)
|
||||||
|
@ -147,8 +145,7 @@ class Account {
|
||||||
|
|
||||||
if (!$updated)
|
if (!$updated)
|
||||||
throw new Exception("Can't update the LDAP entry: ". ldapError($ds));
|
throw new Exception("Can't update the LDAP entry: ". ldapError($ds));
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
ldap_unbind($ds);
|
ldap_unbind($ds);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@ class Login extends Vn\Web\JsonRequest {
|
||||||
,strtolower($_POST['user'])
|
,strtolower($_POST['user'])
|
||||||
,$_POST['password']
|
,$_POST['password']
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
error_log($e->getMessage());
|
error_log($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ class Query extends Vn\Web\JsonRequest {
|
||||||
if ($result !== FALSE) {
|
if ($result !== FALSE) {
|
||||||
$results[] = $this->transformResult($result);
|
$results[] = $this->transformResult($result);
|
||||||
$result->free();
|
$result->free();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$results[] = TRUE;
|
$results[] = TRUE;
|
||||||
}
|
}
|
||||||
while ($db->moreResults() && $db->nextResult());
|
while ($db->moreResults() && $db->nextResult());
|
||||||
|
@ -45,8 +44,7 @@ class Query extends Vn\Web\JsonRequest {
|
||||||
// Checks for errors
|
// Checks for errors
|
||||||
|
|
||||||
$db->checkError();
|
$db->checkError();
|
||||||
}
|
} catch (Vn\Db\Exception $e) {
|
||||||
catch (Vn\Db\Exception $e) {
|
|
||||||
if ($e->getCode() == 1644) {
|
if ($e->getCode() == 1644) {
|
||||||
$dbMessage = $e->getMessage();
|
$dbMessage = $e->getMessage();
|
||||||
$sql = 'SELECT `description` FROM `message` WHERE `code` = #';
|
$sql = 'SELECT `description` FROM `message` WHERE `code` = #';
|
||||||
|
@ -118,8 +116,7 @@ class Query extends Vn\Web\JsonRequest {
|
||||||
];
|
];
|
||||||
$tableIndex = count($resultMap['tables']) - 1;
|
$tableIndex = count($resultMap['tables']) - 1;
|
||||||
$tableMap[$column->table] = $tableIndex;
|
$tableMap[$column->table] = $tableIndex;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$tableIndex = $tableMap[$column->table];
|
$tableIndex = $tableMap[$column->table];
|
||||||
|
|
||||||
if ($column->flags & MYSQLI_PRI_KEY_FLAG)
|
if ($column->flags & MYSQLI_PRI_KEY_FLAG)
|
||||||
|
|
|
@ -96,8 +96,7 @@ class Add extends Vn\Web\JsonRequest {
|
||||||
$db->query('COMMIT');
|
$db->query('COMMIT');
|
||||||
|
|
||||||
return $docId;
|
return $docId;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$db->query('ROLLBACK');
|
$db->query('ROLLBACK');
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@ class Clean extends Edi\Method {
|
||||||
imap_expunge($imap);
|
imap_expunge($imap);
|
||||||
$count = count($messages);
|
$count = count($messages);
|
||||||
$deleted += $count;
|
$deleted += $count;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
echo "$count mails deleted from $folder mailbox\n";
|
echo "$count mails deleted from $folder mailbox\n";
|
||||||
|
|
|
@ -57,8 +57,7 @@ class Message {
|
||||||
if ($firstLoop) {
|
if ($firstLoop) {
|
||||||
if ($segment->name != $info->schema['mainTag'])
|
if ($segment->name != $info->schema['mainTag'])
|
||||||
throw new \Exception();
|
throw new \Exception();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for ($i = $info; $i; $i = $i->parentInfo)
|
for ($i = $info; $i; $i = $i->parentInfo)
|
||||||
if (isset($i->schema['childs'][$segment->name])) {
|
if (isset($i->schema['childs'][$segment->name])) {
|
||||||
$info = new SectionInfo();
|
$info = new SectionInfo();
|
||||||
|
@ -94,13 +93,11 @@ class Message {
|
||||||
$endTag = $i;
|
$endTag = $i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$info->section->segments[] = $segment;
|
$info->section->segments[] = $segment;
|
||||||
|
|
||||||
$firstLoop = FALSE;
|
$firstLoop = FALSE;
|
||||||
}}
|
}} catch (\Exception $e) {
|
||||||
catch (\Exception $e) {
|
|
||||||
throw new \Exception(sprintf('Parse error, something is wrong near "%s"',
|
throw new \Exception(sprintf('Parse error, something is wrong near "%s"',
|
||||||
substr($string, $pos, 10)));
|
substr($string, $pos, 10)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,7 @@ abstract class Method extends \Vn\Lib\Method {
|
||||||
$this->ediRun($db);
|
$this->ediRun($db);
|
||||||
imap_expunge($imap);
|
imap_expunge($imap);
|
||||||
imap_close($imap);
|
imap_close($imap);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
error_log(imap_last_error());
|
error_log(imap_last_error());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,8 +157,7 @@ class Load extends Edi\Method {
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->query('COMMIT');
|
$db->query('COMMIT');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$db->query('ROLLBACK');
|
$db->query('ROLLBACK');
|
||||||
$error = $e->getMessage();
|
$error = $e->getMessage();
|
||||||
break;
|
break;
|
||||||
|
@ -172,8 +171,7 @@ class Load extends Edi\Method {
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$folder = $this->imapConf['success_folder'];
|
$folder = $this->imapConf['success_folder'];
|
||||||
echo "Mail loaded with $count lines.\n";
|
echo "Mail loaded with $count lines.\n";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$folder = $this->imapConf['error_folder'];
|
$folder = $this->imapConf['error_folder'];
|
||||||
echo "Mail error: $error\n";
|
echo "Mail error: $error\n";
|
||||||
}
|
}
|
||||||
|
@ -195,8 +193,7 @@ class Load extends Edi\Method {
|
||||||
$result[] = implode('.', $section);
|
$result[] = implode('.', $section);
|
||||||
else
|
else
|
||||||
$result[] = '1';
|
$result[] = '1';
|
||||||
}
|
} elseif ($part->type == TYPEMULTIPART)
|
||||||
elseif ($part->type == TYPEMULTIPART)
|
|
||||||
foreach($part->parts as $i => $subpart) {
|
foreach($part->parts as $i => $subpart) {
|
||||||
array_push($section, $i + 1);
|
array_push($section, $i + 1);
|
||||||
$this->imapFindParts($subpart, $matchTypes, $section, $result);
|
$this->imapFindParts($subpart, $matchTypes, $section, $result);
|
||||||
|
|
|
@ -41,8 +41,7 @@ class Update extends Vn\Lib\Method {
|
||||||
if ($row['updated']) {
|
if ($row['updated']) {
|
||||||
$updated = DateTime::createFromFormat('Y-m-d', $row['updated']);
|
$updated = DateTime::createFromFormat('Y-m-d', $row['updated']);
|
||||||
$updated->setTime(0, 0, 0, 0);
|
$updated->setTime(0, 0, 0, 0);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$updated = NULL;
|
$updated = NULL;
|
||||||
|
|
||||||
$remoteFile = "codes/$file.ZIP";
|
$remoteFile = "codes/$file.ZIP";
|
||||||
|
@ -100,8 +99,7 @@ class Update extends Vn\Lib\Method {
|
||||||
[$lastUpdated, $baseName]
|
[$lastUpdated, $baseName]
|
||||||
);
|
);
|
||||||
$db->query("COMMIT");
|
$db->query("COMMIT");
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$db->query('ROLLBACK');
|
$db->query('ROLLBACK');
|
||||||
error_log($e->getMessage());
|
error_log($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -112,5 +110,3 @@ class Update extends Vn\Lib\Method {
|
||||||
echo "Update completed\n";
|
echo "Update completed\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,7 @@ class Image {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new UserException(s('Bad file format'));
|
throw new UserException(s('Bad file format'));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
throw new UserException(s('Image open error'));
|
throw new UserException(s('Image open error'));
|
||||||
|
|
||||||
return $image;
|
return $image;
|
||||||
|
@ -63,7 +62,7 @@ class Image {
|
||||||
$dstWidth = $width;
|
$dstWidth = $width;
|
||||||
$dstHeight = $height;
|
$dstHeight = $height;
|
||||||
|
|
||||||
if (!$crop) // Resize {
|
if (!$crop) { // Resize
|
||||||
$ratio = NULL;
|
$ratio = NULL;
|
||||||
|
|
||||||
if ($dstWidth > $maxWidth) {
|
if ($dstWidth > $maxWidth) {
|
||||||
|
@ -77,8 +76,7 @@ class Image {
|
||||||
$dstHeight = $maxHeight;
|
$dstHeight = $maxHeight;
|
||||||
$dstWidth =(int)($dstWidth / $ratio);
|
$dstWidth =(int)($dstWidth / $ratio);
|
||||||
}
|
}
|
||||||
}
|
} else { // Cut & resize
|
||||||
else // Cut & resize {
|
|
||||||
if ($width > $maxWidth)
|
if ($width > $maxWidth)
|
||||||
$dstWidth = $maxWidth;
|
$dstWidth = $maxWidth;
|
||||||
if ($height > $maxWidth)
|
if ($height > $maxWidth)
|
||||||
|
@ -87,14 +85,12 @@ class Image {
|
||||||
if ($width <= $maxWidth) {
|
if ($width <= $maxWidth) {
|
||||||
if ($height > $srcHeight)
|
if ($height > $srcHeight)
|
||||||
$srcHeight = $maxHeight;
|
$srcHeight = $maxHeight;
|
||||||
}
|
} elseif ($height <= $maxHeight) {
|
||||||
elseif ($height <= $maxHeight) {
|
|
||||||
if ($width > $maxWidth)
|
if ($width > $maxWidth)
|
||||||
$srcWidth = $maxWidth;
|
$srcWidth = $maxWidth;
|
||||||
}
|
} else {
|
||||||
else {
|
$srcWidth = (int) ($maxWidth *($height / $maxHeight));
|
||||||
$srcWidth =(int)($maxWidth *($height / $maxHeight));
|
$srcHeight = (int) ($maxHeight *($width / $maxWidth));
|
||||||
$srcHeight =(int)($maxHeight *($width / $maxWidth));
|
|
||||||
|
|
||||||
if ($srcWidth <= $width)
|
if ($srcWidth <= $width)
|
||||||
$srcHeight = $height;
|
$srcHeight = $height;
|
||||||
|
@ -103,10 +99,10 @@ class Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width !== $srcWidth)
|
if ($width !== $srcWidth)
|
||||||
$srcX =(int)(($width / 2) -($srcWidth / 2));
|
$srcX = (int) (($width / 2) -($srcWidth / 2));
|
||||||
|
|
||||||
if ($height !== $srcHeight)
|
if ($height !== $srcHeight)
|
||||||
$srcY =(int)(($height / 2) -($srcHeight / 2));
|
$srcY = (int) (($height / 2) -($srcHeight / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
$resizedImage = imagecreatetruecolor($dstWidth, $dstHeight);
|
$resizedImage = imagecreatetruecolor($dstWidth, $dstHeight);
|
||||||
|
@ -116,11 +112,9 @@ class Image {
|
||||||
0, 0, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight);
|
0, 0, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight);
|
||||||
$saved = imagepng($resizedImage, $dstFile);
|
$saved = imagepng($resizedImage, $dstFile);
|
||||||
imagedestroy($resizedImage);
|
imagedestroy($resizedImage);
|
||||||
}
|
} elseif (isset($symbolicSrc)) {
|
||||||
elseif (isset($symbolicSrc)) {
|
|
||||||
$saved = symlink($symbolicSrc, $dstFile);
|
$saved = symlink($symbolicSrc, $dstFile);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
imagesavealpha($image, TRUE);
|
imagesavealpha($image, TRUE);
|
||||||
$saved = imagepng($image, $dstFile);
|
$saved = imagepng($image, $dstFile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,7 @@ class Resize extends Vn\Lib\Method {
|
||||||
Image::resizeSave($image, $dstFile, $maxHeight, $maxWidth, $crop, $symbolicSrc);
|
Image::resizeSave($image, $dstFile, $maxHeight, $maxWidth, $crop, $symbolicSrc);
|
||||||
imagedestroy($image);
|
imagedestroy($image);
|
||||||
$count++;
|
$count++;
|
||||||
}
|
} catch (\Exception $e) {}
|
||||||
catch (\Exception $e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "$count files resized.\n";
|
echo "$count files resized.\n";
|
||||||
|
|
|
@ -85,8 +85,7 @@ class Thumb extends Vn\Web\RestRequest {
|
||||||
if ($useXsendfile) {
|
if ($useXsendfile) {
|
||||||
header("X-Sendfile: $dstFile");
|
header("X-Sendfile: $dstFile");
|
||||||
header("Content-Type: image/png");
|
header("Content-Type: image/png");
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
header("Location: {$_SERVER['REQUEST_URI']}");
|
header("Location: {$_SERVER['REQUEST_URI']}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,7 @@ class Contact extends Vn\Web\JsonRequest {
|
||||||
$mail->SMTPAuth = TRUE;
|
$mail->SMTPAuth = TRUE;
|
||||||
$mail->Username = $conf->user;
|
$mail->Username = $conf->user;
|
||||||
$mail->Password = base64_decode($conf->password);
|
$mail->Password = base64_decode($conf->password);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$mail->SMTPAuth = FALSE;
|
$mail->SMTPAuth = FALSE;
|
||||||
|
|
||||||
if ($conf->secure) {
|
if ($conf->secure) {
|
||||||
|
|
|
@ -35,8 +35,7 @@ class Mail extends Vn\Lib\Method {
|
||||||
throw new Exception('Send error: '.$mail->ErrorInfo);
|
throw new Exception('Send error: '.$mail->ErrorInfo);
|
||||||
|
|
||||||
$count++;
|
$count++;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$sent = 2;
|
$sent = 2;
|
||||||
$status = $e->getMessage();
|
$status = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,7 @@ class ConfirmMail extends Vn\Lib\Method {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$success = Tpv::confirm($db, $params);
|
$success = Tpv::confirm($db, $params);
|
||||||
}
|
} catch (\Exception $e) {
|
||||||
catch (\Exception $e) {
|
|
||||||
trigger_error($e->getMessage(), E_USER_WARNING);
|
trigger_error($e->getMessage(), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,7 @@ function procesaNotificacionSIS($XML) {
|
||||||
// Confirms the transaction
|
// Confirms the transaction
|
||||||
|
|
||||||
Tpv::confirm($db, $params);
|
Tpv::confirm($db, $params);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$status = 'KO';
|
$status = 'KO';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ if (isset($_POST['key'])) {
|
||||||
$shaHash = sha1($shaString.$key);
|
$shaHash = sha1($shaString.$key);
|
||||||
|
|
||||||
$isValid = $xml->{'Signature'} == $shaHash;
|
$isValid = $xml->{'Signature'} == $shaHash;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$key = '';
|
$key = '';
|
||||||
$result = '';
|
$result = '';
|
||||||
$shaHash = '';
|
$shaHash = '';
|
||||||
|
|
|
@ -37,8 +37,7 @@ class App extends \Vn\Lib\App {
|
||||||
$className = __NAMESPACE__ .'\\'. hyphenToCamelCase($service, TRUE) .'Service';
|
$className = __NAMESPACE__ .'\\'. hyphenToCamelCase($service, TRUE) .'Service';
|
||||||
$service = new $className($this);
|
$service = new $className($this);
|
||||||
$service->run();
|
$service->run();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,7 @@ class HtmlService extends Service {
|
||||||
if ($updateBrowser) {
|
if ($updateBrowser) {
|
||||||
header('Location: ?method=update-browser');
|
header('Location: ?method=update-browser');
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$_SESSION['skipBrowser'] = TRUE;
|
$_SESSION['skipBrowser'] = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +84,7 @@ class HtmlService extends Service {
|
||||||
$dir = $basePath;
|
$dir = $basePath;
|
||||||
include_once __DIR__.'/html.php';
|
include_once __DIR__.'/html.php';
|
||||||
include("./$basePath/ui.php");
|
include("./$basePath/ui.php");
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
header('Location: ./');
|
header('Location: ./');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ function getWebpackAssets() {
|
||||||
foreach($wpAssets as $name => $asset)
|
foreach($wpAssets as $name => $asset)
|
||||||
if (property_exists($asset, 'js'))
|
if (property_exists($asset, 'js'))
|
||||||
$assets->$name = $asset->js;
|
$assets->$name = $asset->js;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$devServerPath = "http://$host:$devServerPort/$buildDir";
|
$devServerPath = "http://$host:$devServerPort/$buildDir";
|
||||||
$manifestJs = "$devServerPath/manifest.js";
|
$manifestJs = "$devServerPath/manifest.js";
|
||||||
$mainJs = "$devServerPath/main.js";
|
$mainJs = "$devServerPath/main.js";
|
||||||
|
|
|
@ -63,8 +63,7 @@ class JsonService extends RestService {
|
||||||
$this->warnings = [];
|
$this->warnings = [];
|
||||||
|
|
||||||
$this->warnings[] = $json;
|
$this->warnings[] = $json;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
$this->replyJson($json);
|
$this->replyJson($json);
|
||||||
exit();
|
exit();
|
||||||
|
@ -79,8 +78,7 @@ class JsonService extends RestService {
|
||||||
if (_ENABLE_DEBUG || $e instanceof Lib\UserException) {
|
if (_ENABLE_DEBUG || $e instanceof Lib\UserException) {
|
||||||
$json->exception = get_class($e);
|
$json->exception = get_class($e);
|
||||||
$json->message = $e->getMessage();
|
$json->message = $e->getMessage();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$json->exception = 'Exception';
|
$json->exception = 'Exception';
|
||||||
$json->message = s('Something went wrong');
|
$json->message = s('Something went wrong');
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@ class Mailer {
|
||||||
$mail->SMTPAuth = TRUE;
|
$mail->SMTPAuth = TRUE;
|
||||||
$mail->Username = $conf->user;
|
$mail->Username = $conf->user;
|
||||||
$mail->Password = base64_decode($conf->password);
|
$mail->Password = base64_decode($conf->password);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$mail->SMTPAuth = FALSE;
|
$mail->SMTPAuth = FALSE;
|
||||||
|
|
||||||
if ($conf->secure) {
|
if ($conf->secure) {
|
||||||
|
|
|
@ -39,8 +39,7 @@ class RestService extends Service {
|
||||||
throw new UserException(s('You don\'t have enough privileges'));
|
throw new UserException(s('You don\'t have enough privileges'));
|
||||||
|
|
||||||
$methodDb = $db;
|
$methodDb = $db;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$methodDb = $this->getUserDb($_SESSION['user']);
|
$methodDb = $this->getUserDb($_SESSION['user']);
|
||||||
|
|
||||||
if ($method::PARAMS !== NULL && !$method->checkParams($_REQUEST, $method::PARAMS))
|
if ($method::PARAMS !== NULL && !$method->checkParams($_REQUEST, $method::PARAMS))
|
||||||
|
@ -52,8 +51,7 @@ class RestService extends Service {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$res = $method->run($methodDb);
|
$res = $method->run($methodDb);
|
||||||
}
|
} catch (Db\Exception $e) {
|
||||||
catch (Db\Exception $e) {
|
|
||||||
if ($e->getCode() == 1644)
|
if ($e->getCode() == 1644)
|
||||||
throw new UserException(s($e->getMessage()));
|
throw new UserException(s($e->getMessage()));
|
||||||
}
|
}
|
||||||
|
@ -69,11 +67,15 @@ class RestService extends Service {
|
||||||
function statusFromException($e) {
|
function statusFromException($e) {
|
||||||
try {
|
try {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
} catch (SessionExpiredException $e) {
|
||||||
|
$status = 401;
|
||||||
|
} catch (BadLoginException $e) {
|
||||||
|
$status = 401;
|
||||||
|
} catch (Lib\UserException $e) {
|
||||||
|
$status = 400;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$status = 500;
|
||||||
}
|
}
|
||||||
catch (SessionExpiredException $e) { $status = 401; }
|
|
||||||
catch (BadLoginException $e) { $status = 401; }
|
|
||||||
catch (Lib\UserException $e) { $status = 400; }
|
|
||||||
catch (\Exception $e) { $status = 500; }
|
|
||||||
|
|
||||||
http_response_code($status);
|
http_response_code($status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,8 +114,7 @@ abstract class Service {
|
||||||
if (isset($row['access'])) {
|
if (isset($row['access'])) {
|
||||||
setcookie('vnVisit', $row['visit'], time() + 31536000); // 1 Year
|
setcookie('vnVisit', $row['visit'], time() + 31536000); // 1 Year
|
||||||
$_SESSION['access'] = $row['access'];
|
$_SESSION['access'] = $row['access'];
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$_SESSION['skipVisit'] = TRUE;
|
$_SESSION['skipVisit'] = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,17 +138,14 @@ abstract class Service {
|
||||||
try {
|
try {
|
||||||
$db->query('CALL account.userLogin(#, #)',
|
$db->query('CALL account.userLogin(#, #)',
|
||||||
[$user, $_POST['password']]);
|
[$user, $_POST['password']]);
|
||||||
}
|
} catch (Db\Exception $e) {
|
||||||
catch (Db\Exception $e) {
|
|
||||||
if ($e->getMessage() == 'INVALID_CREDENTIALS') {
|
if ($e->getMessage() == 'INVALID_CREDENTIALS') {
|
||||||
sleep(3);
|
sleep(3);
|
||||||
throw new BadLoginException();
|
throw new BadLoginException();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (isset($_POST['token']) || isset($_GET['token'])) {
|
if (isset($_POST['token']) || isset($_GET['token'])) {
|
||||||
if (isset($_POST['token']))
|
if (isset($_POST['token']))
|
||||||
$token = $_POST['token'];
|
$token = $_POST['token'];
|
||||||
|
@ -160,8 +156,7 @@ abstract class Service {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$jwtPayload = Jwt::decode($token, $key);
|
$jwtPayload = Jwt::decode($token, $key);
|
||||||
}
|
} catch (\Exception $e) {
|
||||||
catch (\Exception $e) {
|
|
||||||
throw new BadLoginException($e->getMessage());
|
throw new BadLoginException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,8 +271,7 @@ abstract class Service {
|
||||||
if (file_exists('package.json')) {
|
if (file_exists('package.json')) {
|
||||||
$package = json_decode(file_get_contents('package.json'));
|
$package = json_decode(file_get_contents('package.json'));
|
||||||
$version = $package->version;
|
$version = $package->version;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$version = '0.0.0';
|
$version = '0.0.0';
|
||||||
|
|
||||||
apc_store("$appName.version", $version);
|
apc_store("$appName.version", $version);
|
||||||
|
|
|
@ -21,8 +21,7 @@ class Util {
|
||||||
if ($useXsendfile) {
|
if ($useXsendfile) {
|
||||||
header("X-Sendfile: $file");
|
header("X-Sendfile: $file");
|
||||||
header("Content-Type: $mimeType");
|
header("Content-Type: $mimeType");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
header('Content-Description: File Transfer');
|
header('Content-Description: File Transfer');
|
||||||
header("Content-Type: $mimeType");
|
header("Content-Type: $mimeType");
|
||||||
header('Content-Disposition: attachment; filename="'. basename($file) .'"');
|
header('Content-Disposition: attachment; filename="'. basename($file) .'"');
|
||||||
|
|
Loading…
Reference in New Issue