%PDF-1.4 %Óëéá 1 0 obj <> endobj 3 0 obj <> endobj 4 0 obj <
| Server IP : 212.252.79.165 / Your IP : 216.73.216.24 [ Web Server : Apache System : Linux 212-252-79-165.cprapid.com 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64 User : cehaburo ( 1001) PHP Version : 8.1.33 Disable Function : exec,passthru,shell_exec,system Domains : 48 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/cehaburo/public_html/admin/ |
Upload File : |
<?php
include 'lib/include.php';
// Fetch existing categories to allow selection of parent category
$select_category = $ceha->query("SELECT * FROM tbl_qr_category");
$categories = [];
while ($cat = $select_category->fetch_assoc()) {
$categories[] = $cat;
}
// Function to build the category tree
function buildCategoryTree(array $categories, $parent_id = 0) {
$branch = [];
foreach ($categories as $category) {
if ($category['parent_id'] == $parent_id) {
$children = buildCategoryTree($categories, $category['id']);
if ($children) {
$category['children'] = $children;
}
$branch[] = $category;
}
}
return $branch;
}
$category_tree = buildCategoryTree($categories);
include 'header.php';
?>
<div class="container">
<div class="row align-items-center mb-3">
<div class="col-6">
<div class="row">
<div class="col-6">
<h4 class="card-title">Yeni QR Sayfa</h4>
</div>
</div>
</div>
<div class="col-6 text-right">
<button type="submit" form="qrForm" class="btn btn-primary" style="width: 200px;">Ekle</button>
</div>
</div>
<div class="row">
<div class="col-md-6 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<form id="qrForm" action="dba/qr-create.php" method="post" enctype="multipart/form-data" class="forms-sample">
<div class="form-group">
<label>Başlık</label>
<input type="text" class="form-control" name="title" required>
</div>
<div class="form-group">
<label>Alt Başlık</label>
<input type="text" class="form-control" name="alt_title" required>
</div>
<div class="form-group">
<label>Kategori</label>
<select class="form-control" name="category_id" required>
<option value="">Kategori Seçiniz</option>
<?php
function renderCategoryOptions($categories, $level = 0) {
foreach ($categories as $category) {
echo '<option value="' . htmlspecialchars($category['id'], ENT_QUOTES, 'UTF-8') . '">';
echo str_repeat(' ', $level * 4) . htmlspecialchars($category['name'], ENT_QUOTES, 'UTF-8');
echo '</option>';
if (isset($category['children'])) {
renderCategoryOptions($category['children'], $level + 1);
}
}
}
renderCategoryOptions($category_tree);
?>
</select>
</div>
<div class="form-group">
<label>Video Embed</label>
<textarea class="form-control" name="video_url"></textarea>
</div>
<div class="form-group">
<label>Galeri</label>
<div id="gallery" class="dropzone" style="border: 1px dashed #cdd4e0; padding: 20px;">
<div class="dz-message">Fotoğraf yükle</div>
</div>
</div>
<input type="hidden" name="pdf_url_hidden" id="pdf_url_hidden" value="">
</form>
</div>
</div>
</div>
<div class="col-md-6 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<label>Teknik Döküman</label>
<div id="pdfDropArea" style="border: 1px dashed #cdd4e0; padding: 20px; text-align: center;">
Teknik döküman yükle
<input type="file" id="pdfFile" name="pdf_url" accept="application/pdf" class="form-control-file" style="display: none;">
</div>
<div id="pdfLoader" style="display: none;">Yükleniyor...</div>
<div id="pdfPreview" style="margin-top: 10px; max-height: 600px; overflow-y: auto;"></div>
<div id="pdfControls" style="display: none; margin-top: 10px;">
<button type="button" id="prevPage" class="btn btn-primary btn-icon"><i class="mdi mdi-arrow-left"></i></button>
<button type="button" id="nextPage" class="btn btn-primary btn-icon"><i class="mdi mdi-arrow-right"></i></button>
<span>Sayfa: <span id="pageNum"></span> / <span id="pageCount"></span></span>
<button type="button" id="removePdf" class="btn btn-primary btn-icon"><i class="mdi mdi-delete"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>
<!-- Add custom styles for 16:9 aspect ratio -->
<style>
.dropzone .dz-preview .dz-image {
width: 100%;
padding-top: 56.25%; /* 16:9 aspect ratio */
position: relative;
}
.dropzone .dz-preview .dz-image img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
#gallery {
position: relative;
}
#gallery .dz-message {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
font-size: 14px;
color: #1c273c;
}
.dropzone.dz-started .dz-message {
display: none !important;
}
#pdfDropArea {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
font-size: 14px;
color: #1c273c;
}
#pdfDropArea:hover {
cursor: pointer;
}
</style>
<!-- Include Dropzone.js and Sortable.js libraries -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.7.2/min/dropzone.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.7.2/min/dropzone.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.14.0/Sortable.min.js"></script>
<!-- Include PDF.js library -->
<script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.8.335/build/pdf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@2.8.335/build/pdf.worker.min.js"></script>
<script>
Dropzone.autoDiscover = false;
var galleryDropzone = new Dropzone("#gallery", {
url: "dba/qr-upload.php",
paramName: "file",
addRemoveLinks: false,
thumbnailWidth: null, // Set to null to maintain aspect ratio
thumbnailHeight: null, // Set to null to maintain aspect ratio
dictDefaultMessage: "Fotoğraf yükle",
dictFallbackMessage: "Tarayıcınız dosya yüklemeyi desteklemiyor.",
dictFallbackText: "Lütfen eski usul formu kullanarak dosyalarınızı yükleyin.",
dictFileTooBig: "Dosya çok büyük ({{filesize}}MB). Maksimum boyut: {{maxFilesize}}MB.",
dictInvalidFileType: "Bu dosya tipini yükleyemezsiniz.",
dictResponseError: "Sunucu hatası. Kod: {{statusCode}}.",
dictCancelUpload: "Yüklemeyi iptal et",
dictCancelUploadConfirmation: "Yüklemeyi iptal etmek istediğinize emin misiniz?",
dictRemoveFile: "Sil",
dictRemoveFileConfirmation: null,
dictMaxFilesExceeded: "Daha fazla dosya yükleyemezsiniz.",
previewTemplate: `
<div class="dz-preview dz-file-preview">
<div class="dz-image"><img data-dz-thumbnail /></div>
<div class="dz-details">
<div class="dz-size"><span data-dz-size></span></div>
<div class="dz-filename"><span data-dz-name></span></div>
</div>
<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
<div class="dz-success-mark"><span>✔</span></div>
<div class="dz-error-mark"><span>✘</span></div>
<div class="dz-error-message"><span data-dz-errormessage></span></div>
<a class="dz-remove" href="javascript:undefined;" data-dz-remove>Sil</a>
</div>`,
success: function(file, response) {
console.log('Upload response:', response);
var filePath;
try {
if (typeof response === 'string') {
response = JSON.parse(response);
}
filePath = response.filePath;
console.log('File path:', filePath);
var input = document.createElement("input");
input.type = "hidden";
input.name = "gallery_images[]";
input.value = filePath;
input.classList.add("gallery-hidden-input");
file.previewElement.appendChild(input);
} catch (e) {
console.error('Error parsing response:', e);
}
},
error: function(file, response) {
console.error('Upload error:', response);
},
removedfile: function(file) {
if (file.previewElement) {
var input = file.previewElement.querySelector(".gallery-hidden-input");
var filePath = input ? input.value : null;
if (filePath) {
fetch('dba/qr-delete.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ filePath: filePath })
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log('File removed:', filePath);
} else {
console.error('Error removing file:', data.error);
}
})
.catch(error => console.error('Error:', error));
}
file.previewElement.parentNode.removeChild(file.previewElement);
}
}
});
// Initialize Sortable
var el = document.getElementById('gallery');
var sortable = Sortable.create(el, {
animation: 150
});
// Initialize PDF.js
const pdfjsLib = window['pdfjs-dist/build/pdf'];
pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@2.8.335/build/pdf.worker.min.js';
let pdfDoc = null,
pageNum = 1,
pageRendering = false,
pageNumPending = null,
pdfCanvas = document.createElement('canvas'),
ctx = pdfCanvas.getContext('2d');
const pdfFileInput = document.getElementById('pdfFile');
const pdfDropArea = document.getElementById('pdfDropArea');
const pdfLoader = document.getElementById('pdfLoader');
const pdfControls = document.getElementById('pdfControls');
const pdfPreview = document.getElementById('pdfPreview');
pdfFileInput.addEventListener('change', handleFileSelect);
pdfDropArea.addEventListener('click', () => pdfFileInput.click());
pdfDropArea.addEventListener('dragover', handleDragOver);
pdfDropArea.addEventListener('drop', handleFileDrop);
function handleFileSelect(event) {
const file = event.target.files[0];
if (file && file.type === 'application/pdf') {
const reader = new FileReader();
reader.onload = function(e) {
const arrayBuffer = e.target.result;
uploadPDF(file, arrayBuffer);
};
reader.readAsArrayBuffer(file);
}
}
function handleDragOver(event) {
event.preventDefault();
event.stopPropagation();
pdfDropArea.style.borderColor = '#000';
}
function handleFileDrop(event) {
event.preventDefault();
event.stopPropagation();
pdfDropArea.style.borderColor = '#ccc';
const file = event.dataTransfer.files[0];
if (file && file.type === 'application/pdf') {
const reader = new FileReader();
reader.onload = function(e) {
const arrayBuffer = e.target.result;
uploadPDF(file, arrayBuffer);
};
reader.readAsArrayBuffer(file);
}
}
function uploadPDF(file, arrayBuffer) {
pdfLoader.style.display = 'block';
const formData = new FormData();
formData.append('file', file);
fetch('dba/qr-upload.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
pdfLoader.style.display = 'none';
if (data.filePath) {
document.getElementById('pdf_url_hidden').value = data.filePath;
renderPDF(arrayBuffer);
pdfDropArea.style.display = 'none';
} else {
console.error('Error uploading PDF:', data.error);
}
})
.catch(error => {
pdfLoader.style.display = 'none';
console.error('Error:', error);
});
}
function renderPDF(arrayBuffer) {
pdfjsLib.getDocument(arrayBuffer).promise.then(function(pdf) {
pdfDoc = pdf;
pdfControls.style.display = 'block';
document.getElementById('pageCount').textContent = pdf.numPages;
renderPage(pageNum);
});
}
function renderPage(num) {
pageRendering = true;
pdfDoc.getPage(num).then(function(page) {
const viewport = page.getViewport({ scale: 1.0 });
pdfCanvas.height = viewport.height;
pdfCanvas.width = viewport.width;
const renderContext = {
canvasContext: ctx,
viewport: viewport
};
const renderTask = page.render(renderContext);
renderTask.promise.then(function() {
pageRendering = false;
if (pageNumPending !== null) {
renderPage(pageNumPending);
pageNumPending = null;
}
updatePageControls();
});
});
pdfPreview.innerHTML = ''; // Clear previous preview
pdfPreview.appendChild(pdfCanvas);
document.getElementById('pageNum').textContent = num;
}
function updatePageControls() {
document.getElementById('prevPage').style.display = pageNum <= 1 ? 'none' : 'inline-block';
document.getElementById('nextPage').style.display = pageNum >= pdfDoc.numPages ? 'none' : 'inline-block';
}
function queueRenderPage(num) {
if (pageRendering) {
pageNumPending = num;
} else {
renderPage(num);
}
}
document.getElementById('prevPage').addEventListener('click', function() {
if (pageNum <= 1) {
return;
}
pageNum--;
queueRenderPage(pageNum);
});
document.getElementById('nextPage').addEventListener('click', function() {
if (pageNum >= pdfDoc.numPages) {
return;
}
pageNum++;
queueRenderPage(pageNum);
});
document.getElementById('removePdf').addEventListener('click', function() {
pdfDoc = null;
pageNum = 1;
pageRendering = false;
pageNumPending = null;
pdfFileInput.value = '';
document.getElementById('pdf_url_hidden').value = '';
pdfPreview.innerHTML = '';
pdfControls.style.display = 'none';
pdfDropArea.style.display = 'block';
});
</script>