Version Beta

This commit is contained in:
Juan Ferrer Toribio 2016-08-31 13:53:46 +02:00
parent 25e56bea80
commit 1dbf6de165
14 changed files with 38 additions and 26 deletions

View File

@ -2,7 +2,7 @@
require_once ('vn/lib/cli-app.php'); require_once ('vn/lib/cli-app.php');
$cliApp = new Vn\Lib\CliApp ('hedera-web'); $cliApp = new Vn\Lib\CliApp ('hedera-web', './rest');
$cliApp->run (); $cliApp->run ();
?> ?>

View File

@ -1,7 +1,7 @@
# Alias /hedera-web /usr/share/hedera-web/web/ # Alias /hedera-web /usr/share/hedera-web/
# Alias /vn-image-data /var/cache/hedera-web/image/ # Alias /vn-image-data /var/cache/hedera-web/image-db/
<Directory /usr/share/hedera-web/web/> <Directory /usr/share/hedera-web/>
Options -Indexes -FollowSymLinks Options -Indexes -FollowSymLinks
AllowOverride None AllowOverride None
@ -21,7 +21,7 @@
</Directory> </Directory>
<Directory /var/cache/hedera-web/image/> <Directory /var/cache/hedera-web/image-db/>
Options Indexes FollowSymLinks MultiViews Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo Options AllowOverride FileInfo Options

View File

@ -7,7 +7,7 @@ echo '<meta name="content-language" content="'. Locale::get () .'"/>'."\n\t\t";
if ($result = $db->query ('SELECT name, content FROM metatag')) if ($result = $db->query ('SELECT name, content FROM metatag'))
{ {
while ($row = $result->fetch_assoc ()) while ($row = $result->fetch_assoc ())
echo '<meta name="'. $row['name'] .'" content="'. $row['content'] .'"/>'."\n\t\t"; echo "<meta name=\"{$row['name']}\" content=\"{$row['content']}\"/>\n\t\t";
$result->free (); $result->free ();
} }

View File

