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