Skip to content

Commit

Permalink
Merge pull request #3868 from AllskyTeam/3867-remove-ability-to-uploa…
Browse files Browse the repository at this point in the history
…d-modules

#3867 Remove module upload functions
  • Loading branch information
EricClaeys authored Sep 15, 2024
2 parents e7db7bb + 0cf4bf6 commit 70990f6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 69 deletions.
3 changes: 0 additions & 3 deletions html/includes/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ function DisplayModule() {
<div class="btn btn-lg navbar-btn" id="module-editor-save"><i class="fa-solid fa-floppy-disk"></i></div>
</div>
</li>
<li>
<div class="btn btn-lg navbar-btn" id="module-editor-new" data-toggle="tooltip" data-placement="top" data-container="body" title="Add A New Module"><i class="fa-solid fa-upload"></i></div>
</li>
<li class="btn-lg">
<form id="oe-item-list-edit-dialog-form" class="form-horizontal">
<div class="form-group">
Expand Down
36 changes: 0 additions & 36 deletions html/includes/moduleutil.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,42 +380,6 @@ public function deleteModules() {
}
}

public function postUpload() {
$data = $_FILES['module-file'];
$sourcePath = $_FILES['module-file']['tmp_name'];
$scriptName = str_replace("zip","py",$_FILES['module-file']['name']);

$targetPath = $this->userModules . '/' . $scriptName ;

$zipArchive = new ZipArchive();
$zipArchive->open($sourcePath);
for ($i = 0; $i < $zipArchive->numFiles; $i++) {
$stat = $zipArchive->statIndex($i);

$nameInArchive = $stat['name'];

if ($scriptName == $nameInArchive) {
$fp = $zipArchive->getStream($nameInArchive);
if (!$fp) {
$this->send500('Unable to extract module from zip file');
}

$contents = '';
while (!feof($fp)) {
$contents .= fread($fp, 1024);
}
fclose($fp);

$file = fopen($targetPath, 'wb');
fwrite($file, $contents);
fclose($file);
$this->sendResponse();
break;
}
}
$this->send500('Unable to locate module in zip file');
}

public function getReset() {
$flow = $_GET['flow'];

Expand Down
30 changes: 0 additions & 30 deletions html/js/modules/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,27 +849,6 @@ class MODULESEDITOR {
}
}

#uploadFile(form) {
$.LoadingOverlay('show');
$('#module-upload-dialog').modal('hide');

$.ajax({
type: 'POST',
url: 'includes/moduleutil.php?request=Upload',
data: new FormData(form),
contentType: false,
cache: false,
processData: false,
context: this
}).done(function () {
this.#buildUI();
}).fail(function () {
bootbox.alert('Failed to upload the plugin. Unable to move the file');
}).always(function () {
$.LoadingOverlay('hide');
});
}

#showDebug() {
$.ajax({
url: 'includes/moduleutil.php?request=Modules&event=' + this.#eventName,
Expand Down Expand Up @@ -1044,15 +1023,6 @@ class MODULESEDITOR {
}
});

$(document).on('click', '#module-editor-new', () => {
$('#module-upload-dialog').modal('show');
});

$('#module-upload-dialog-form').on('submit', (e) => {
e.preventDefault();
this.#uploadFile(e.target);
});

this.#buildUI();
}

Expand Down

0 comments on commit 70990f6

Please sign in to comment.