From 1dbf6de165391423f75fa8de3f35d4c654344db7 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 31 Aug 2016 13:53:46 +0200 Subject: [PATCH] Version Beta --- cli.php | 2 +- conf/apache.conf | 8 ++++---- pages/main/head.php | 2 +- rest/edi/clean.php | 11 ++++------- rest/edi/{schemas => lib}/CLOCKT.json | 0 rest/edi/lib/message.php | 4 ++-- rest/edi/lib/method.php | 4 +++- rest/edi/lib/section.php | 2 +- rest/edi/lib/segment.php | 2 +- rest/edi/load.php | 12 ++++++------ rest/edi/update.php | 8 +++++++- rest/misc/exchange-rate.php | 1 + rest/misc/mail.php | 6 ++++++ rest/misc/visits-sync.php | 2 +- 14 files changed, 38 insertions(+), 26 deletions(-) rename rest/edi/{schemas => lib}/CLOCKT.json (100%) diff --git a/cli.php b/cli.php index e0538a82..1c253ee1 100755 --- a/cli.php +++ b/cli.php @@ -2,7 +2,7 @@ require_once ('vn/lib/cli-app.php'); -$cliApp = new Vn\Lib\CliApp ('hedera-web'); +$cliApp = new Vn\Lib\CliApp ('hedera-web', './rest'); $cliApp->run (); ?> diff --git a/conf/apache.conf b/conf/apache.conf index 982b7c6f..981a7795 100644 --- a/conf/apache.conf +++ b/conf/apache.conf @@ -1,7 +1,7 @@ -# Alias /hedera-web /usr/share/hedera-web/web/ -# Alias /vn-image-data /var/cache/hedera-web/image/ +# Alias /hedera-web /usr/share/hedera-web/ +# Alias /vn-image-data /var/cache/hedera-web/image-db/ - + Options -Indexes -FollowSymLinks AllowOverride None @@ -21,7 +21,7 @@ - + Options Indexes FollowSymLinks MultiViews AllowOverride FileInfo Options diff --git a/pages/main/head.php b/pages/main/head.php index f1001f31..b48ec281 100755 --- a/pages/main/head.php +++ b/pages/main/head.php @@ -7,7 +7,7 @@ echo ''."\n\t\t"; if ($result = $db->query ('SELECT name, content FROM metatag')) { while ($row = $result->fetch_assoc ()) - echo ''."\n\t\t"; + echo "\n\t\t"; $result->free (); } diff --git a/rest/edi/clean.php b/rest/edi/clean.php index 0448e120..f22d690b 100644 --- a/rest/edi/clean.php +++ b/rest/edi/clean.php @@ -1,8 +1,8 @@ 0) - printf ('Total: %d messages readed.', $inboxCount); + echo "Total $inboxCount messages readed\n"; } } @@ -155,7 +155,7 @@ class Load extends EdiMethod // Adds the exchange to the Database - $res = $db->queryFromFile ('sql/batch-add', $ediValues); + $res = $db->queryFromFile (__DIR__.'/sql/batch-add', $ediValues); if (!$res) throw new Exception ('Failed to insert the line.'); @@ -180,12 +180,12 @@ class Load extends EdiMethod if (!$error) { $folder = $this->imapConf['success_folder']; - printf ('EDI: Mail loaded with %d lines.', $count); + printf ('Mail loaded with %d lines.', $count); } else { $folder = $this->imapConf['error_folder']; - printf ('EDI: Mail error: %s', $error); + printf ('Mail error: %s', $error); } // Moves the mail to another folder diff --git a/rest/edi/update.php b/rest/edi/update.php index aeec615f..87182487 100644 --- a/rest/edi/update.php +++ b/rest/edi/update.php @@ -15,6 +15,8 @@ class Update extends Vn\Lib\Method // Establece una conexión FTP $ftpConf = $db->getRow ('SELECT host, user, password FROM ftp_config'); + + echo "Openning FTP connection to {$ftpConf['host']}\n"; $ftpConn = ftp_connect ($ftpConf['host']); if (!$ftpConn) @@ -56,6 +58,7 @@ class Update extends Vn\Lib\Method { $dwFiles[$file] = TRUE; + echo "Downloading $remoteFile\n"; if (!ftp_get ($ftpConn, $zipFile, $remoteFile, FTP_BINARY)) throw new Exception ("Error downloading $remoteFile to $zipFile"); @@ -89,7 +92,8 @@ class Update extends Vn\Lib\Method // Actualiza los datos de la tabla - $importQuery = $db->loadFromFile ("sql/$table", ['file' => $fileName]); + echo "Dumping data to table $table\n"; + $importQuery = $db->loadFromFile (__DIR__."/sql/$table", ['file' => $fileName]); $db->multiQuery ( "START TRANSACTION; @@ -113,6 +117,8 @@ class Update extends Vn\Lib\Method shell_exec ("rm -R $tmpDir"); ftp_close ($ftpConn); + + echo "Update completed\n"; } } diff --git a/rest/misc/exchange-rate.php b/rest/misc/exchange-rate.php index f2fcab60..0fbfecb2 100755 --- a/rest/misc/exchange-rate.php +++ b/rest/misc/exchange-rate.php @@ -11,6 +11,7 @@ class ExchangeRate extends Vn\Lib\Method function run () { $db = $this->getSysConn (); + $db->selectDb ('vn2008'); // Indica la URL del archivo diff --git a/rest/misc/mail.php b/rest/misc/mail.php index a54911d3..001b71d5 100755 --- a/rest/misc/mail.php +++ b/rest/misc/mail.php @@ -8,6 +8,7 @@ class Mail extends Vn\Lib\Method function run () { $db = $this->getSysConn (); + $db->selectDb ('vn2008'); $db->query ('START TRANSACTION'); $conf = $db->getRow ( @@ -18,6 +19,8 @@ class Mail extends Vn\Lib\Method 'SELECT * FROM mail WHERE sent = 0 ORDER BY DATE_ODBC DESC LIMIT 20 FOR UPDATE'); + $count = 0; + while ($row = $res->fetch_assoc ()) { $sent = 1; @@ -73,6 +76,8 @@ class Mail extends Vn\Lib\Method if (!$mail->Send ()) throw new Exception ('Send error: '.$mail->ErrorInfo); + + $count++; } catch (Exception $e) { @@ -85,6 +90,7 @@ class Mail extends Vn\Lib\Method } $db->query ('COMMIT'); + echo "Total $count mails sent\n"; } } diff --git a/rest/misc/visits-sync.php b/rest/misc/visits-sync.php index 44fa7251..be8146a5 100644 --- a/rest/misc/visits-sync.php +++ b/rest/misc/visits-sync.php @@ -44,7 +44,7 @@ class VisitsSync extends Vn\Lib\Method $count++; } - echo "$count records updated"; + echo "$count records updated\n"; } if ($stmt)