commit - cfd90730c4ec4e3a108a3bb5d7d40cd7450635c4
commit + a364f4a20c938e57ad4df30b7ceeca0ed06519ab
blob - 140bc46a870319fee447ffdbd67b20cc4d0ba767
blob + 3b8051604a0c69d5cfe36e4e5387e8fe6d6ecb8a
--- module/Securitx/src/Controller/SecuritxController.php
+++ module/Securitx/src/Controller/SecuritxController.php
use Laminas\Crypt\FileCipher;
+use Laminas\Http\Client;
+use Laminas\Http\PhpEnvironment\Response;
+
+
use InvalidArgumentException;
class SecuritxController extends AbstractActionController {
$item['tmp_name']);
$fc = new FileCipher;
$download = new Downloads();
+ $download->moddate = time();
$download->id_key = basename($new_name, ".pdf");
$download->u_key = $member->u_key;
$download->e_key = uniqid();
+ $download->downloaded = 0;
+ $download->company_id = 0;
$fc->setKey($download->e_key);
$fc->encrypt($item['tmp_name'], $new_name);
unlink($item['tmp_name']);
if (!$this->checkAnyAdmin())
return $this->redirect()->toRoute('securitx');
$member = $this->getMember();
+ $company = $this->company_table->getCompany($member->company_id);
+ $downloads = new Downloads;
+ $downloads = $this->downloads_table->getCDownloads(
+ $company->company_id
+ );
+ $da = array();
+ foreach($downloads as $download)
+ array_push($da, $download);
return new ViewModel(array(
+ 'first' => $member->first,
'u_key' => $member->u_key,
+ 'downloads' => $da,
));
}
+ public function downloaderAction() {
+ if (!$this->checkAnyAdmin())
+ return $this->redirect()->toRoute('securitx');
+ $member = $this->getMember();
+ if ($_GET) {
+ $download =
+ $this->downloads_table->getDownload($_GET['id']);
+ $download->downloaded = time();
+ $this->downloads_table->saveDownload($download);
+
+ if ($_GET['type'] == "p") {
+ $file = sprintf('%s/data/downloads/%s/%s.pdf',
+ realpath(getcwd()), $member->u_key,
+ $download->id_key);
+
+ $new_name = sprintf('%s/data/tmp/%s.pdf',
+ realpath(getcwd()), $download->id_key);
+ } else if ($_GET['type'] == "c") {
+ $company = $this->company_table->getCompany(
+ $member->company_id
+ );
+ $file = sprintf('%s/data/uploads/%s/%s.pdf',
+ realpath(getcwd()), $company->short,
+ $download->id_key);
+
+ $new_name = sprintf('%s/data/tmp/%s.pdf',
+ realpath(getcwd()), $download->id_key);
+ }
+ $fc = new FileCipher;
+ $fc->setKey($download->e_key);
+ $fc->decrypt($file, $new_name);
+
+ $client = new Client();
+ $response = new Response();
+ $response->getHeaders()->addHeaders([
+ 'Content-Description' => 'File Transfer',
+ 'Content-Type' => 'application/pdf',
+ 'Content-Disposition' => 'attachment; filename="' . basename($new_name) . '"',
+ 'Expires' => '0',
+ 'Cache-Control' => 'must-revalidate',
+ 'Pragma' => 'public',
+ 'Content-Length' => filesize($new_name),
+ 'Content-Transfer-Encoding' => 'binary',
+ ]);
+ $response->setContent(file_get_contents($new_name));
+
+ unlink($new_name);
+ return $response;
+ }
+ return new ViewModel();
+ }
public function downloadAction() {
if (!$this->checkAnyAdmin())
return $this->redirect()->toRoute('securitx');
$member = $this->getMember();
+ $downloads = new Downloads;
+ $downloads =
+ $this->downloads_table->getDownloads($member->u_key);
+ $da = array();
+ foreach($downloads as $download)
+ array_push($da, $download);
return new ViewModel(array(
+ 'first' => $member->first,
'u_key' => $member->u_key,
+ 'downloads' => $da,
));
}
public function forgotAction() {
id_key UUID NOT NULL,
u_key UUID NOT NULL,
e_key UUID NOT NULL,
- company_id INTEGER,
- downloaded INTEGER
+ company_id INTEGER NOT NULL,
+ downloaded INTEGER NOT NULL
)
', Adapter::QUERY_MODE_EXECUTE);
}
echo $new_name;
$fc = new FileCipher;
$download = new Downloads();
+ $download->moddate = time();
$download->id_key = basename($new_name, ".pdf");
$download->u_key = $member->u_key;
$download->e_key = uniqid();
+ $download->downloaded = 0;
$download->company_id = $company->company_id;
$fc->setKey($download->e_key);
$fc->encrypt($item['tmp_name'], $new_name);
blob - 8ec0d545b192e66f8be1818c77594c74bf22887f
blob + 52affe605f4a9bb2823f09334efc895941cceac6
--- module/Securitx/src/Model/Downloads.php
+++ module/Securitx/src/Model/Downloads.php
class Downloads {
public $downloads_id;
+ public $moddate;
public $id_key;
public $u_key;
public $e_key;
+ public $downloaded;
public $company_id;
public function exchangeArray(array $data) {
$this->downloads_id = !empty($data['downloads_id']) ? $data['downloads_id'] : null;
+ $this->moddate = !empty($data['moddate']) ? $data['moddate'] : null;
$this->id_key = !empty($data['id_key']) ? $data['id_key'] : null;
$this->u_key = !empty($data['u_key']) ? $data['u_key'] : null;
+ $this->downloaded = $data['downloaded'];
$this->e_key = !empty($data['e_key']) ? $data['e_key'] : null;
- $this->company_id = !empty($data['company_id']) ? $data['company_id'] : null;
+ $this->company_id = $data['company_id'];
}
}
blob - 848f650784fbc6f50b198dc8c4e5cc0f5491815b
blob + 6cd5147b0ce8cc30e0a35cddd2ffbdd290822cac
--- module/Securitx/src/Model/DownloadsTable.php
+++ module/Securitx/src/Model/DownloadsTable.php
public function fetchAll() {
return $this->tableGateway->select();
}
+ public function getDownload($id) {
+ $rowset = $this->tableGateway->select(['downloads_id' => $id]);
+ $row = $rowset->current();
+ return $row;
+ }
public function getCount($u_key) {
return $this->tableGateway->select(['u_key' => $u_key])->count();
}
])->count();
}
public function getDownloads($u_key) {
- return $this->tableGateway->select()(['u_key' => $u_key]);
+ return $this->tableGateway->select([
+ 'u_key' => $u_key,
+ 'company_id' => 0,
+ ]);
}
+ public function getCDownloads($c_id) {
+ return $this->tableGateway->select([
+ 'company_id' =>$c_id,
+ ]);
+ }
public function saveDownload(Downloads $download) {
$data = [
- 'moddate' => time(),
+ 'moddate' => $download->moddate,
'id_key' => $download->id_key,
'u_key' => $download->u_key,
+ 'downloaded' => $download->downloaded,
'e_key' => $download->e_key,
'company_id' => $download->company_id,
];
- $this->tableGateway->insert($data);
+ $id = (int)$download->downloads_id;
+ if ($id === 0) {
+ $this->tableGateway->insert($data);
+ return;
+ }
+
+ try {
+ $this->getDownload($id);
+ } catch (RuntimeException $e) {
+ return;
+ }
+ $this->tableGateway->update($data, ['downloads_id' => $id]);
}
}
blob - 4efd5dd8f411b2768a29215df987df527effaea6
blob + 9806c07e801dea21c277413aeee58a88492dc697
--- module/Securitx/view/securitx/cdownload/cdownload.phtml
+++ module/Securitx/view/securitx/cdownload/cdownload.phtml
<?php
- $this->headTitle('SecuritX: Download');
+use Securitx\Model\DownloadsTable;
+use Securitx\Model\Downloads;
+ $this->headTitle('SecuritX: Downloads');
?>
+<script>
+ function add_date(name) {
+ document.getElementById(name).innerHTML = "Today";
+ document.getElementById(name+'_a').style.textDecoration = "line-through";
+ document.getElementById(name+'_a').style.color = "#000000";
+ }
+</script>
<div class="jumbotron">
<h1 class="display-4">Welcome to SecuritX</h1>
-
- <p>You've reached your SecuritX downloader!</p>
-
+ <p>Hello, <?= $first ?>.<br />
+ You've reached your SecuritX company file downloader!<br />
+ Links are good for five days.</p>
<hr class="my-4">
+<div class="downloads">
+ <div class="dfilem">File Name</div>
+ <div class="mdatem">File Sent Date</div>
+ <div class="dloadm">File Downloaded</div>
+ <div class="clear"></div>
+<?php
+ foreach(array_reverse($downloads) as $download) {
+ $date = new DateTime;
+ $date->setTimestamp($download->moddate);
+ $class = "";
+ if ($download->downloaded != 0)
+ $class = "strike";
+
+ echo "<div class='dfile'><a id='" . $download->id_key . "_a' class='$class' onclick='add_date(\"$download->id_key\")' href='/securitx/downloader/$u_key?id=$download->downloads_id&type=c'>$download->id_key.pdf</a></div>";
+ echo "<div class='mdate'>" . $date->format('Y-m-d H:i:s') . "</div>";
+ echo "<div id='$download->id_key' class='dload'>";
+ if ($download->downloaded == 0)
+ echo "No";
+ else {
+ $date->setTimestamp($download->downloaded);
+ echo $date->format('Y-m-d H:i:s');
+ }
+ echo "</div><div class='clear'></div>";
+ }
+?>
+</div>
<br /><p><a class="a a-pad" href="/securitx/home/<?= $u_key ?>">Go home</a></p>
</div>
blob - 4efd5dd8f411b2768a29215df987df527effaea6
blob + 3f2487be3a7010284db8a726537cd99bd33566a7
--- module/Securitx/view/securitx/download/download.phtml
+++ module/Securitx/view/securitx/download/download.phtml
<?php
- $this->headTitle('SecuritX: Download');
+use Securitx\Model\DownloadsTable;
+use Securitx\Model\Downloads;
+ $this->headTitle('SecuritX: Downloads');
?>
+<script>
+ function add_date(name) {
+ document.getElementById(name).innerHTML = "Today";
+ document.getElementById(name+'_a').style.textDecoration = "line-through";
+ document.getElementById(name+'_a').style.color = "#000000";
+ }
+</script>
<div class="jumbotron">
<h1 class="display-4">Welcome to SecuritX</h1>
-
- <p>You've reached your SecuritX downloader!</p>
-
+ <p>Hello, <?= $first ?>.<br />
+ You've reached your SecuritX personal file downloader!<br />
+ Links are good for five days.</p>
<hr class="my-4">
+<div class="downloads">
+ <div class="dfilem">File Name</div>
+ <div class="mdatem">File Sent Date</div>
+ <div class="dloadm">File Downloaded</div>
+ <div class="clear"></div>
+<?php
+ foreach(array_reverse($downloads) as $download) {
+ $date = new DateTime;
+ $date->setTimestamp($download->moddate);
+ $class = "";
+ if ($download->downloaded != 0)
+ $class = "strike";
+
+ echo "<div class='dfile'><a id='" . $download->id_key . "_a' class='$class' onclick='add_date(\"$download->id_key\")' href='/securitx/downloader/$u_key?id=$download->downloads_id&type=p'>$download->id_key.pdf</a></div>";
+ echo "<div class='mdate'>" . $date->format('Y-m-d H:i:s') . "</div>";
+ echo "<div id='$download->id_key' class='dload'>";
+ if ($download->downloaded == 0)
+ echo "No";
+ else {
+ $date->setTimestamp($download->downloaded);
+ echo $date->format('Y-m-d H:i:s');
+ }
+ echo "</div><div class='clear'></div>";
+ }
+?>
+</div>
<br /><p><a class="a a-pad" href="/securitx/home/<?= $u_key ?>">Go home</a></p>
</div>
blob - 891c6fa1270a066fc021d6cde5fae1ead4ee69fa
blob + 4c89ff5ccc112ef75369f85e15a1504209661679
--- module/Securitx/view/securitx/home/home.phtml
+++ module/Securitx/view/securitx/home/home.phtml
if ($member->inviter) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/send/<?= $member->u_key ?>">Send files to <?= $inviter ?> »</a></p>
<?php }
- if (!$member->is_admin && !$member->is_editor) { ?>
+ if ($has_domain && !$member->r_admin && !$member->r_editor) {
+ echo "You are an employee of the company. Please request an action below.";
+ }
+ if ($has_domain && !$member->is_admin && !$member->is_editor) {
+ echo "Please wait for an administrator to review your request";
+ }
+ if (!$member->is_admin && !$member->is_editor && !$has_domain) { ?>
<p><a class="btn btn-secondary btn-lg" href="/securitx/upload/<?= $member->u_key ?>">Upload files to <?= $company ?> »</a></p>
<?php } ?>
blob - b106909ae95309f270d997928de33091f961ed48
blob + 30c1e6bdb7290bc389fca0897717123dc27e3da5
--- public/css/style.css
+++ public/css/style.css
.a-pad {
padding: 0.375rem 0.75rem;
}
+
+.downloads {
+ width: 100%
+}
+.dfilem {
+ background-color: #77a5d9;
+ width: 33%;
+ padding: 10px;
+ border: 1px solid;
+ font-weight: bold;
+ float: left;
+}
+.mdatem {
+ background-color: #77a5d9;
+ width: 33%;
+ padding: 10px;
+ border: 1px solid;
+ font-weight: bold;
+ float: left;
+}
+.dloadm {
+ background-color: #77a5d9;
+ width: 33%;
+ padding: 10px;
+ border: 1px solid;
+ font-weight: bold;
+ float: left;
+}
+.dfile {
+ background-color: #ffffff;
+ width: 33%;
+ padding: 10px;
+ border: 1px solid;
+ float: left;
+}
+.mdate {
+ background-color: #ffffff;
+ width: 33%;
+ padding: 10px;
+ border: 1px solid;
+ float: left;
+}
+.dload {
+ background-color: #ffffff;
+ width: 33%;
+ padding: 10px;
+ border: 1px solid;
+ float: left;
+}
+.clear {
+ clear:both;
+}
+.strike {
+ text-decoration: line-through;
+ color: #000000;
+}