| Server IP : 104.21.21.239 / Your IP : 216.73.216.68 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/banners/domains/stagemag/ |
Upload File : |
<?php
include 'header.php';
set_time_limit(600);
$programid = resolve_programid();
require_program_access($programid, $getuser);
$typer = intval($_GET['typer'] ?? 1);
$imagepath = '/home/banners/domains/stagemag/temp/';
?>
<style>
.feature-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
.feature-card-header { background: linear-gradient(135deg, #b20223 0%, #8a011a 100%); color: #fff; padding: 12px 20px; border-radius: 7px 7px 0 0; font-size: 18px; font-weight: 600; }
.feature-card-body { padding: 20px; }
.feature-card-body p { color: #555; margin-bottom: 15px; line-height: 1.5; }
.feature-card-body label { font-weight: 600; color: #333; display: block; margin-bottom: 5px; margin-top: 15px; }
.feature-card-body label:first-child { margin-top: 0; }
.feature-card-body select, .feature-card-body input[type="text"] { padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.feature-card-body textarea { padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.feature-row { margin-bottom: 15px; }
.feature-row:last-child { margin-bottom: 0; }
.media-table { width: 100%; border-collapse: collapse; }
.media-table th { background: #f5f5f5; padding: 10px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid #e0e0e0; }
.media-table td { padding: 10px 12px; border-bottom: 1px solid #eee; vertical-align: middle; }
.media-table tr:hover { background: #fafafa; }
.btn-save { background-color: #b20223; color: white; border: none; padding: 10px 25px; border-radius: 4px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-save:hover { background-color: #8a011a; }
.btn-add { display: inline-block; background-color: #b20223; color: white; border: none; padding: 10px 20px; border-radius: 4px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-add:hover { background-color: #8a011a; color: white; }
.btn-action { color: #b20223; text-decoration: none; font-size: 13px; margin-right: 10px; }
.btn-action:hover { text-decoration: underline; }
.btn-delete { color: #c00; text-decoration: none; font-size: 13px; }
.btn-delete:hover { text-decoration: underline; }
.current-media { border: 1px solid #e0e0e0; border-radius: 8px; padding: 10px; background: #f9f9f9; display: inline-block; margin-bottom: 15px; }
.current-media img { max-height: 120px; border-radius: 4px; }
.video-container { position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; margin-bottom: 20px; overflow: hidden; }
.video-container iframe, .video-container object, .video-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
</style>
<?php
// Get existing items
$stmt = db_write()->prepare("SELECT * FROM stagemag.multimedia WHERE programid = ? AND typer = ? ORDER BY ordernum");
$stmt->execute([$programid, $typer]);
$getcast = $stmt->fetchAll();
// Delete
if (isset($_GET['delete'])) {
$stmt = db_write()->prepare("DELETE FROM stagemag.multimedia WHERE id = ?");
$stmt->execute([intval($_GET['delete'])]);
}
// Save edit
if (isset($_GET['editsaveclient'])) {
$editsaveclient = intval($_GET['editsaveclient']);
$video = $_POST['video'] ?? '';
$caption = $_POST['caption'] ?? '';
$stmt = db_write()->prepare("UPDATE stagemag.multimedia SET caption = ?, video = ? WHERE id = ?");
$stmt->execute([$caption, $video, $editsaveclient]);
// Photo upload
$uploadExt = isset($_FILES['photo']) ? validate_image_upload($_FILES['photo']) : null;
if ($uploadExt !== null) {
$uuid = uniqid() . '-' . bin2hex(random_bytes(4));
$photo = $uuid . '.' . $uploadExt;
move_uploaded_file($_FILES['photo']['tmp_name'], $imagepath . $photo);
try {
graphicsmagick('ResizeWidth', $imagepath . $photo, $imagepath . 'nd' . $photo, ['width' => 300, 'quality' => 100]);
} catch (Exception $e) {
copy($imagepath . $photo, $imagepath . 'nd' . $photo);
}
s3_upload($imagepath . $photo, 'stagemag/' . $photo);
@unlink($imagepath . $photo);
s3_upload($imagepath . 'nd' . $photo, 'stagemag/nd' . $photo);
@unlink($imagepath . 'nd' . $photo);
$stmt = db_write()->prepare("UPDATE stagemag.multimedia SET image = ? WHERE id = ?");
$stmt->execute([$photo, $editsaveclient]);
}
if (isset($_POST['buttarticleman'])) {
header('Location: /programedit-multimedia.php?id=' . $editsaveclient . '&programid=' . urlencode($programid) . '&typer=' . $typer);
} else {
header('Location: /programedit-multimedia.php?programid=' . urlencode($programid) . '&typer=' . $typer);
}
exit;
}
// Add new item
if (isset($_GET['add'])) {
$stmt = db_write()->prepare("SELECT ordernum FROM stagemag.multimedia WHERE programid = ? AND typer = ? ORDER BY ordernum DESC LIMIT 1");
$stmt->execute([$programid, $typer]);
$getordernum = $stmt->fetch();
$newordernum = (!$getordernum) ? 1 : $getordernum['ordernum'] + 1;
$stmt = db_write()->prepare("INSERT INTO stagemag.multimedia (programid, ordernum, typer) VALUES (?, ?, ?)");
$stmt->execute([$programid, $newordernum, $typer]);
$stmt = db_write()->prepare("SELECT id FROM stagemag.multimedia ORDER BY id DESC LIMIT 1");
$stmt->execute();
$getblast = $stmt->fetch();
header('Location: /programedit-multimedia.php?programid=' . urlencode($programid) . '&edit=' . $getblast['id'] . '&typer=' . $typer);
exit;
}
?>
<div id="content" style="max-width: 900px;">
<div id="content-header">
<h2> Manage <?= ($typer == 1) ? 'Photos' : 'Videos' ?></h2>
</div>
<div class="container-fluid">
<div style="margin-bottom: 20px;">
<a href="programedit-multimedia.php?add=on&programid=<?= $programid ?>&typer=<?= $typer ?>" class="btn-add">Add <?= ($typer == 1) ? 'Photo' : 'Video' ?></a>
</div>
<?php if (isset($_GET['edit'])):
$editId = intval($_GET['edit']);
if (!is_numeric($programid) || !is_numeric($editId)) { header('Location: /'); exit; }
$stmt = db_read()->prepare("SELECT * FROM stagemag.multimedia WHERE programid = ? AND id = ?");
$stmt->execute([$programid, $editId]);
$geter = $stmt->fetch();
?>
<div class="feature-card">
<div class="feature-card-header">Edit <?= ($typer == 1) ? 'Photo' : 'Video' ?></div>
<div class="feature-card-body">
<?php if ($geter['image'] !== ''): ?>
<div class="current-media">
<img src="https://cloudimages.broadwayworld.com/stagemag/nd<?= htmlspecialchars($geter['image']) ?>">
</div>
<?php endif; ?>
<FORM action="programedit-multimedia.php?editsaveclient=<?= $editId ?>&programid=<?= $programid ?>&typer=<?= $typer ?>" method="post" enctype="multipart/form-data">
<div class="feature-row">
<label>Caption</label>
<input name="caption" style="width:100%; max-width:500px;" type="text" value="<?= htmlspecialchars($geter['caption']) ?>">
</div>
<?php if ($typer == 2): ?>
<div class="feature-row">
<label>Video Embed Code</label>
<textarea name="video" style="width:100%; max-width:500px; height:200px;" placeholder="You can copy/paste the embed code for videos on YouTube, Facebook, Instagram, Vimeo & More..."><?= htmlspecialchars($geter['video']) ?></textarea>
</div>
<?php else: ?>
<div class="feature-row">
<label>Photo</label>
<p style="margin: 0 0 10px 0; font-size: 13px; color: #666;">Recommended: 1000 pixels wide</p>
<input type="file" name="photo" style="padding: 8px 0;">
</div>
<?php endif; ?>
<div style="margin-top: 20px; display: flex; gap: 15px; align-items: center;">
<button type="submit" name="buttadminman" class="btn-save">Upload</button>
<a href="programedit-multimedia.php?programid=<?= $programid ?>&typer=<?= $typer ?>" style="color: #666;">Cancel</a>
</div>
</form>
<div style="margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee;">
<a href="programedit-multimedia.php?delete=<?= $editId ?>&programid=<?= $programid ?>&typer=<?= $typer ?>" onclick="return confirm('Are you sure?');" class="btn-delete">Delete This <?= ($typer == 1) ? 'Photo' : 'Video' ?></a>
</div>
</div>
</div>
<?php else: ?>
<?php
// Sort order save
if (isset($_POST['sort_order']) && $_POST['sort_order'] !== '') {
$sort_order = str_ireplace('section_id_', '', $_POST['sort_order']);
$ids = explode(',', $sort_order);
foreach ($ids as $ndx => $id) {
$stmt = db_write()->prepare("UPDATE stagemag.multimedia SET ordernum = ? WHERE id = ?");
$stmt->execute([$ndx + 1, intval($id)]);
}
}
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/TableDnD/1.0.4/jquery.tablednd.min.js" integrity="sha512-yWU5jqsvn25Wl+rBp0hB2gY8mtPQJypx2spvFPEsEPyReMRaiKBkgAoPrFDiBZyKJhFlj2+7Est4UKT0mS71wQ==" crossorigin="anonymous"></script>
<script type="text/javascript">
$(function(){
$("#sortable-tbl").tableDnD();
$('#frm-sort').submit(function(){
var sRowOrder = "";
$("#sortable-tbl tr").each(function(i,o){
if (sRowOrder.length) { sRowOrder += "," + o.id; } else { sRowOrder = o.id; }
});
$('#sort_order').val(sRowOrder);
});
});
</script>
<?php
// Re-fetch for display after potential sort
$stmt = db_write()->prepare("SELECT * FROM stagemag.multimedia WHERE programid = ? AND typer = ? ORDER BY ordernum");
$stmt->execute([$programid, $typer]);
$getcast = $stmt->fetchAll();
if (count($getcast) > 0):
?>
<div class="feature-card">
<div class="feature-card-header">Current <?= ($typer == 1) ? 'Photos' : 'Videos' ?></div>
<div class="feature-card-body" style="padding: 0;">
<p style="padding: 15px 20px 0 20px; margin-bottom: 10px;">Click and drag to change the order.</p>
<table id="sortable-tbl" class="media-table">
<tr><th>Caption</th><th>Preview</th><th>Actions</th></tr>
<?php foreach ($getcast as $row): ?>
<tr id="section_id_<?= $row['id'] ?>" style="cursor: move;">
<td><?= htmlspecialchars($row['caption']) ?></td>
<td style="text-align: center;<?= ($row['video'] !== '') ? 'width:300px;' : '' ?>">
<?php if ($row['image'] !== ''): ?>
<img src="https://cloudimages.broadwayworld.com/stagemag/nd<?= htmlspecialchars($row['image']) ?>" style="max-height:80px; border-radius: 4px;">
<?php else: ?>
<div class="video-container" style="max-width: 250px; margin: 0 auto;">
<?= $row['video'] ?>
</div>
<?php endif; ?>
</td>
<td>
<a href="programedit-multimedia.php?edit=<?= $row['id'] ?>&programid=<?= $programid ?>&typer=<?= $typer ?>" class="btn-action">Edit</a>
<a href="programedit-multimedia.php?delete=<?= $row['id'] ?>&programid=<?= $programid ?>&typer=<?= $typer ?>" onclick="return confirm('Are you sure?');" class="btn-delete">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
<form id="frm-sort" action="/programedit-multimedia.php?programid=<?= $programid ?>&typer=<?= $typer ?>" method="post">
<input type="hidden" name="sort_order" id="sort_order" value="" />
<button type="submit" name="save" class="btn-save">Save Order</button>
</form>
<?php endif; ?>
<?php endif; ?>
</div>
<!--Footer-part-->
<br><br><br><br>
<?php include 'footer.php'; ?>