From bf5ad50f94a1d73d32a37cd12e7bdc23bc61f69e Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 4 Oct 2022 15:12:16 +0200 Subject: [PATCH] Refactor, unused code removed --- debian/changelog | 2 +- forms/account/conf/conf.js | 2 +- forms/cms/contact/contact.js | 54 +++++------ js/hedera/login.js | 2 +- js/vn/json-connection.js | 2 +- package.json | 2 +- reports/delivery-note/delivery-note.js | 39 -------- reports/delivery-note/style.css | 45 --------- reports/delivery-note/ui.xml | 89 ------------------ reports/items-report/items-report.js | 4 - reports/items-report/style.css | 45 --------- reports/items-report/ui.xml | 53 ----------- rest/client/supplant.php | 8 +- rest/core/set-password.php | 28 ------ rest/edi/sql/bucket.sql | 14 --- rest/edi/sql/bucket_type.sql | 10 -- rest/edi/sql/feature.sql | 11 --- rest/edi/sql/genus.sql | 10 -- rest/edi/sql/item.sql | 13 --- rest/edi/sql/item_feature.sql | 12 --- rest/edi/sql/item_group.sql | 10 -- rest/edi/sql/plant.sql | 11 --- rest/edi/sql/specie.sql | 11 --- rest/edi/sql/supplier.sql | 11 --- rest/edi/sql/type.sql | 11 --- rest/edi/sql/value.sql | 11 --- rest/edi/update.php | 113 ----------------------- rest/image/image.php | 8 +- rest/{core => misc}/IndieFlower.ttf | Bin rest/misc/access-version.php | 74 --------------- rest/{core => misc}/captcha.php | 0 rest/{core => user}/account.php | 0 rest/{core => user}/recover-password.php | 0 rest/{core => user}/restore-password.php | 0 rest/{core => user}/supplant.php | 0 35 files changed, 40 insertions(+), 665 deletions(-) delete mode 100644 reports/delivery-note/delivery-note.js delete mode 100644 reports/delivery-note/style.css delete mode 100644 reports/delivery-note/ui.xml delete mode 100644 reports/items-report/items-report.js delete mode 100644 reports/items-report/style.css delete mode 100644 reports/items-report/ui.xml delete mode 100644 rest/core/set-password.php delete mode 100644 rest/edi/sql/bucket.sql delete mode 100644 rest/edi/sql/bucket_type.sql delete mode 100644 rest/edi/sql/feature.sql delete mode 100644 rest/edi/sql/genus.sql delete mode 100644 rest/edi/sql/item.sql delete mode 100644 rest/edi/sql/item_feature.sql delete mode 100644 rest/edi/sql/item_group.sql delete mode 100644 rest/edi/sql/plant.sql delete mode 100644 rest/edi/sql/specie.sql delete mode 100644 rest/edi/sql/supplier.sql delete mode 100644 rest/edi/sql/type.sql delete mode 100644 rest/edi/sql/value.sql delete mode 100644 rest/edi/update.php rename rest/{core => misc}/IndieFlower.ttf (100%) delete mode 100644 rest/misc/access-version.php rename rest/{core => misc}/captcha.php (100%) rename rest/{core => user}/account.php (100%) rename rest/{core => user}/recover-password.php (100%) rename rest/{core => user}/restore-password.php (100%) rename rest/{core => user}/supplant.php (100%) diff --git a/debian/changelog b/debian/changelog index 36fd1083..e6d4ff98 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.408.14) stable; urgency=low +hedera-web (1.408.15) stable; urgency=low * Initial Release. diff --git a/forms/account/conf/conf.js b/forms/account/conf/conf.js index e15c2ca7..437adb61 100644 --- a/forms/account/conf/conf.js +++ b/forms/account/conf/conf.js @@ -41,7 +41,7 @@ Hedera.Conf = new Class({ if (verificationToken) { params.verificationToken = verificationToken; - this.conn.send('core/restore-password', params, + this.conn.send('user/restore-password', params, this._onPassChange.bind(this)); } else { let userId = this.gui.user.id; diff --git a/forms/cms/contact/contact.js b/forms/cms/contact/contact.js index 41ff9886..6bb9d700 100644 --- a/forms/cms/contact/contact.js +++ b/forms/cms/contact/contact.js @@ -1,46 +1,40 @@ -Hedera.Contact = new Class -({ +Hedera.Contact = new Class({ Extends: Hedera.Form - ,activate: function () - { + ,activate: function() { var self = this; - this.$.contactForm.onsubmit = function () - { self._onSubmit (); return false; }; - - this.refreshCaptcha (); - } - - ,refreshCaptcha: function () - { - params = { - 'srv': 'rest:core/captcha', - 'stamp': new Date ().getTime () + this.$.contactForm.onsubmit = function() { + self._onSubmit(); return false; }; - this.$.captchaImg.src = '?'+ Vn.Url.makeUri (params); + + this.refreshCaptcha(); } - ,_onSubmit: function () - { - this.conn.sendForm (this.$.contactForm, - this._onResponse.bind (this)); + ,refreshCaptcha: function() { + params = { + srv: 'rest:misc/captcha', + stamp: new Date().getTime() + }; + this.$.captchaImg.src = '?'+ Vn.Url.makeUri(params); } - ,_onResponse: function (json, error) - { + ,_onSubmit: function() { + this.conn.sendForm(this.$.contactForm, + this._onResponse.bind(this)); + } + + ,_onResponse: function(json) { var form = this.$.contactForm; - if (json) - { - form.reset (); - Htk.Toast.showMessage (_('DataSentSuccess')); - } - else - Htk.Toast.showError (_('ErrorSendingData')); + if (json) { + form.reset(); + Htk.Toast.showMessage(_('DataSentSuccess')); + } else + Htk.Toast.showError(_('ErrorSendingData')); form['captcha'].value = ''; - this.refreshCaptcha (); + this.refreshCaptcha(); } }); diff --git a/js/hedera/login.js b/js/hedera/login.js index 36fba7c7..d3b8450c 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -98,7 +98,7 @@ module.exports = new Class({ if (!user) Htk.Toast.showError(_('Please write your user name')); else - this._conn.send('core/recover-password', {recoverUser: user}, + this._conn.send('user/recover-password', {recoverUser: user}, this._onPasswordRecovered.bind(this)); } diff --git a/js/vn/json-connection.js b/js/vn/json-connection.js index f6655927..23bc2e3f 100644 --- a/js/vn/json-connection.js +++ b/js/vn/json-connection.js @@ -115,7 +115,7 @@ module.exports = new Class({ this.send('client/supplant', params, this._onUserSupplant.bind(this, callback)); } - + ,_onUserSupplant: function(callback, json, err) { if (json) this.token = json; diff --git a/package.json b/package.json index 13e1bc17..cb3e4aa7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.408.14", + "version": "1.408.15", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/reports/delivery-note/delivery-note.js b/reports/delivery-note/delivery-note.js deleted file mode 100644 index 1730c284..00000000 --- a/reports/delivery-note/delivery-note.js +++ /dev/null @@ -1,39 +0,0 @@ - -Hedera.DeliveryNote = new Class({ - Extends: Hedera.Report, - - onTicketReady: function(form) { - if (form.$.method != 'PICKUP') - Vn.Node.setText(this.$.method, _('Agency')); - else - Vn.Node.setText(this.$.method, _('Warehouse')); - }, - - discountRenderer: function(column, form) { - column.value = form.$.discount ? form.$.discount : null; - }, - - subtotalRenderer: function(column, form) { - column.value = this.subtotal(form); - }, - - subtotal: function(form) { - var price = form.$.price; - var discount = form.$.discount; - return form.$.quantity * price *((100 - discount) / 100); - }, - - serviceSubtotal: function(column, form) { - column.value = form.$.quantity * form.$.price; - }, - - onServicesChanged: function(model) { - this.$.services.node.style.display = - model.numRows > 0 ? 'block' : 'none'; - }, - - onPackagesChanged: function(model) { - this.$.packages.node.style.display = - model.numRows > 0 ? 'block' : 'none'; - } -}); diff --git a/reports/delivery-note/style.css b/reports/delivery-note/style.css deleted file mode 100644 index fe39e671..00000000 --- a/reports/delivery-note/style.css +++ /dev/null @@ -1,45 +0,0 @@ -* -{ - font-size: 4mm; -} -.sheet -{ - height: auto; -} -h2 -{ - font-size: 1.2em; - font-weight: bold; -} -.header -{ - margin-bottom: 2em; -} -.header > div > p -{ - margin: .1em 0; -} -.important -{ - font-size: 1.2em; - font-weight: bold; -} -.address, -.total -{ - margin-top: .8em; -} -.total -{ - text-align: right; -} -.htk-grid -{ - margin-top: 1em; -} -.packages -{ - width: 50%; - margin-left: 0; - display: none; -} diff --git a/reports/delivery-note/ui.xml b/reports/delivery-note/ui.xml deleted file mode 100644 index eb7d3db5..00000000 --- a/reports/delivery-note/ui.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - CALL myTicket_get(#ticket) - - - -
-

- # -

-
-
-

- Preparation -

-

- Delivery -

-

- -

-
-
-

- -

-

- -

-

- - - () -

-
-
-

- Total - -

-

- Total + tax - -

-
-
- - - CALL myTicket_getRows(#ticket) - - - - - - - - - - - - - CALL myTicket_getServices(#ticket) - - - - - - - - - CALL myTicket_getPackages(#ticket) - - - - - -
-
diff --git a/reports/items-report/items-report.js b/reports/items-report/items-report.js deleted file mode 100644 index cae507db..00000000 --- a/reports/items-report/items-report.js +++ /dev/null @@ -1,4 +0,0 @@ - -Hedera.ItemsReport = new Class({ - Extends: Hedera.Report -}); diff --git a/reports/items-report/style.css b/reports/items-report/style.css deleted file mode 100644 index 453ef8ba..00000000 --- a/reports/items-report/style.css +++ /dev/null @@ -1,45 +0,0 @@ -* -{ - font-size: 4mm; -} -.sheet -{ - height: auto; -} -h1 -{ - font-weight: normal; - font-size: 200%; - text-align: center; - margin: 0 auto; - margin-bottom: 8mm; -} -.htk-grid -{ - border-collapse: collapse; - width: 100%; - margin: 0 auto; - padding: 0; -} -thead > tr -{ - border-bottom: 1px solid #333; - height: 10mm; -} -th -{ - font-weight: normal; -} -td -{ - padding-left: 2mm; -} -tbody > tr -{ - height: 18mm; -} -.cell-image img -{ - width: 15mm; -} - diff --git a/reports/items-report/ui.xml b/reports/items-report/ui.xml deleted file mode 100644 index ac2d2383..00000000 --- a/reports/items-report/ui.xml +++ /dev/null @@ -1,53 +0,0 @@ - -
-

- Item list -

- - - - CALL item_getList(#warehouse, CURDATE(), #realm, #rate) - - - - - - - - - - - - - - -
-
diff --git a/rest/client/supplant.php b/rest/client/supplant.php index 4b2dbf49..4ef83402 100644 --- a/rest/client/supplant.php +++ b/rest/client/supplant.php @@ -18,12 +18,12 @@ class Supplant extends Vn\Web\JsonRequest { if (!$isClient) throw new Web\ForbiddenException(s('The user is not a client')); - $isWorker = $db->getValue( - 'SELECT COUNT(*) > 0 FROM vn.worker WHERE id = #', + $hasAccount = $db->getValue( + 'SELECT COUNT(*) > 0 FROM account.account WHERE id = #', [$userId] ); - if ($isWorker) - throw new Web\ForbiddenException(s('Workers cannot be supplanted')); + if ($hasAccount) + throw new Web\ForbiddenException(s('The user is not impersonable')); return $this->service->createToken($_REQUEST['supplantUser']); } diff --git a/rest/core/set-password.php b/rest/core/set-password.php deleted file mode 100644 index 5ceaa87b..00000000 --- a/rest/core/set-password.php +++ /dev/null @@ -1,28 +0,0 @@ -getValue( - 'SELECT id FROM account.user WHERE `name` = #', - [$setUser] - ); - $db->query('CALL account.user_setPassword(#, #)', - [$userId, $setPassword]); - Account::sync($db, $setUser, $setPassword); - return TRUE; - } -} - diff --git a/rest/edi/sql/bucket.sql b/rest/edi/sql/bucket.sql deleted file mode 100644 index 9b2d2dfa..00000000 --- a/rest/edi/sql/bucket.sql +++ /dev/null @@ -1,14 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE bucket - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12) - SET - bucket_id = @col2, - bucket_type_id = @col4, - description = @col5, - x_size = @col6, - y_size = @col7, - z_size = @col8, - entry_date = STR_TO_DATE(@col10, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col11, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col12, '%Y%m%d%H%i') diff --git a/rest/edi/sql/bucket_type.sql b/rest/edi/sql/bucket_type.sql deleted file mode 100644 index 11bcc7f0..00000000 --- a/rest/edi/sql/bucket_type.sql +++ /dev/null @@ -1,10 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE bucket_type - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6) - SET - bucket_type_id = @col2, - description = @col3, - entry_date = STR_TO_DATE(@col4, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col5, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col6, '%Y%m%d%H%i') diff --git a/rest/edi/sql/feature.sql b/rest/edi/sql/feature.sql deleted file mode 100644 index a5d2833c..00000000 --- a/rest/edi/sql/feature.sql +++ /dev/null @@ -1,11 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE `feature` - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7) - SET - item_id = @col2, - feature_type_id = @col3, - feature_value = @col4, - entry_date = STR_TO_DATE(@col5, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i') diff --git a/rest/edi/sql/genus.sql b/rest/edi/sql/genus.sql deleted file mode 100644 index 0e60fd79..00000000 --- a/rest/edi/sql/genus.sql +++ /dev/null @@ -1,10 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE genus - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6) - SET - genus_id = @col2, - latin_genus_name = @col3, - entry_date = STR_TO_DATE(@col4, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col5, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col6, '%Y%m%d%H%i') diff --git a/rest/edi/sql/item.sql b/rest/edi/sql/item.sql deleted file mode 100644 index 1c348439..00000000 --- a/rest/edi/sql/item.sql +++ /dev/null @@ -1,13 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE item - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12) - SET - id = @col2, - product_name = @col4, - name = @col5, - plant_id = @col7, - group_id = @col9, - entry_date = STR_TO_DATE(@col10, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col11, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col12, '%Y%m%d%H%i') diff --git a/rest/edi/sql/item_feature.sql b/rest/edi/sql/item_feature.sql deleted file mode 100644 index 81ddbc73..00000000 --- a/rest/edi/sql/item_feature.sql +++ /dev/null @@ -1,12 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE `item_feature` - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8) - SET - item_id = @col2, - feature = @col3, - regulation_type = @col4, - presentation_order = @col5, - entry_date = STR_TO_DATE(@col6, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col7, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col8, '%Y%m%d%H%i') diff --git a/rest/edi/sql/item_group.sql b/rest/edi/sql/item_group.sql deleted file mode 100644 index cbdc1328..00000000 --- a/rest/edi/sql/item_group.sql +++ /dev/null @@ -1,10 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE item_group - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6) - SET - group_code = @col2, - dutch_group_description = @col3, - entry_date = STR_TO_DATE(@col4, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col5, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col6, '%Y%m%d%H%i') diff --git a/rest/edi/sql/plant.sql b/rest/edi/sql/plant.sql deleted file mode 100644 index ba969afa..00000000 --- a/rest/edi/sql/plant.sql +++ /dev/null @@ -1,11 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE plant - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9) - SET - plant_id = @col3, - genus_id = @col4, - specie_id = @col5, - entry_date = STR_TO_DATE(@col7, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col8, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col9, '%Y%m%d%H%i') diff --git a/rest/edi/sql/specie.sql b/rest/edi/sql/specie.sql deleted file mode 100644 index 883d97b7..00000000 --- a/rest/edi/sql/specie.sql +++ /dev/null @@ -1,11 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE specie - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7) - SET - specie_id = @col2, - genus_id = @col3, - latin_species_name = @col4, - entry_date = STR_TO_DATE(@col5, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i') diff --git a/rest/edi/sql/supplier.sql b/rest/edi/sql/supplier.sql deleted file mode 100644 index 636d0a0b..00000000 --- a/rest/edi/sql/supplier.sql +++ /dev/null @@ -1,11 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE supplier - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7, @col8, @col9, @col10, @col11, @col12, @col13, @col14, @col15, @col16, @col17, @col18, @col19, @col20) - SET - GLNAddressCode = @col2, - supplier_id = @col4, - company_name = @col3, - entry_date = STR_TO_DATE(@col9, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col10, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col11, '%Y%m%d%H%i') diff --git a/rest/edi/sql/type.sql b/rest/edi/sql/type.sql deleted file mode 100644 index 77c0883d..00000000 --- a/rest/edi/sql/type.sql +++ /dev/null @@ -1,11 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE `type` - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7) - SET - type_id = @col2, - type_group_id = @col3, - description = @col4, - entry_date = STR_TO_DATE(@col5, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i') diff --git a/rest/edi/sql/value.sql b/rest/edi/sql/value.sql deleted file mode 100644 index 288b8c10..00000000 --- a/rest/edi/sql/value.sql +++ /dev/null @@ -1,11 +0,0 @@ -LOAD DATA LOCAL INFILE #file - INTO TABLE `value` - FIELDS TERMINATED BY ';' - LINES TERMINATED BY '\n' (@col1, @col2, @col3, @col4, @col5, @col6, @col7) - SET - type_id = @col2, - type_value = @col3, - type_description = @col4, - entry_date = STR_TO_DATE(@col5, '%Y%m%d'), - expiry_date = IFNULL(NULL,STR_TO_DATE(@col6, '%Y%m%d')), - change_date_time = STR_TO_DATE(@col7, '%Y%m%d%H%i') diff --git a/rest/edi/update.php b/rest/edi/update.php deleted file mode 100644 index 87ca6d21..00000000 --- a/rest/edi/update.php +++ /dev/null @@ -1,113 +0,0 @@ -selectDb('edi'); - $db->getHandler()->options(MYSQLI_OPT_LOCAL_INFILE, TRUE); - - $tmpDir = '/tmp/floricode'; - - // Establish the FTP connection - - $ftpConf = $db->getRow('SELECT host, user, password FROM ftpConfig'); - - echo "Openning FTP connection to {$ftpConf['host']}\n"; - $ftpConn = ftp_connect($ftpConf['host']); - - if (!$ftpConn) - throw new Exception('Can not connect to '. $ftpConf['host']); - - if (!ftp_login($ftpConn, $ftpConf['user'], $ftpConf['password'])) - throw new Exception('Can not login to '. $ftpConf['user'] .'@'. $ftpConf['host']); - ftp_pasv($ftpConn, true); - - // Gets the list with the tables to update - - set_time_limit(0); - - $res = $db->query( - 'SELECT fileName, toTable, file, updated FROM fileConfig'); - - $dwFiles = []; - - if (!file_exists($tmpDir)) - mkdir($tmpDir); - - while ($row = $res->fetch_assoc()) - try { - $file = $row['file']; - $table = $row['toTable']; - $baseName = $row['fileName']; - - if ($row['updated']) { - $updated = DateTime::createFromFormat('Y-m-d', $row['updated']); - $updated->setTime(0, 0, 0); - } else - $updated = NULL; - - $remoteFile = "codes/$file.ZIP"; - $zipFile = "$tmpDir/$file.zip"; - $ucDir = "$tmpDir/$file"; - - // Downloads and decompress the file with the data - - if (!isset($dwFiles[$file])) { - $dwFiles[$file] = TRUE; - - echo "Downloading $remoteFile\n"; - if (!ftp_get($ftpConn, $zipFile, $remoteFile, FTP_BINARY)) - throw new Exception("Error downloading $remoteFile to $zipFile"); - - $zip = new ZipArchive; - - if ($zip->open($zipFile) !== TRUE) - throw new Exception("Can not open $zipFile"); - - @mkdir($ucDir, 0774, TRUE); - - if (!$zip->extractTo($ucDir)) - throw new Exception("Can not uncompress file $zipFile"); - - $zip->close(); - unlink($zipFile); - } - - foreach (glob("$ucDir/$baseName*.txt") as $fileName) - break; - - if (empty($fileName)) - throw new Exception("Import file for table $table does not exist"); - - // If data is updated, omits the table - - $lastUpdated = substr($fileName, -10, 6); - $lastUpdated = DateTime::createFromFormat('dmy', $lastUpdated); - $lastUpdated->setTime(0, 0, 0); - - if (isset($updated) && $lastUpdated <= $updated) { - echo "Table $table is updated, omitted\n"; - continue; - } - - // Updates the table - - echo "Dumping data to table $table\n"; - - $db->query("START TRANSACTION"); - $db->query("DELETE FROM {$db->quote($table)}"); - $db->queryFromFile(__DIR__."/sql/$table", ['file' => $fileName]); - $db->query("UPDATE fileConfig SET updated = # WHERE fileName = #", - [$lastUpdated, $baseName] - ); - $db->query("COMMIT"); - } catch (Exception $e) { - error_log($e->getMessage()); - $db->query('ROLLBACK'); - } - - shell_exec("rm -R $tmpDir"); - ftp_close($ftpConn); - - echo "Update completed\n"; - } -} diff --git a/rest/image/image.php b/rest/image/image.php index 0e6cae0f..0c104851 100644 --- a/rest/image/image.php +++ b/rest/image/image.php @@ -20,7 +20,13 @@ class Image { $image = imagecreatefrompng($srcFile); break; case IMAGETYPE_GIF: - $image = imagecreatefromgif ($srcFile); + $image = imagecreatefromgif($srcFile); + break; + case IMAGETYPE_WEBP: + $image = imagecreatefromwebp($srcFile); + break; + case IMAGETYPE_BMP: + $image = imagecreatefrombmp($srcFile); break; default: throw new UserException(s('Bad file format')); diff --git a/rest/core/IndieFlower.ttf b/rest/misc/IndieFlower.ttf similarity index 100% rename from rest/core/IndieFlower.ttf rename to rest/misc/IndieFlower.ttf diff --git a/rest/misc/access-version.php b/rest/misc/access-version.php deleted file mode 100644 index 63f74a8d..00000000 --- a/rest/misc/access-version.php +++ /dev/null @@ -1,74 +0,0 @@ -app->getName() .'/vn-access'; - $headFile = "$accessDir/$appName.7z"; - $archiveRelPath = ".archive/$appName/$newVersion.7z"; - $archiveFullPath = "$accessDir/$archiveRelPath"; - - // Updates the application - - rename($moduleFile['tmp_name'], $archiveFullPath); - chmod($archiveFullPath, 0644); - - @unlink($headFile); - symlink($archiveRelPath, $headFile); - - return TRUE; - } -} diff --git a/rest/core/captcha.php b/rest/misc/captcha.php similarity index 100% rename from rest/core/captcha.php rename to rest/misc/captcha.php diff --git a/rest/core/account.php b/rest/user/account.php similarity index 100% rename from rest/core/account.php rename to rest/user/account.php diff --git a/rest/core/recover-password.php b/rest/user/recover-password.php similarity index 100% rename from rest/core/recover-password.php rename to rest/user/recover-password.php diff --git a/rest/core/restore-password.php b/rest/user/restore-password.php similarity index 100% rename from rest/core/restore-password.php rename to rest/user/restore-password.php diff --git a/rest/core/supplant.php b/rest/user/supplant.php similarity index 100% rename from rest/core/supplant.php rename to rest/user/supplant.php