@ -1,8 +1,8 @@
<?php <?php
require_once (__DIR__.'/lib/edi-method.php'); require_once (__DIR__.'/lib/method.php');
class Clean extends EdiMethod class Clean extends Edi\Method
{ {
function ediRun () function ediRun ()
{ {
@ -36,13 +36,10 @@ class Clean extends EdiMethod
else else
$count = 0; $count = 0;
printf ('%d mails deleted from %s mailbox.' echo "$count mails deleted from $folder mailbox\n";
,$count
,$folder
);
} }
printf ('Total: %d mails deleted.', $deleted); echo "Total $deleted mails deleted\n";
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Vn\Edi; namespace Edi;
require_once (__DIR__.'/section.php'); require_once (__DIR__.'/section.php');
@ -17,7 +17,7 @@ class Message
static function loadSchema ($schemaName) static function loadSchema ($schemaName)
{ {
$ediSchemaStr = file_get_contents ("vn/edi/schemas/$schemaName.json", TRUE); $ediSchemaStr = file_get_contents (__DIR__."/$schemaName.json", TRUE);
if ($ediSchemaStr !== FALSE) if ($ediSchemaStr !== FALSE)
return json_decode ($ediSchemaStr, TRUE); return json_decode ($ediSchemaStr, TRUE);

View File

@ -1,8 +1,10 @@
<?php <?php
namespace Edi;
require_once ('vn/lib/method.php'); require_once ('vn/lib/method.php');
abstract class EdiMethod extends Vn\Lib\Method abstract class Method extends \Vn\Lib\Method
{ {
protected $imap; protected $imap;
protected $imapConf; protected $imapConf;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Vn\Edi; namespace Edi;
require_once (__DIR__.'/segment.php'); require_once (__DIR__.'/segment.php');

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Vn\Edi; namespace Edi;
require_once ('vn/lib/type.php'); require_once ('vn/lib/type.php');

View File

@ -1,9 +1,9 @@
<?php <?php
require_once (__DIR__.'/lib/method.php'); require_once (__DIR__.'/lib/method.php');
require_once (__DIR__.'/lib/edi.php'); require_once (__DIR__.'/lib/message.php');
class Load extends EdiMethod class Load extends Edi\Method
{ {
function ediRun () function ediRun ()
{ {
@ -26,7 +26,7 @@ class Load extends EdiMethod
$inboxCount = count ($inbox); $inboxCount = count ($inbox);
if ($inboxCount > 0) if ($inboxCount > 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 // Adds the exchange to the Database
$res = $db->queryFromFile ('sql/batch-add', $ediValues); $res = $db->queryFromFile (__DIR__.'/sql/batch-add', $ediValues);
if (!$res) if (!$res)
throw new Exception ('Failed to insert the line.'); throw new Exception ('Failed to insert the line.');
@ -180,12 +180,12 @@ class Load extends EdiMethod
if (!$error) if (!$error)
{ {
$folder = $this->imapConf['success_folder']; $folder = $this->imapConf['success_folder'];
printf ('EDI: Mail loaded with %d lines.', $count); printf ('Mail loaded with %d lines.', $count);
} }
else else
{ {
$folder = $this->imapConf['error_folder']; $folder = $this->imapConf['error_folder'];
printf ('EDI: Mail error: %s', $error); printf ('Mail error: %s', $error);
} }
// Moves the mail to another folder // Moves the mail to another folder

View File

@ -15,6 +15,8 @@ class Update extends Vn\Lib\Method
// Establece una conexión FTP // Establece una conexión FTP
$ftpConf = $db->getRow ('SELECT host, user, password FROM ftp_config'); $ftpConf = $db->getRow ('SELECT host, user, password FROM ftp_config');
echo "Openning FTP connection to {$ftpConf['host']}\n";
$ftpConn = ftp_connect ($ftpConf['host']); $ftpConn = ftp_connect ($ftpConf['host']);
if (!$ftpConn) if (!$ftpConn)
@ -56,6 +58,7 @@ class Update extends Vn\Lib\Method
{ {
$dwFiles[$file] = TRUE; $dwFiles[$file] = TRUE;
echo "Downloading $remoteFile\n";
if (!ftp_get ($ftpConn, $zipFile, $remoteFile, FTP_BINARY)) if (!ftp_get ($ftpConn, $zipFile, $remoteFile, FTP_BINARY))
throw new Exception ("Error downloading $remoteFile to $zipFile"); throw new Exception ("Error downloading $remoteFile to $zipFile");
@ -89,7 +92,8 @@ class Update extends Vn\Lib\Method
// Actualiza los datos de la tabla // 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 ( $db->multiQuery (
"START TRANSACTION; "START TRANSACTION;
@ -113,6 +117,8 @@ class Update extends Vn\Lib\Method
shell_exec ("rm -R $tmpDir"); shell_exec ("rm -R $tmpDir");
ftp_close ($ftpConn); ftp_close ($ftpConn);
echo "Update completed\n";
} }
} }

View File

@ -11,6 +11,7 @@ class ExchangeRate extends Vn\Lib\Method
function run () function run ()
{ {
$db = $this->getSysConn (); $db = $this->getSysConn ();
$db->selectDb ('vn2008');
// Indica la URL del archivo // Indica la URL del archivo

View File

@ -8,6 +8,7 @@ class Mail extends Vn\Lib\Method
function run () function run ()
{ {
$db = $this->getSysConn (); $db = $this->getSysConn ();
$db->selectDb ('vn2008');
$db->query ('START TRANSACTION'); $db->query ('START TRANSACTION');
$conf = $db->getRow ( $conf = $db->getRow (
@ -18,6 +19,8 @@ class Mail extends Vn\Lib\Method
'SELECT * FROM mail WHERE sent = 0 ORDER BY DATE_ODBC DESC 'SELECT * FROM mail WHERE sent = 0 ORDER BY DATE_ODBC DESC
LIMIT 20 FOR UPDATE'); LIMIT 20 FOR UPDATE');
$count = 0;
while ($row = $res->fetch_assoc ()) while ($row = $res->fetch_assoc ())
{ {
$sent = 1; $sent = 1;
@ -73,6 +76,8 @@ class Mail extends Vn\Lib\Method
if (!$mail->Send ()) if (!$mail->Send ())
throw new Exception ('Send error: '.$mail->ErrorInfo); throw new Exception ('Send error: '.$mail->ErrorInfo);
$count++;
} }
catch (Exception $e) catch (Exception $e)
{ {
@ -85,6 +90,7 @@ class Mail extends Vn\Lib\Method
} }
$db->query ('COMMIT'); $db->query ('COMMIT');
echo "Total $count mails sent\n";
} }
} }

View File

@ -44,7 +44,7 @@ class VisitsSync extends Vn\Lib\Method
$count++; $count++;
} }
echo "$count records updated"; echo "$count records updated\n";
} }
if ($stmt) if ($stmt)