HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/alq-cali.bikenow.co/public/js/podcast_club.js
var myDropzone;
var id;
var deleteImageArray = [];

$(document).ready(function () {
    $('.select2').select2();
    if (window.Dropzone) {
        window.Dropzone.autoDiscover = false;
        myDropzone = new Dropzone("#dropzone", {
            autoProcessQueue: false,
            addRemoveLinks: true,
            url: window.location.origin + "/podcasts/saveImages",
            method: "post",
            maxFilesize: 40, // in MB
            acceptedFiles: ".png, .jpg, .jpeg",
            paramName: "file", // Name of the uploaded file parameter
            dictDefaultMessage: "Drop files here to upload",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            maxFiles: 1,
            parallelUploads: 1,
            init: function () {
                let myDropzone = this;
                // Obtiene el valor del input oculto que contiene las URLs
                let urlInput = document.querySelector("input[type='hidden'][name='urls']").value;

                let urls = urlInput.split(',');

                urls.forEach(url => {
                    if (url.trim()) {
                        fetch(url)
                            .then(response => {
                                if (!response.ok) {
                                    throw new Error('Network response was not ok');
                                }
                                return response.blob();
                            })
                            .then(blob => {
                                const blobUrl = URL.createObjectURL(blob);

                                let mockFile = { name: url.split("/").pop(), size: 1000, flags: "server", url: url };

                                myDropzone.displayExistingFile(mockFile, blobUrl);

                                myDropzone.on("success", function (file, response) {
                                });
                            })
                            .catch(error => {
                                console.error('There was a problem with the fetch operation:', error);
                            });
                    }
                });

                this.on("success", function (file, response) {
                });
                this.on("error", function (file, errorMessage, xhr) {
                    // Mostrar mensaje de error al usuario
                    alert("Hubo un error al subir el archivo: " + errorMessage);
                });

            },
            removedfile: function (file) {
                if (file.flags) {
                    let id = document.getElementById("id").value;
                    deleteImageArray.push(file.url);
                }
                if (file.previewElement != null && file.previewElement.parentNode != null) {
                    file.previewElement.parentNode.removeChild(file.previewElement);
                }
                return this._updateMaxFilesReachedClass();
            }
        });
    }
});

function create() {
    createRegister(
        '/podcasts/create',
        Lang.get("messagesClient.podcasts.create_question"),
        "/podcasts",
        null,
        null,
        myDropzone
    );

}

function clickEdit(value) {
    $(location).attr("href", "/podcasts/edit/" + value);
}

function edit() {
    editRegister(
        '/podcasts/update/',
        Lang.get("messagesClient.podcasts.edit_question"),
        "/podcasts",
        null,
        null,
        myDropzone,
        deleteImageArray
    );
}

function clickDelete(value) {
    deleteRegister(
        "/podcasts/delete/" + value,
        Lang.get("messagesClient.podcasts.delete_question"),
        "/podcasts"
    );
}

function chk(value) {
    activate(value, "/podcasts/active");
}

function clickDeleteProductImage(value, imageToDelete) {

    swal(Lang.get("messagesClient.product_tag11"), {
        buttons: {
            cancel: "No",
            Ok: true,
        },
    }).then((val) => {
        if (val == "Ok") {
            var info = {
                id: value,
                link: imageToDelete,
            };

            $.ajax({
                url: "podcasts/deletedImage",
                type: "POST",
                contentType: "application/json",
                headers: {
                    "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
                    "Content-Type": "application/json",
                },
                data: JSON.stringify(info),
                success: function (r) {
                    if (r.r) {
                        swal(r.m, {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            },
                        }).then((val) => {
                            if (val == "Ok") {
                                $(location).attr('href', '/podcasts');
                            }
                        });
                    } else {
                        swal("Error", r.m, "error");
                    }
                },
                error: function (e) {
                    swal("Error", Lang.get("messagesClient.product_tag12"), "error");
                },
            });
        }
    });
}

function clickCopy(value) {
    $(location).attr("href", "/podcasts/add/" + value);
}