Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3867 Remove module upload functions #3868

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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