(options = {})
| 5847 | } |
| 5848 | |
| 5849 | export function initProBundleInstaller(options = {}) { |
| 5850 | try { |
| 5851 | const fileInput = document.getElementById('proBundleFile'); |
| 5852 | const btn = document.getElementById('btnInstallProBundle'); |
| 5853 | const dlBtn = document.getElementById('btnDownloadProBundle'); |
| 5854 | const statusEl = document.getElementById('proBundleStatus'); |
| 5855 | const updatesExpired = !!options.updatesExpired; |
| 5856 | const updatesUntilLabel = options.updatesUntil ? String(options.updatesUntil) : ''; |
| 5857 | |
| 5858 | if (!fileInput || !btn || !statusEl) return; |
| 5859 | |
| 5860 | // Allow names like: FileRisePro_v1.0.0.zip or FileRisePro-1.0.0.zip |
| 5861 | const PRO_ZIP_NAME_RE = /^FileRisePro[_-]v?[0-9]+\.[0-9]+\.[0-9]+\.zip$/i; |
| 5862 | |
| 5863 | btn.addEventListener('click', async () => { |
| 5864 | const file = fileInput.files && fileInput.files[0]; |
| 5865 | |
| 5866 | if (!file) { |
| 5867 | statusEl.textContent = 'Choose a FileRise Pro .zip bundle first.'; |
| 5868 | statusEl.className = 'small text-danger'; |
| 5869 | return; |
| 5870 | } |
| 5871 | |
| 5872 | const name = file.name || ''; |
| 5873 | if (!PRO_ZIP_NAME_RE.test(name)) { |
| 5874 | statusEl.textContent = 'Bundle must be named like "FileRisePro_v1.0.0.zip".'; |
| 5875 | statusEl.className = 'small text-danger'; |
| 5876 | return; |
| 5877 | } |
| 5878 | |
| 5879 | if (updatesExpired) { |
| 5880 | const when = updatesUntilLabel ? ` on ${updatesUntilLabel}` : ''; |
| 5881 | const ok = await showCustomConfirmModal( |
| 5882 | `Updates expired${when}. Installing a newer Pro bundle will deactivate Pro. Continue only if this bundle is eligible for your license.` |
| 5883 | ); |
| 5884 | if (!ok) { |
| 5885 | return; |
| 5886 | } |
| 5887 | } |
| 5888 | |
| 5889 | const formData = new FormData(); |
| 5890 | formData.append('bundle', file); |
| 5891 | |
| 5892 | statusEl.textContent = 'Uploading and installing Pro bundle...'; |
| 5893 | statusEl.className = 'small text-muted'; |
| 5894 | const progress = startProBundleProgress({ |
| 5895 | action: 'Installing Pro', |
| 5896 | title: 'Installing FileRise Pro bundle' |
| 5897 | }); |
| 5898 | |
| 5899 | try { |
| 5900 | const resp = await fetch('/api/admin/installProBundle.php', { |
| 5901 | method: 'POST', |
| 5902 | headers: { |
| 5903 | 'X-CSRF-Token': window.csrfToken || '' |
| 5904 | }, |
| 5905 | body: formData |
| 5906 | }); |
no test coverage detected