0
1
Fork 0

improved README, PHP linting, bugs fixed

This commit is contained in:
Juan 2018-06-06 13:08:17 +02:00
parent d19438bad1
commit 91dec387fa
21 changed files with 62 additions and 44 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
node_modules node_modules
build/ build/
config.php config.my.php

View File

@ -1,3 +1,20 @@
# Hedera # Hedera
Hedera is the main page for Verdnatura. Hedera is the main web page for Verdnatura.
## Getting Started
Required dependencies.
* PHP >= 7.0
* Node.js >= 8.0
Launch command line client.
```
$ php hedera-web.php -m method_path
```
## Built with
* [Webpack](https://webpack.js.org/)
* [MooTools](https://mootools.net/)
* [TinyMCE](https://www.tinymce.com/)

View File

@ -14,16 +14,14 @@
* - http://test.mydomain.org -> config.test.php * - http://test.mydomain.org -> config.test.php
*/ */
return [ return [
/**
/**
* Database parameters. * Database parameters.
**/ */
'db' => [ 'db' => [
'host' => 'localhost' 'host' => 'localhost'
,'port' => 3306 ,'port' => 3306
,'schema' => 'hedera-web' ,'schema' => 'hedera-web'
,'user' => 'hedera-web' ,'user' => 'hedera-web'
,'pass' => '' ,'pass' => ''
] ]
]; ];

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.406.04) stable; urgency=low hedera-web (1.406.05) stable; urgency=low
* Initial Release. * Initial Release.

3
debian/install vendored
View File

@ -1,4 +1,5 @@
conf/* etc/hedera-web apache.conf etc/hedera-web
config.php etc/hedera-web
web usr/share/php/vn web usr/share/php/vn
doc/* usr/share/doc/hedera-web doc/* usr/share/doc/hedera-web
hedera-web.php usr/share/hedera-web hedera-web.php usr/share/hedera-web

View File

@ -1,6 +1,8 @@
<?php <?php
@include_once __DIR__.'/env.php'; if (file_exists(__DIR__.'/env.php'))
include_once __DIR__.'/env.php';
require_once 'vn-autoload.php'; require_once 'vn-autoload.php';
$webApp = new Vn\Web\App('hedera-web'); $webApp = new Vn\Web\App('hedera-web');

View File

@ -1,6 +1,6 @@
{ {
"name": "hedera-web", "name": "hedera-web",
"version": "1.406.04", "version": "1.406.05",
"description": "Verdnatura web page", "description": "Verdnatura web page",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {

View File

@ -22,7 +22,7 @@ $result = $db->query('SELECT name, content FROM metatag');
<meta name="<?=$row->name?>" content="<?=$row->content?>"/> <meta name="<?=$row->name?>" content="<?=$row->content?>"/>
<?php endwhile ?> <?php endwhile ?>
<?php foreach(getWebpackAssets() as $js): ?> <?php foreach (getWebpackAssets() as $js): ?>
<script type="text/javascript" src="<?=$js?>"></script> <script type="text/javascript" src="<?=$js?>"></script>
<?php endforeach ?> <?php endforeach ?>

View File

@ -114,7 +114,7 @@ class Account {
$modifs = []; $modifs = [];
$curAttrs = ldap_get_attributes($ds, $entry); $curAttrs = ldap_get_attributes($ds, $entry);
foreach($attrs as $attribute => $value) foreach ($attrs as $attribute => $value)
if (!empty($value)) { if (!empty($value)) {
$modifs[] = [ $modifs[] = [
'attrib' => $attribute, 'attrib' => $attribute,
@ -132,7 +132,7 @@ class Account {
} else { } else {
$addAttrs = []; $addAttrs = [];
foreach($attrs as $attribute => $value) foreach ($attrs as $attribute => $value)
if (!empty($value)) if (!empty($value))
$addAttrs[$attribute] = $value; $addAttrs[$attribute] = $value;

View File

@ -18,10 +18,10 @@ class Clean extends Edi\Method {
,$this->imapConf['error_folder'] ,$this->imapConf['error_folder']
]; ];
foreach($folders as $folder) foreach ($folders as $folder)
if (imap_reopen($imap, "{$this->mailbox}$folder")) { if (imap_reopen($imap, "{$this->mailbox}$folder")) {
if ($messages = imap_search($imap, $filter)) { if ($messages = imap_search($imap, $filter)) {
foreach($messages as $message) foreach ($messages as $message)
imap_delete($imap, $message); imap_delete($imap, $message);
imap_expunge($imap); imap_expunge($imap);

View File

@ -11,7 +11,7 @@ class Section {
var $childs = []; var $childs = [];
function getValue($name, $key, $type = NULL, $subname = NULL) { function getValue($name, $key, $type = NULL, $subname = NULL) {
foreach($this->segments as $segment) foreach ($this->segments as $segment)
if ($segment->name == $name if ($segment->name == $name
&&(!$subname || $segment->values[1] == $subname)) &&(!$subname || $segment->values[1] == $subname))
return $segment->getValue($key, $type); return $segment->getValue($key, $type);

View File

@ -18,7 +18,7 @@ class Load extends Edi\Method {
$inbox = imap_search($this->imap, 'ALL'); $inbox = imap_search($this->imap, 'ALL');
if ($inbox) { if ($inbox) {
foreach($inbox as $msg) foreach ($inbox as $msg)
$this->loadMail($db, $msg); $this->loadMail($db, $msg);
$inboxCount = count($inbox); $inboxCount = count($inbox);
@ -55,7 +55,7 @@ class Load extends Edi\Method {
$count = 0; $count = 0;
$error = NULL; $error = NULL;
foreach($result as $msgSection) foreach ($result as $msgSection)
try { try {
$part = imap_bodystruct($imap, $msg, $msgSection); $part = imap_bodystruct($imap, $msg, $msgSection);
$ediString = imap_fetchbody($imap, $msg, $msgSection); $ediString = imap_fetchbody($imap, $msg, $msgSection);
@ -87,8 +87,8 @@ class Load extends Edi\Method {
$unb = $ediMessage->section; $unb = $ediMessage->section;
$unhs = $unb->childs['UNH']; $unhs = $unb->childs['UNH'];
foreach($unhs as $unh) foreach ($unhs as $unh)
foreach($lins = $unh->childs['LIN'] as $lin) { foreach ($lins = $unh->childs['LIN'] as $lin) {
$ediValues = []; $ediValues = [];
// Gets the exchange params // Gets the exchange params
@ -194,7 +194,7 @@ class Load extends Edi\Method {
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);
array_pop($section); array_pop($section);

View File

@ -71,7 +71,7 @@ class Update extends Vn\Lib\Method {
unlink($zipFile); unlink($zipFile);
} }
foreach(glob("$ucDir/$baseName*.txt") as $fileName) foreach (glob("$ucDir/$baseName*.txt") as $fileName)
break; break;
if (!$fileName) if (!$fileName)

View File

@ -75,7 +75,7 @@ class Sync extends Vn\Lib\Method {
$this->cleanImages($schema, 'full', $map); $this->cleanImages($schema, 'full', $map);
foreach($info['sizes'] as $size => $i) foreach ($info['sizes'] as $size => $i)
$this->cleanImages($schema, $size, $map); $this->cleanImages($schema, $size, $map);
} }

View File

@ -84,7 +84,7 @@ class Upload extends Vn\Web\JsonRequest {
$image = Image::create($tmpName); $image = Image::create($tmpName);
Image::resizeSave($image, $fullFile, $info['maxHeight'], $info['maxWidth']); Image::resizeSave($image, $fullFile, $info['maxHeight'], $info['maxWidth']);
foreach($info['sizes'] as $size => $i) { foreach ($info['sizes'] as $size => $i) {
$dstFile = "$schemaPath/$size/$fileName"; $dstFile = "$schemaPath/$size/$fileName";
Image::resizeSave($image, $dstFile, $i['height'], $i['width'], $i['crop'], $symbolicSrc); Image::resizeSave($image, $dstFile, $i['height'], $i['width'], $i['crop'], $symbolicSrc);
} }

View File

@ -16,13 +16,13 @@ class ExchangeRate extends Vn\Lib\Method {
$date = $db->getValue("SELECT MAX(date) fecha FROM reference_rate"); $date = $db->getValue("SELECT MAX(date) fecha FROM reference_rate");
$maxDate = $date ? DateTime::createFromFormat('Y-m-d', $date) : NULL; $maxDate = $date ? DateTime::createFromFormat('Y-m-d', $date) : NULL;
foreach($xml->Cube[0]->Cube as $cube) { foreach ($xml->Cube[0]->Cube as $cube) {
$xmlDate = new DateTime($cube['time']); $xmlDate = new DateTime($cube['time']);
// Si existen datos más recientes de la máxima fecha los añade // Si existen datos más recientes de la máxima fecha los añade
if ($maxDate <= $xmlDate) if ($maxDate <= $xmlDate)
foreach($cube->Cube as $subCube) foreach ($cube->Cube as $subCube)
if ($subCube['currency'] == 'USD') { if ($subCube['currency'] == 'USD') {
$params = [ $params = [
'date' => $xmlDate, 'date' => $xmlDate,

View File

@ -30,14 +30,14 @@ class ConfirmMail extends Vn\Lib\Method {
$inbox = imap_search($imap, 'ALL'); $inbox = imap_search($imap, 'ALL');
if ($inbox) if ($inbox)
foreach($inbox as $msg) { foreach ($inbox as $msg) {
// Decodes the mail body // Decodes the mail body
$params = []; $params = [];
$body = imap_fetchbody($imap, $msg, '1'); $body = imap_fetchbody($imap, $msg, '1');
$strings = explode(';', $body); $strings = explode(';', $body);
foreach($strings as $string) { foreach ($strings as $string) {
$x = explode(':', $string); $x = explode(':', $string);
$params[trim($x[0])] = trim($x[1]); $params[trim($x[0])] = trim($x[1]);
} }
@ -81,10 +81,10 @@ class ConfirmMail extends Vn\Lib\Method {
$date->sub(new \DateInterval($imapConf->cleanPeriod)); $date->sub(new \DateInterval($imapConf->cleanPeriod));
$filter = sprintf('BEFORE "%s"', $date->format('D, j M Y')); $filter = sprintf('BEFORE "%s"', $date->format('D, j M Y'));
foreach($folders as $folder) foreach ($folders as $folder)
if (imap_reopen($imap, $mailbox.'.'.$folder)) if (imap_reopen($imap, $mailbox.'.'.$folder))
if ($messages = imap_search($imap, $filter)) { if ($messages = imap_search($imap, $filter)) {
foreach($messages as $message) foreach ($messages as $message)
imap_delete($imap, $message); imap_delete($imap, $message);
imap_expunge($imap); imap_expunge($imap);

View File

@ -38,7 +38,7 @@ function getWebpackAssets() {
unset($wpAssets->manifest); unset($wpAssets->manifest);
unset($wpAssets->main); unset($wpAssets->main);
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 {
@ -48,14 +48,14 @@ function getWebpackAssets() {
unset($wpConfig->entry->main); unset($wpConfig->entry->main);
foreach($wpConfig->entry as $asset => $files) foreach ($wpConfig->entry as $asset => $files)
$assets->$asset = "$devServerPath/$asset.js"; $assets->$asset = "$devServerPath/$asset.js";
} }
$jsFiles = []; $jsFiles = [];
$jsFiles[] = $manifestJs; $jsFiles[] = $manifestJs;
foreach($assets as $jsFile) foreach ($assets as $jsFile)
$jsFiles[] = $jsFile; $jsFiles[] = $jsFile;
$jsFiles[] = $mainJs; $jsFiles[] = $mainJs;

View File

@ -43,7 +43,7 @@ class Mailer {
$mailList = explode(',', $mailTo); $mailList = explode(',', $mailTo);
foreach($mailList as $to) foreach ($mailList as $to)
$mail->AddAddress($to); $mail->AddAddress($to);
return $mail; return $mail;

View File

@ -64,7 +64,7 @@ abstract class Service {
preg_match_all($regexp, $_SERVER['HTTP_ACCEPT_LANGUAGE'], $languages); preg_match_all($regexp, $_SERVER['HTTP_ACCEPT_LANGUAGE'], $languages);
foreach($languages[1] as $lang) foreach ($languages[1] as $lang)
if (TRUE || stream_resolve_include_path("locale/$lang")) { if (TRUE || stream_resolve_include_path("locale/$lang")) {
$_SESSION['lang'] = $lang; $_SESSION['lang'] = $lang;
break; break;