From 0e6900be0bcfc882505ec4c8b8730a798985bc80 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 17 Mar 2019 17:43:17 +0000 Subject: [PATCH] More progress with attachments. --- WEB-INF/lib/ttFileHelper.class.php | 34 +++++++++++++++++++----------- WEB-INF/resources/ca.lang.php | 1 + WEB-INF/resources/cs.lang.php | 1 + WEB-INF/resources/da.lang.php | 1 + WEB-INF/resources/de.lang.php | 1 + WEB-INF/resources/en.lang.php | 1 + WEB-INF/resources/es.lang.php | 1 + WEB-INF/resources/et.lang.php | 2 ++ WEB-INF/resources/fa.lang.php | 2 ++ WEB-INF/resources/fi.lang.php | 1 + WEB-INF/resources/fr.lang.php | 1 + WEB-INF/resources/gr.lang.php | 1 + WEB-INF/resources/he.lang.php | 1 + WEB-INF/resources/hu.lang.php | 1 + WEB-INF/resources/it.lang.php | 1 + WEB-INF/resources/ja.lang.php | 1 + WEB-INF/resources/ko.lang.php | 1 + WEB-INF/resources/nl.lang.php | 2 ++ WEB-INF/resources/no.lang.php | 1 + WEB-INF/resources/pl.lang.php | 1 + WEB-INF/resources/pt-br.lang.php | 1 + WEB-INF/resources/pt.lang.php | 1 + WEB-INF/resources/ro.lang.php | 1 + WEB-INF/resources/ru.lang.php | 1 + WEB-INF/resources/sk.lang.php | 1 + WEB-INF/resources/sl.lang.php | 1 + WEB-INF/resources/sr.lang.php | 1 + WEB-INF/resources/sv.lang.php | 1 + WEB-INF/resources/tr.lang.php | 1 + WEB-INF/resources/zh-cn.lang.php | 1 + WEB-INF/resources/zh-tw.lang.php | 1 + WEB-INF/templates/footer.tpl | 2 +- project_files.php | 5 ++++- 33 files changed, 60 insertions(+), 14 deletions(-) diff --git a/WEB-INF/lib/ttFileHelper.class.php b/WEB-INF/lib/ttFileHelper.class.php index aad91e9f..af470c71 100644 --- a/WEB-INF/lib/ttFileHelper.class.php +++ b/WEB-INF/lib/ttFileHelper.class.php @@ -52,6 +52,8 @@ class ttFileHelper { // checkSiteRegistration - obtains site id and key from local database. // If not found, it tries to register with file stroage facility. function checkSiteRegistration() { + + global $i18n; $mdb2 = getConnection(); // Obtain site id. @@ -94,6 +96,8 @@ class ttFileHelper { $mdb2->exec($sql); $sql = "insert into tt_site_config values('locker_key', $key, now(), null)"; $mdb2->exec($sql); + } else { + $this->errors->add($i18n->get('error.file_storage')); } } } else { @@ -109,16 +113,21 @@ class ttFileHelper { } // putFile - puts uploaded file in remote storage. - function putFile($description) { - - $url = $this->storage_uri; - $fields = array('description' => urlencode($description), -// 'fname' => urlencode($_POST['first_name']), -// 'title' => urlencode($_POST['title']), -// 'company' => urlencode($_POST['institution']), -// 'age' => urlencode($_POST['age']), -// 'email' => urlencode($_POST['email']), -// 'phone' => urlencode($_POST['phone']) + function putFile($fields) { + $mdb2 = getConnection(); + + $fields = array('site_id' => urlencode($this->site_id), + 'site_key' => urlencode($this->site_key), + //'org_id' => urlencode($this->org_id), // TODO: obtain this properly. + //'org_key' => urlencode($this->org_key), // TODO: obtain this properly. + //'group_id' => urlencode($this->group_id), // TODO: obtain this properly. + //'group_key' => urlencode($this->group_key), // TODO: obtain this properly. + //'user_id' => urlencode($this->user_id), // TODO: obtain this properly. + //'user_key' => urlencode($this->user_key), // TODO: obtain this properly. + 'file_name' => urlencode($fields['file_name']), + 'description' => urlencode($fields['description']), + // TODO: add file content here, too. Will this work for large files? + // ); // url-ify the data for the POST. @@ -129,7 +138,7 @@ class ttFileHelper { $ch = curl_init(); // Set the url, number of POST vars, POST data. - curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_URL, $this->putfile_uri); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -142,7 +151,8 @@ class ttFileHelper { if ($result) { $result_array = json_decode($result, true); - $file_id = $mdb2->quote($result_array['id']); + $file_id = $result_array['file_id']; + $file_key = $result_array['file_key']; } unlink($_FILES['newfile']['tmp_name']); diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index 59ea97ef..06a28c88 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -120,6 +120,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index 96f17769..97ab7e67 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -122,6 +122,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index 7a6ef813..403289ba 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -116,6 +116,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index bc7ba0c3..980706d2 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -110,6 +110,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index 8dc20118..f1fc72aa 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -105,6 +105,7 @@ $i18n_key_words = array( 'error.format' => 'Invalid file format.', 'error.user_count' => 'Limit on user count.', 'error.expired' => 'Expiration date reached.', +'error.file_storage' => 'File storage error.', // Warning messages. 'warn.sure' => 'Are you sure?', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 7978ff55..4f33f6d9 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -118,6 +118,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 94fb496e..f46db014 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -126,6 +126,8 @@ $i18n_key_words = array( 'error.format' => 'Faili formaat on vale.', 'error.user_count' => 'Kasutajate arvu piirang.', 'error.expired' => 'Kehtivusaeg on lõppenud.', +// TODO: translate the following. +// 'error.file_storage' => 'File storage error.', // Warning messages. 'warn.sure' => 'Oled kindel?', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index 17a76172..8111b3d3 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -123,6 +123,8 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// TODO: translate the following. +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 661edd86..2f3a4092 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -118,6 +118,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index b797b6ff..1bb5f680 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -116,6 +116,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index a69e6aa8..bb2a334b 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -111,6 +111,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 8cc4d022..19ace043 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -133,6 +133,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index 8c2e730c..349c224c 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -121,6 +121,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index c1a87b73..c19f9f3d 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -115,6 +115,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 3b48408c..c53b8aed 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -124,6 +124,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 1a77cde7..cf3f608e 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -123,6 +123,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index 426a1428..e56846c7 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -105,6 +105,8 @@ $i18n_key_words = array( 'error.format' => 'Bestandsformaat niet valide.', 'error.user_count' => 'Limiet op aantal gebruikers.', 'error.expired' => 'Verloop datum is bereikt.', +// TODO: translate the following. +// 'error.file_storage' => 'File storage error.', // Warning messages. 'warn.sure' => 'Ben je er zeker van?', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index a37e8881..e6816351 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -124,6 +124,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index 9258b851..e81fc254 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -120,6 +120,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index 99d4d1c7..f5d92390 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -117,6 +117,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 8969cdcd..a0ac39b2 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -117,6 +117,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index 74b843e9..83218b04 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -124,6 +124,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index c8dee6fc..36815e9f 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -104,6 +104,7 @@ $i18n_key_words = array( 'error.format' => 'Неверный формат файла.', 'error.user_count' => 'Ограничение на количество пользователей.', 'error.expired' => 'Достигнута дата экспирации.', +'error.file_storage' => 'Ошибка файлохранилища.', // Warning messages. 'warn.sure' => 'Вы уверены?', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 34d92dd5..1a53dc8f 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -122,6 +122,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index a4cc8fef..c9144c8c 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -114,6 +114,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 7178d548..6365d1c0 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -117,6 +117,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index 818a7db5..c89dd648 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -115,6 +115,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index 7608d155..fd96a2af 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -127,6 +127,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index ef133c96..8d561837 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -116,6 +116,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 9aa12451..dc590fec 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -121,6 +121,7 @@ $i18n_key_words = array( // 'error.format' => 'Invalid file format.', // 'error.user_count' => 'Limit on user count.', // 'error.expired' => 'Expiration date reached.', +// 'error.file_storage' => 'File storage error.', // Warning messages. // TODO: translate the following. diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 1dcec802..9f0efd99 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.59.4874 | Copyright © Anuko | +  Anuko Time Tracker 1.18.59.4875 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/project_files.php b/project_files.php index affc6d72..fec090b2 100644 --- a/project_files.php +++ b/project_files.php @@ -72,7 +72,10 @@ if ($request->isPost()) { if ($err->no()) { $fileHelper = new ttFileHelper($err); - $fileHelper->putFile($cl_description); + $fields = array('description'=>$cl_description); // TODO: add other fields here if required. + if (!$fileHelper->putFile($fields)) { + $err->add($i18n->get('error.expired')); + } } // if ($err->no()) $msg->add($i18n->get('form.import.success')); } // isPost -- 2.20.1