📂 FileMgr
📍
/var/www/vhosts/nursoft.al/public_html/CampusIEA/admin
✏️ Edit File: /var/www/vhosts/nursoft.al/public_html/CampusIEA/admin/index.php
⬅ Kembali
<?php error_reporting(E_ALL); define('INCLUDE_CHECK', 1); require_once __DIR__ . '/../all_php_files/dbconnect.php'; require_once __DIR__ . '/../all_php_files/session_bootstrap.php'; function admin_query($sql) { return mysqli_query(site_db(), $sql); } function ensure_admin_schema() { admin_query("CREATE TABLE IF NOT EXISTS site_settings ( id int(11) NOT NULL AUTO_INCREMENT, setting_key varchar(120) NOT NULL, value_it text NOT NULL, value_en text NOT NULL, updated_at timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), PRIMARY KEY (id), UNIQUE KEY setting_key (setting_key) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"); admin_query("CREATE TABLE IF NOT EXISTS certificates ( id int(11) NOT NULL AUTO_INCREMENT, certificate_no varchar(80) NOT NULL, student_name varchar(180) NOT NULL, course_title varchar(220) NOT NULL, issue_date date NOT NULL, language enum('it','en') NOT NULL DEFAULT 'it', status enum('valid','revoked','expired') NOT NULL DEFAULT 'valid', issuer varchar(180) NOT NULL DEFAULT 'Campus IEA', notes text DEFAULT NULL, created_at timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (id), UNIQUE KEY certificate_no (certificate_no) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"); if (!db_has_column('certificates', 'pdf_path')) { admin_query("ALTER TABLE certificates ADD pdf_path varchar(255) DEFAULT NULL"); } if (!db_has_column('certificates', 'pdf_original_name')) { admin_query("ALTER TABLE certificates ADD pdf_original_name varchar(255) DEFAULT NULL"); } admin_query("CREATE TABLE IF NOT EXISTS certificate_templates ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(120) NOT NULL, title_it varchar(220) NOT NULL, title_en varchar(220) NOT NULL, body_it text NOT NULL, body_en text NOT NULL, active tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"); admin_query("CREATE TABLE IF NOT EXISTS shop_orders ( id int(11) NOT NULL AUTO_INCREMENT, product_id int(11) NOT NULL, customer_name varchar(180) NOT NULL, customer_email varchar(180) NOT NULL, customer_phone varchar(80) NOT NULL, quantity int(11) NOT NULL DEFAULT 1, message text DEFAULT NULL, status varchar(40) NOT NULL DEFAULT 'new', created_at timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"); admin_query("CREATE TABLE IF NOT EXISTS fair_leads ( id int(11) NOT NULL AUTO_INCREMENT, first_name varchar(120) NOT NULL, last_name varchar(120) NOT NULL, phone varchar(80) NOT NULL, source varchar(120) NOT NULL DEFAULT 'homepage_fair', lang varchar(8) NOT NULL DEFAULT 'it', status varchar(40) NOT NULL DEFAULT 'new', created_at timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (id), KEY phone (phone), KEY status (status) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"); if (!db_has_column('permbledhje', 'titulli_en')) { admin_query("ALTER TABLE permbledhje ADD titulli_en text DEFAULT NULL"); } if (!db_has_column('permbledhje', 'pershkrimi_en')) { admin_query("ALTER TABLE permbledhje ADD pershkrimi_en text DEFAULT NULL"); } if (!db_has_column('products', 'product_name_en')) { admin_query("ALTER TABLE products ADD product_name_en varchar(255) DEFAULT NULL"); } if (!db_has_column('products', 'details_en')) { admin_query("ALTER TABLE products ADD details_en text DEFAULT NULL"); } if (!db_has_column('products', 'official_distributor')) { admin_query("ALTER TABLE products ADD official_distributor tinyint(1) NOT NULL DEFAULT 1"); } if (!db_has_column('products', 'brand')) { admin_query("ALTER TABLE products ADD brand varchar(160) DEFAULT NULL"); } campus_ensure_event_modules(); $defaults = array( 'address' => array('Strada Donika Kastrioti TIRANA (AL), Palazzo No.14, Piano 2', 'Donika Kastrioti Street, Tirana (AL), Building No.14, 2nd Floor'), 'phone' => array('+355 673856399', '+355 673856399'), 'email_1' => array('info@campusiea.com', 'info@campusiea.com'), 'email_2' => array('infostudenti@campusiea.com', 'infostudenti@campusiea.com'), 'home_certificate_title' => array('Verifica certificati Campus IEA', 'Verify Campus IEA certificates'), 'home_certificate_text' => array('Inserisci il codice del certificato per confermare autenticita, intestatario, corso e data di rilascio.', 'Enter the certificate code to confirm authenticity, holder, course and issue date.'), 'home_shop_title' => array('Shop ufficiale', 'Official shop'), 'home_shop_text' => array('Prodotti disponibili solo come distributore ufficiale Campus IEA.', 'Products available only as Campus IEA official distributor.') ); foreach ($defaults as $key => $value) { $k = db_escape($key); $it = db_escape($value[0]); $en = db_escape($value[1]); admin_query("INSERT IGNORE INTO site_settings (setting_key, value_it, value_en) VALUES ('$k', '$it', '$en')"); } $templateCount = (int)db_value("SELECT COUNT(*) FROM certificate_templates", 0); if ($templateCount === 0) { admin_query("INSERT INTO certificate_templates (name, title_it, title_en, body_it, body_en, active) VALUES ('Default', 'Certificato di completamento', 'Certificate of completion', 'Si certifica che {student_name} ha completato con successo {course_title}.', 'This certifies that {student_name} has successfully completed {course_title}.', 1)"); } } function admin_upload($field) { if (!isset($_FILES[$field]) || !is_uploaded_file($_FILES[$field]['tmp_name'])) { return ''; } $name = basename($_FILES[$field]['name']); $name = preg_replace('/[^a-zA-Z0-9._-]/', '-', $name); $target = __DIR__ . '/../images/' . time() . '-' . $name; if (move_uploaded_file($_FILES[$field]['tmp_name'], $target)) { return basename($target); } return ''; } function admin_upload_to($field, $subdir) { if (!isset($_FILES[$field]) || !is_uploaded_file($_FILES[$field]['tmp_name'])) { return ''; } $allowed = array('jpg', 'jpeg', 'png', 'webp', 'gif'); $name = basename($_FILES[$field]['name']); $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (!in_array($ext, $allowed, true)) { return ''; } $clean = preg_replace('/[^a-zA-Z0-9._-]/', '-', $name); $relativeDir = trim($subdir, '/'); $targetDir = __DIR__ . '/../' . $relativeDir; if (!is_dir($targetDir)) { mkdir($targetDir, 0775, true); } $fileName = date('YmdHis') . '-' . substr(md5(uniqid('', true)), 0, 6) . '-' . $clean; $target = $targetDir . '/' . $fileName; if (move_uploaded_file($_FILES[$field]['tmp_name'], $target)) { return $relativeDir . '/' . $fileName; } return ''; } function admin_upload_video($field, $subdir) { if (!isset($_FILES[$field]) || !is_uploaded_file($_FILES[$field]['tmp_name'])) { return ''; } $allowed = array('mp4', 'webm', 'mov', 'm4v'); $name = basename($_FILES[$field]['name']); $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if (!in_array($ext, $allowed, true)) { return ''; } $relativeDir = trim($subdir, '/'); $targetDir = __DIR__ . '/../' . $relativeDir; if (!is_dir($targetDir)) { mkdir($targetDir, 0775, true); } $clean = preg_replace('/[^a-zA-Z0-9._-]/', '-', $name); $fileName = date('YmdHis') . '-' . substr(md5(uniqid('', true)), 0, 6) . '-' . $clean; $target = $targetDir . '/' . $fileName; if (move_uploaded_file($_FILES[$field]['tmp_name'], $target)) { return $relativeDir . '/' . $fileName; } return ''; } function admin_upload_pdf($field, $subdir, $code) { if (!isset($_FILES[$field]) || !is_uploaded_file($_FILES[$field]['tmp_name'])) { return array('', ''); } $name = basename($_FILES[$field]['name']); $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if ($ext !== 'pdf') { return array('', ''); } if (isset($_FILES[$field]['size']) && (int)$_FILES[$field]['size'] > 20 * 1024 * 1024) { return array('', ''); } $relativeDir = trim($subdir, '/'); $targetDir = __DIR__ . '/../' . $relativeDir; if (!is_dir($targetDir)) { mkdir($targetDir, 0775, true); } $safeCode = preg_replace('/[^a-zA-Z0-9_-]+/', '-', (string)$code); $safeCode = trim($safeCode, '-'); if ($safeCode === '') { $safeCode = 'certificate'; } $clean = preg_replace('/[^a-zA-Z0-9._-]/', '-', $name); $fileName = $safeCode . '-' . date('YmdHis') . '-' . $clean; $target = $targetDir . '/' . $fileName; if (move_uploaded_file($_FILES[$field]['tmp_name'], $target)) { return array($relativeDir . '/' . $fileName, $name); } return array('', ''); } function admin_existing_certificate_pdfs() { $dir = __DIR__ . '/../Certificate'; if (!is_dir($dir)) { return array(); } $files = array(); foreach (glob($dir . '/*.pdf') as $file) { $files[] = basename($file); } sort($files); return $files; } function admin_upload_many($field, $subdir) { $paths = array(); if (!isset($_FILES[$field]) || !is_array($_FILES[$field]['name'])) { return $paths; } $count = count($_FILES[$field]['name']); for ($i = 0; $i < $count; $i++) { if (!isset($_FILES[$field]['tmp_name'][$i]) || !is_uploaded_file($_FILES[$field]['tmp_name'][$i])) { continue; } $single = array( 'name' => $_FILES[$field]['name'][$i], 'type' => $_FILES[$field]['type'][$i], 'tmp_name' => $_FILES[$field]['tmp_name'][$i], 'error' => $_FILES[$field]['error'][$i], 'size' => $_FILES[$field]['size'][$i] ); $_FILES['_campus_event_photo'] = $single; $path = admin_upload_to('_campus_event_photo', $subdir); if ($path !== '') { $paths[] = $path; } } unset($_FILES['_campus_event_photo']); return $paths; } function login_ok($username, $password) { $u = db_escape($username); $row = db_row("SELECT * FROM users WHERE username='$u' LIMIT 1"); if ($row) { $stored = (string)$row['password']; if ($stored === $password || password_verify($password, $stored) || md5($password) === $stored || sha1($password) === $stored) { return true; } return $username === 'admin' && $password === 'admin123' && $stored === 'stc5ahuFZvdJk'; } return $username === 'admin' && $password === 'admin123'; } ensure_admin_schema(); if (isset($_GET['logout'])) { session_destroy(); header('Location: index.php'); exit; } $message = ''; $messageType = 'success'; if (isset($_POST['login'])) { if (login_ok($_POST['username'], $_POST['password'])) { $_SESSION['campus_admin'] = $_POST['username']; header('Location: index.php'); exit; } $message = 'Login i pasakte.'; $messageType = 'error'; } if (!isset($_SESSION['campus_admin'])) { ?><!DOCTYPE html> <html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Campus IEA Admin</title><link href="../css/campus-modern.css?v=2026051606" rel="stylesheet"></head> <body class="campus-admin"><div class="shell" style="max-width:420px"><div class="panel"><h1>Campus IEA Admin</h1><?php if ($message) { ?><div class="campus-admin-notice campus-admin-notice-<?php echo h($messageType); ?>"><span class="campus-admin-notice-icon" aria-hidden="true"></span><strong><?php echo h($message); ?></strong></div><?php } ?><form method="post"><label>Username</label><input name="username" required><label>Password</label><input type="password" name="password" required><p><button name="login" value="1">Login</button></p></form></div></div></body></html><?php exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { $action = $_POST['action']; if ($action === 'save_settings') { foreach ($_POST['settings'] as $key => $values) { $k = db_escape($key); $it = db_escape($values['it']); $en = db_escape($values['en']); admin_query("INSERT INTO site_settings (setting_key, value_it, value_en) VALUES ('$k', '$it', '$en') ON DUPLICATE KEY UPDATE value_it='$it', value_en='$en'"); } $message = 'Konfigurimet u ruajten.'; } if ($action === 'change_password') { $newPassword = isset($_POST['new_password']) ? $_POST['new_password'] : ''; if (strlen($newPassword) >= 8) { $hash = db_escape(password_hash($newPassword, PASSWORD_DEFAULT)); $ip = db_escape(isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''); $today = date('Y-m-d'); $exists = db_row("SELECT id FROM users WHERE username='admin' LIMIT 1"); if ($exists) { admin_query("UPDATE users SET password='$hash', lastlogin='$today' WHERE username='admin'"); } else { admin_query("INSERT INTO users (emri, username, password, email, ip, kategoria, lastlogin) VALUES ('admin', 'admin', '$hash', 'admin@campusiea.com', '$ip', 'Admin', '$today')"); } $message = 'Password admin u ndryshua.'; } else { $message = 'Password duhet te kete te pakten 8 karaktere.'; $messageType = 'error'; } } if ($action === 'save_content') { $id = (int)$_POST['id']; $titleIt = db_escape($_POST['titulli']); $titleEn = db_escape($_POST['titulli_en']); $bodyIt = db_escape($_POST['pershkrimi']); $bodyEn = db_escape($_POST['pershkrimi_en']); $category = db_escape($_POST['kategoria']); $photo = admin_upload('foto'); $photoSql = $photo !== '' ? ", foto='" . db_escape($photo) . "'" : ''; if ($id > 0) { admin_query("UPDATE permbledhje SET titulli='$titleIt', titulli_en='$titleEn', pershkrimi='$bodyIt', pershkrimi_en='$bodyEn', kategoria='$category' $photoSql WHERE id=$id"); } else { $photoInsert = db_escape($photo); admin_query("INSERT INTO permbledhje (titulli, titulli_en, pershkrimi, pershkrimi_en, foto, kategoria, data, postuesi) VALUES ('$titleIt', '$titleEn', '$bodyIt', '$bodyEn', '$photoInsert', '$category', CURDATE(), 'admin')"); } $message = 'Permbajtja u ruajt.'; } if ($action === 'delete_content') { $id = (int)$_POST['id']; admin_query("DELETE FROM permbledhje WHERE id=$id"); $message = 'Permbajtja u fshi.'; } if ($action === 'save_event') { $id = (int)$_POST['id']; $eventType = isset($_POST['event_type']) && in_array($_POST['event_type'], array('post', 'album', 'video'), true) ? $_POST['event_type'] : 'post'; $titleIt = db_escape($_POST['title_it']); $titleEn = db_escape($_POST['title_en']); $bodyIt = db_escape($_POST['description_it']); $bodyEn = db_escape($_POST['description_en']); $eventDate = trim((string)$_POST['event_date']) !== '' ? "'" . db_escape($_POST['event_date']) . "'" : "NULL"; $locationIt = db_escape($_POST['location_it']); $locationEn = db_escape($_POST['location_en']); $videoUrl = db_escape(trim((string)(isset($_POST['video_url']) ? $_POST['video_url'] : ''))); $videoCaptionIt = db_escape(trim((string)(isset($_POST['video_caption_it']) ? $_POST['video_caption_it'] : ''))); $videoCaptionEn = db_escape(trim((string)(isset($_POST['video_caption_en']) ? $_POST['video_caption_en'] : ''))); $homeFeatured = isset($_POST['home_featured']) ? 1 : 0; $homePriority = max(0, min(100, (int)(isset($_POST['home_priority']) ? $_POST['home_priority'] : 0))); $status = isset($_POST['status']) && $_POST['status'] === 'draft' ? 'draft' : 'published'; $cover = admin_upload_to('cover_image', 'images/events'); $coverSql = $cover !== '' ? ", cover_image='" . db_escape($cover) . "'" : ''; $videoFile = admin_upload_video('video_file', 'videos/events'); $videoFileSql = $videoFile !== '' ? ", video_file='" . db_escape($videoFile) . "'" : ''; if ($id > 0) { admin_query("UPDATE campus_events SET event_type='$eventType', title_it='$titleIt', title_en='$titleEn', description_it='$bodyIt', description_en='$bodyEn', video_url='$videoUrl', video_caption_it='$videoCaptionIt', video_caption_en='$videoCaptionEn', event_date=$eventDate, home_featured=$homeFeatured, home_priority=$homePriority, location_it='$locationIt', location_en='$locationEn', status='$status' $coverSql $videoFileSql WHERE id=$id"); } else { $coverInsert = $cover !== '' ? db_escape($cover) : ''; $videoFileInsert = $videoFile !== '' ? db_escape($videoFile) : ''; admin_query("INSERT INTO campus_events (event_type, title_it, title_en, description_it, description_en, cover_image, video_file, video_url, video_caption_it, video_caption_en, event_date, home_featured, home_priority, location_it, location_en, status) VALUES ('$eventType', '$titleIt', '$titleEn', '$bodyIt', '$bodyEn', '$coverInsert', '$videoFileInsert', '$videoUrl', '$videoCaptionIt', '$videoCaptionEn', $eventDate, $homeFeatured, $homePriority, '$locationIt', '$locationEn', '$status')"); $id = (int)mysqli_insert_id(site_db()); } if ($id > 0) { $newPhotos = admin_upload_many('gallery_photos', 'images/events'); $sortBase = (int)db_value("SELECT COALESCE(MAX(sort_order), 0) FROM campus_event_photos WHERE event_id=$id", 0); foreach ($newPhotos as $index => $path) { $pathSql = db_escape($path); $sort = $sortBase + $index + 1; admin_query("INSERT INTO campus_event_photos (event_id, image_path, sort_order) VALUES ($id, '$pathSql', $sort)"); } } $message = 'Eventi u ruajt.'; } if ($action === 'delete_event') { $id = (int)$_POST['id']; admin_query("DELETE FROM campus_event_photos WHERE event_id=$id"); admin_query("DELETE FROM campus_events WHERE id=$id"); $message = 'Eventi u fshi.'; } if ($action === 'delete_event_photo') { $id = (int)$_POST['id']; $eventId = (int)$_POST['event_id']; admin_query("DELETE FROM campus_event_photos WHERE id=$id"); $message = 'Foto u fshi nga albumi.'; header('Location: index.php?tab=events&edit_event=' . $eventId . '&saved=1'); exit; } if ($action === 'save_product') { $id = (int)$_POST['id']; $nameIt = db_escape($_POST['product_name']); $nameEn = db_escape($_POST['product_name_en']); $detailsIt = db_escape($_POST['details']); $detailsEn = db_escape($_POST['details_en']); $price = db_escape($_POST['price']); $category = db_escape($_POST['category']); $brand = db_escape($_POST['brand']); $qty = (int)$_POST['sasia']; $official = isset($_POST['official_distributor']) ? 1 : 0; $photo = admin_upload('product_photo'); $photoSql = $photo !== '' ? ", product_photo='" . db_escape($photo) . "'" : ''; if ($id > 0) { admin_query("UPDATE products SET product_name='$nameIt', product_name_en='$nameEn', details='$detailsIt', details_en='$detailsEn', price='$price', category='$category', brand='$brand', sasia=$qty, official_distributor=$official $photoSql WHERE id=$id"); } else { $photoInsert = db_escape($photo); admin_query("INSERT INTO products (product_name, product_name_en, price, details, details_en, category, subcategory, date_added, product_photo, pesha, sasia, official_distributor, brand) VALUES ('$nameIt', '$nameEn', '$price', '$detailsIt', '$detailsEn', '$category', '', CURDATE(), '$photoInsert', 0, $qty, $official, '$brand')"); } $message = 'Produkti u ruajt.'; } if ($action === 'delete_product') { $id = (int)$_POST['id']; admin_query("DELETE FROM products WHERE id=$id"); $message = 'Produkti u fshi.'; } if ($action === 'save_certificate') { $id = (int)$_POST['id']; $code = trim($_POST['certificate_no']); if ($code === '') { $code = 'CIEA-' . date('Ymd') . '-' . strtoupper(substr(md5(uniqid('', true)), 0, 6)); } $codeSql = db_escape($code); $student = db_escape($_POST['student_name']); $course = db_escape($_POST['course_title']); $date = db_escape($_POST['issue_date']); $language = in_array($_POST['language'], array('it', 'en'), true) ? $_POST['language'] : 'it'; $status = in_array($_POST['status'], array('valid', 'revoked', 'expired'), true) ? $_POST['status'] : 'valid'; $issuer = db_escape($_POST['issuer']); $notes = db_escape($_POST['notes']); list($pdfPath, $pdfOriginalName) = admin_upload_pdf('certificate_pdf', 'Certificate', $code); $existingPdf = isset($_POST['existing_pdf']) ? basename((string)$_POST['existing_pdf']) : ''; if ($pdfPath === '' && $existingPdf !== '' && is_file(__DIR__ . '/../Certificate/' . $existingPdf)) { $pdfPath = 'Certificate/' . $existingPdf; $pdfOriginalName = $existingPdf; } $pdfSql = ''; if ($pdfPath !== '') { $pdfPathSql = db_escape($pdfPath); $pdfOriginalSql = db_escape($pdfOriginalName); $pdfSql = ", pdf_path='$pdfPathSql', pdf_original_name='$pdfOriginalSql'"; } if ($id > 0) { admin_query("UPDATE certificates SET certificate_no='$codeSql', student_name='$student', course_title='$course', issue_date='$date', language='$language', status='$status', issuer='$issuer', notes='$notes' $pdfSql WHERE id=$id"); } else { $insertPdfPath = $pdfPath !== '' ? "'" . db_escape($pdfPath) . "'" : "NULL"; $insertPdfOriginal = $pdfOriginalName !== '' ? "'" . db_escape($pdfOriginalName) . "'" : "NULL"; admin_query("INSERT INTO certificates (certificate_no, student_name, course_title, issue_date, language, status, issuer, notes, pdf_path, pdf_original_name) VALUES ('$codeSql', '$student', '$course', '$date', '$language', '$status', '$issuer', '$notes', $insertPdfPath, $insertPdfOriginal)"); } $message = 'Certifikata u ruajt. Link: ../certificate.php?code=' . h($code); } if ($action === 'delete_certificate') { $id = (int)$_POST['id']; admin_query("DELETE FROM certificates WHERE id=$id"); $message = 'Certifikata u fshi.'; } if ($action === 'save_order') { $id = (int)$_POST['id']; $status = db_escape($_POST['status']); admin_query("UPDATE shop_orders SET status='$status' WHERE id=$id"); $message = 'Porosia u perditesua.'; } if ($action === 'save_fair_lead') { $id = (int)$_POST['id']; $status = preg_replace('/[^a-zA-Z0-9_-]+/', '', (string)$_POST['status']); if ($id > 0 && $status !== '') { admin_query("UPDATE fair_leads SET status='" . db_escape($status) . "' WHERE id=$id"); $message = 'Regjistrimi u perditesua.'; } else { $message = 'Regjistrimi nuk u perditesua.'; $messageType = 'error'; } } } $tab = isset($_GET['tab']) ? $_GET['tab'] : 'dashboard'; $tabs = array('dashboard' => 'Dashboard', 'settings' => 'Settings', 'content' => 'Content', 'events' => 'Evente', 'products' => 'Products', 'certificates' => 'Certificates', 'orders' => 'Orders', 'fair_leads' => 'Regjistrime'); $editContent = isset($_GET['edit_content']) ? db_row("SELECT * FROM permbledhje WHERE id=" . (int)$_GET['edit_content']) : null; $editEvent = isset($_GET['edit_event']) ? db_row("SELECT * FROM campus_events WHERE id=" . (int)$_GET['edit_event']) : null; $editProduct = isset($_GET['edit_product']) ? db_row("SELECT * FROM products WHERE id=" . (int)$_GET['edit_product']) : null; $editCert = isset($_GET['edit_cert']) ? db_row("SELECT * FROM certificates WHERE id=" . (int)$_GET['edit_cert']) : null; ?><!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Campus IEA Admin</title> <link href="../css/campus-modern.css?v=2026051606" rel="stylesheet"> </head> <body class="campus-admin"> <div class="shell"> <div class="admin-top"> <div><h1>Campus IEA Admin</h1><p>Panel per permbajtje, certifikata dhe shop.</p></div> <div><a class="button" href="../index.php" target="_blank">Hap faqen</a> <a class="button" href="?logout=1">Logout</a></div> </div> <nav> <?php foreach ($tabs as $key => $label) { ?><a class="<?php echo $tab === $key ? 'active' : ''; ?>" href="?tab=<?php echo h($key); ?>"><?php echo h($label); ?></a><?php } ?> </nav> <?php if ($message) { ?><div class="campus-admin-notice campus-admin-notice-<?php echo h($messageType); ?>"><span class="campus-admin-notice-icon" aria-hidden="true"></span><strong><?php echo h($message); ?></strong></div><?php } ?> <?php if ($tab === 'dashboard') { ?> <div class="campus-grid"> <div class="panel"><h2>Permbajtje</h2><p><?php echo (int)db_value("SELECT COUNT(*) FROM permbledhje", 0); ?> blloqe/faqe</p></div> <div class="panel"><h2>Evente</h2><p><?php echo (int)db_value("SELECT COUNT(*) FROM campus_events", 0); ?> postime/foto/video</p><p><?php echo (int)db_value("SELECT COUNT(*) FROM campus_events WHERE home_featured=1", 0); ?> te zgjedhura per index</p></div> <div class="panel"><h2>Produkte</h2><p><?php echo (int)db_value("SELECT COUNT(*) FROM products", 0); ?> produkte</p></div> <div class="panel"><h2>Certifikata</h2><p><?php echo (int)db_value("SELECT COUNT(*) FROM certificates", 0); ?> certifikata</p></div> <div class="panel"><h2>Porosi</h2><p><?php echo (int)db_value("SELECT COUNT(*) FROM shop_orders WHERE status='new'", 0); ?> te reja</p></div> <div class="panel"><h2>Regjistrime</h2><p><?php echo (int)db_value("SELECT COUNT(*) FROM fair_leads WHERE status='new'", 0); ?> te reja nga homepage</p></div> </div> <?php } ?> <?php if ($tab === 'settings') { $settings = db_all("SELECT * FROM site_settings ORDER BY setting_key"); ?> <form method="post" class="panel"> <input type="hidden" name="action" value="save_settings"> <h2>Konfigurime te faqes</h2> <?php foreach ($settings as $setting) { ?> <label><?php echo h($setting['setting_key']); ?> - IT</label> <textarea name="settings[<?php echo h($setting['setting_key']); ?>][it]" rows="2"><?php echo h($setting['value_it']); ?></textarea> <label><?php echo h($setting['setting_key']); ?> - EN</label> <textarea name="settings[<?php echo h($setting['setting_key']); ?>][en]" rows="2"><?php echo h($setting['value_en']); ?></textarea> <?php } ?> <p><button>Ruaj konfigurimet</button></p> </form> <form method="post" class="panel"> <input type="hidden" name="action" value="change_password"> <h2>Ndrysho password admin</h2> <label>Password i ri</label> <input type="password" name="new_password" minlength="8" required> <p><button>Ndrysho password</button></p> </form> <?php } ?> <?php if ($tab === 'content') { $contents = db_all("SELECT * FROM permbledhje ORDER BY id DESC LIMIT 80"); ?> <form method="post" enctype="multipart/form-data" class="panel"> <input type="hidden" name="action" value="save_content"> <input type="hidden" name="id" value="<?php echo h($editContent ? $editContent['id'] : 0); ?>"> <h2><?php echo $editContent ? 'Modifiko permbajtje' : 'Shto permbajtje'; ?></h2> <label>Titulli IT</label><input name="titulli" value="<?php echo h($editContent ? $editContent['titulli'] : ''); ?>" required> <label>Titulli EN</label><input name="titulli_en" value="<?php echo h($editContent && isset($editContent['titulli_en']) ? $editContent['titulli_en'] : ''); ?>"> <label>Kategoria</label><input name="kategoria" value="<?php echo h($editContent ? $editContent['kategoria'] : 'Scopri di piu'); ?>"> <label>Pershkrimi IT</label><textarea name="pershkrimi" rows="8"><?php echo h($editContent ? $editContent['pershkrimi'] : ''); ?></textarea> <label>Pershkrimi EN</label><textarea name="pershkrimi_en" rows="8"><?php echo h($editContent && isset($editContent['pershkrimi_en']) ? $editContent['pershkrimi_en'] : ''); ?></textarea> <label>Foto</label><input type="file" name="foto"> <p><button>Ruaj</button></p> </form> <div class="panel"><h2>Lista</h2><table><tr><th>ID</th><th>Titulli</th><th>Kategoria</th><th></th></tr><?php foreach ($contents as $item) { ?><tr><td><?php echo (int)$item['id']; ?></td><td><?php echo h($item['titulli']); ?></td><td><?php echo h($item['kategoria']); ?></td><td><a href="?tab=content&edit_content=<?php echo (int)$item['id']; ?>">Edit</a><form method="post" style="display:inline"><input type="hidden" name="action" value="delete_content"><input type="hidden" name="id" value="<?php echo (int)$item['id']; ?>"><button onclick="return confirm('Fshi?')">Fshi</button></form></td></tr><?php } ?></table></div> <?php } ?> <?php if ($tab === 'events') { $events = db_all("SELECT e.*, COUNT(p.id) AS photo_count FROM campus_events e LEFT JOIN campus_event_photos p ON p.event_id=e.id GROUP BY e.id ORDER BY home_featured DESC, home_priority DESC, CASE WHEN event_date IS NULL THEN 1 ELSE 0 END ASC, event_date DESC, e.id DESC LIMIT 120"); $eventPhotos = $editEvent ? db_all("SELECT * FROM campus_event_photos WHERE event_id=" . (int)$editEvent['id'] . " ORDER BY sort_order ASC, id ASC") : array(); ?> <form method="post" enctype="multipart/form-data" class="panel"> <input type="hidden" name="action" value="save_event"> <input type="hidden" name="id" value="<?php echo h($editEvent ? $editEvent['id'] : 0); ?>"> <h2><?php echo $editEvent ? 'Modifiko event / foto album / video' : 'Shto event / foto album / video'; ?></h2> <label>Tipi</label> <select name="event_type"> <option value="post" <?php echo !$editEvent || $editEvent['event_type'] === 'post' ? 'selected' : ''; ?>>Postim</option> <option value="album" <?php echo $editEvent && $editEvent['event_type'] === 'album' ? 'selected' : ''; ?>>Foto album</option> <option value="video" <?php echo $editEvent && $editEvent['event_type'] === 'video' ? 'selected' : ''; ?>>Video postim</option> </select> <label>Titulli IT</label><input name="title_it" value="<?php echo h($editEvent ? $editEvent['title_it'] : ''); ?>" required> <label>Titulli EN</label><input name="title_en" value="<?php echo h($editEvent ? $editEvent['title_en'] : ''); ?>"> <?php $eventDateValue = $editEvent && preg_match('/^[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}$/', (string)$editEvent['event_date']) ? $editEvent['event_date'] : ''; ?> <label>Data eventit (opsionale, per renditje)</label><input type="date" name="event_date" value="<?php echo h($eventDateValue); ?>"> <label>Lokacioni IT</label><input name="location_it" value="<?php echo h($editEvent ? $editEvent['location_it'] : ''); ?>"> <label>Lokacioni EN</label><input name="location_en" value="<?php echo h($editEvent ? $editEvent['location_en'] : ''); ?>"> <div class="admin-event-home-options"> <label><input type="checkbox" name="home_featured" <?php echo $editEvent && (int)$editEvent['home_featured'] === 1 ? 'checked' : ''; ?>> Shfaq ne bllokun e eventeve ne index</label> <label>Rendesia ne index (0-100)</label><input type="number" name="home_priority" min="0" max="100" value="<?php echo h($editEvent && isset($editEvent['home_priority']) ? (int)$editEvent['home_priority'] : 0); ?>"> </div> <label>Status</label> <select name="status"> <option value="published" <?php echo !$editEvent || $editEvent['status'] === 'published' ? 'selected' : ''; ?>>published</option> <option value="draft" <?php echo $editEvent && $editEvent['status'] === 'draft' ? 'selected' : ''; ?>>draft</option> </select> <label>Pershkrimi IT</label><textarea name="description_it" rows="8" required><?php echo h($editEvent ? $editEvent['description_it'] : ''); ?></textarea> <label>Pershkrimi EN</label><textarea name="description_en" rows="8"><?php echo h($editEvent ? $editEvent['description_en'] : ''); ?></textarea> <div class="admin-video-fields"> <h3>Video</h3> <p>Per postime video mund te ngarkosh file MP4/WebM/MOV ose te vendosesh link YouTube. Nese i vendos te dyja, file lokal shfaqet i pari.</p> <label>Upload video</label><input type="file" name="video_file" accept="video/mp4,video/webm,video/quicktime,video/x-m4v"> <?php if ($editEvent && trim((string)$editEvent['video_file']) !== '') { ?><p><a class="button" target="_blank" href="../<?php echo h($editEvent['video_file']); ?>">Hap videon aktuale</a></p><?php } ?> <label>Link video / YouTube</label><input name="video_url" value="<?php echo h($editEvent && isset($editEvent['video_url']) ? $editEvent['video_url'] : ''); ?>" placeholder="https://www.youtube.com/watch?v=..."> <label>Pershkrim i shkurter video IT</label><input name="video_caption_it" value="<?php echo h($editEvent && isset($editEvent['video_caption_it']) ? $editEvent['video_caption_it'] : ''); ?>"> <label>Pershkrim i shkurter video EN</label><input name="video_caption_en" value="<?php echo h($editEvent && isset($editEvent['video_caption_en']) ? $editEvent['video_caption_en'] : ''); ?>"> </div> <label>Foto kryesore</label><input type="file" name="cover_image" accept="image/*"> <?php if ($editEvent && trim((string)$editEvent['cover_image']) !== '') { ?><p><img src="../<?php echo h($editEvent['cover_image']); ?>" alt="" style="max-width:180px;height:auto"></p><?php } ?> <label>Shto foto ne album</label><input type="file" name="gallery_photos[]" accept="image/*" multiple> <p><button>Ruaj eventin</button> <?php if ($editEvent) { ?><a class="button" target="_blank" href="../event.php?id=<?php echo (int)$editEvent['id']; ?>">Hap ne faqe</a><?php } ?></p> </form> <?php if ($editEvent && !empty($eventPhotos)) { ?> <div class="panel"> <h2>Fotot e albumit</h2> <div class="admin-event-photo-grid"> <?php foreach ($eventPhotos as $photo) { ?> <div> <img src="../<?php echo h($photo['image_path']); ?>" alt=""> <form method="post"> <input type="hidden" name="action" value="delete_event_photo"> <input type="hidden" name="id" value="<?php echo (int)$photo['id']; ?>"> <input type="hidden" name="event_id" value="<?php echo (int)$editEvent['id']; ?>"> <button onclick="return confirm('Fshi foton?')">Fshi foto</button> </form> </div> <?php } ?> </div> </div> <?php } ?> <div class="panel"> <h2>Evente, foto albume dhe video</h2> <table> <tr><th>ID</th><th>Titulli</th><th>Tipi</th><th>Data</th><th>Index</th><th>Rendesi</th><th>Media</th><th>Status</th><th></th></tr> <?php foreach ($events as $event) { ?> <tr> <td><?php echo (int)$event['id']; ?></td> <td><?php echo h($event['title_it']); ?></td> <td><?php echo h($event['event_type']); ?></td> <td><?php echo h($event['event_date']); ?></td> <td><?php echo (int)$event['home_featured'] === 1 ? 'Po' : 'Jo'; ?></td> <td><?php echo (int)$event['home_priority']; ?></td> <td><?php echo (int)$event['photo_count']; ?> foto<?php echo trim((string)$event['video_file']) !== '' || trim((string)$event['video_url']) !== '' ? ' / video' : ''; ?></td> <td><?php echo h($event['status']); ?></td> <td><a target="_blank" href="../event.php?id=<?php echo (int)$event['id']; ?>">Hap</a> <a href="?tab=events&edit_event=<?php echo (int)$event['id']; ?>">Edit</a><form method="post" style="display:inline"><input type="hidden" name="action" value="delete_event"><input type="hidden" name="id" value="<?php echo (int)$event['id']; ?>"><button onclick="return confirm('Fshi eventin?')">Fshi</button></form></td> </tr> <?php } ?> </table> </div> <?php } ?> <?php if ($tab === 'products') { $products = db_all("SELECT * FROM products ORDER BY id DESC LIMIT 80"); ?> <form method="post" enctype="multipart/form-data" class="panel"> <input type="hidden" name="action" value="save_product"> <input type="hidden" name="id" value="<?php echo h($editProduct ? $editProduct['id'] : 0); ?>"> <h2><?php echo $editProduct ? 'Modifiko produkt' : 'Shto produkt'; ?></h2> <label>Emri IT</label><input name="product_name" value="<?php echo h($editProduct ? $editProduct['product_name'] : ''); ?>" required> <label>Emri EN</label><input name="product_name_en" value="<?php echo h($editProduct && isset($editProduct['product_name_en']) ? $editProduct['product_name_en'] : ''); ?>"> <label>Cmimi</label><input name="price" value="<?php echo h($editProduct ? $editProduct['price'] : ''); ?>"> <label>Kategoria</label><input name="category" value="<?php echo h($editProduct ? $editProduct['category'] : 'Official distributor'); ?>"> <label>Brand</label><input name="brand" value="<?php echo h($editProduct && isset($editProduct['brand']) ? $editProduct['brand'] : ''); ?>"> <label>Sasia</label><input type="number" name="sasia" value="<?php echo h($editProduct ? $editProduct['sasia'] : 1); ?>"> <label><input type="checkbox" name="official_distributor" <?php echo !$editProduct || (int)$editProduct['official_distributor'] === 1 ? 'checked' : ''; ?>> Produkt distributor zyrtar</label> <label>Detaje IT</label><textarea name="details" rows="6"><?php echo h($editProduct ? $editProduct['details'] : ''); ?></textarea> <label>Detaje EN</label><textarea name="details_en" rows="6"><?php echo h($editProduct && isset($editProduct['details_en']) ? $editProduct['details_en'] : ''); ?></textarea> <label>Foto produkti</label><input type="file" name="product_photo"> <p><button>Ruaj produktin</button></p> </form> <div class="panel"><h2>Produkte</h2><table><tr><th>ID</th><th>Produkt</th><th>Cmim</th><th>Official</th><th></th></tr><?php foreach ($products as $product) { ?><tr><td><?php echo (int)$product['id']; ?></td><td><?php echo h($product['product_name']); ?></td><td><?php echo h($product['price']); ?></td><td><?php echo isset($product['official_distributor']) && $product['official_distributor'] ? 'Po' : 'Jo'; ?></td><td><a href="?tab=products&edit_product=<?php echo (int)$product['id']; ?>">Edit</a><form method="post" style="display:inline"><input type="hidden" name="action" value="delete_product"><input type="hidden" name="id" value="<?php echo (int)$product['id']; ?>"><button onclick="return confirm('Fshi?')">Fshi</button></form></td></tr><?php } ?></table></div> <?php } ?> <?php if ($tab === 'certificates') { $certs = db_all("SELECT * FROM certificates ORDER BY id DESC LIMIT 100"); $existingPdfs = admin_existing_certificate_pdfs(); ?> <form method="post" enctype="multipart/form-data" class="panel"> <input type="hidden" name="action" value="save_certificate"> <input type="hidden" name="id" value="<?php echo h($editCert ? $editCert['id'] : 0); ?>"> <h2><?php echo $editCert ? 'Modifiko certifikate' : 'Shto certifikate / PDF ekzistues'; ?></h2> <label>Kodi</label><input name="certificate_no" value="<?php echo h($editCert ? $editCert['certificate_no'] : ''); ?>" placeholder="Lere bosh per auto"> <label>Emri i personit</label><input name="student_name" value="<?php echo h($editCert ? $editCert['student_name'] : ''); ?>" required> <label>Kursi/Programi</label><input name="course_title" value="<?php echo h($editCert ? $editCert['course_title'] : ''); ?>" required> <label>Data</label><input type="date" name="issue_date" value="<?php echo h($editCert ? $editCert['issue_date'] : date('Y-m-d')); ?>"> <label>Gjuha</label><select name="language"><option value="it" <?php echo $editCert && $editCert['language'] === 'it' ? 'selected' : ''; ?>>Italiano</option><option value="en" <?php echo $editCert && $editCert['language'] === 'en' ? 'selected' : ''; ?>>English</option></select> <label>Status</label><select name="status"><option value="valid" <?php echo !$editCert || $editCert['status'] === 'valid' ? 'selected' : ''; ?>>valid</option><option value="revoked" <?php echo $editCert && $editCert['status'] === 'revoked' ? 'selected' : ''; ?>>revoked</option><option value="expired" <?php echo $editCert && $editCert['status'] === 'expired' ? 'selected' : ''; ?>>expired</option></select> <label>Leshuesi</label><input name="issuer" value="<?php echo h($editCert ? $editCert['issuer'] : 'Campus IEA'); ?>"> <label>PDF ekzistues nga folderi Certificate</label> <select name="existing_pdf"> <option value="">Mos zgjidh PDF ekzistues</option> <?php foreach ($existingPdfs as $pdf) { ?> <option value="<?php echo h($pdf); ?>" <?php echo $editCert && !empty($editCert['pdf_path']) && basename($editCert['pdf_path']) === $pdf ? 'selected' : ''; ?>><?php echo h($pdf); ?></option> <?php } ?> </select> <label>Ngarko PDF te ri</label><input type="file" name="certificate_pdf" accept="application/pdf,.pdf"> <?php if ($editCert && !empty($editCert['pdf_path'])) { ?> <p>PDF aktual: <a target="_blank" href="../<?php echo h($editCert['pdf_path']); ?>"><?php echo h($editCert['pdf_original_name'] ? $editCert['pdf_original_name'] : basename($editCert['pdf_path'])); ?></a></p> <?php } ?> <label>Shenime</label><textarea name="notes" rows="4"><?php echo h($editCert ? $editCert['notes'] : ''); ?></textarea> <p><button>Ruaj certifikaten</button></p> </form> <div class="panel"><h2>Certifikata</h2><table><tr><th>Kodi</th><th>Personi</th><th>Kursi</th><th>Status</th><th>PDF</th><th></th></tr><?php foreach ($certs as $cert) { ?><tr><td><?php echo h($cert['certificate_no']); ?></td><td><?php echo h($cert['student_name']); ?></td><td><?php echo h($cert['course_title']); ?></td><td><?php echo h($cert['status']); ?></td><td><?php echo !empty($cert['pdf_path']) ? '<a target="_blank" href="../' . h($cert['pdf_path']) . '">PDF</a>' : '-'; ?></td><td><a target="_blank" href="../verify-certificate.php?code=<?php echo urlencode($cert['certificate_no']); ?>">Verifiko</a> <a target="_blank" href="../certificate.php?code=<?php echo urlencode($cert['certificate_no']); ?>">Hap</a> <a href="?tab=certificates&edit_cert=<?php echo (int)$cert['id']; ?>">Edit</a><form method="post" style="display:inline"><input type="hidden" name="action" value="delete_certificate"><input type="hidden" name="id" value="<?php echo (int)$cert['id']; ?>"><button onclick="return confirm('Fshi?')">Fshi</button></form></td></tr><?php } ?></table></div> <?php } ?> <?php if ($tab === 'orders') { $orders = db_all("SELECT o.*, p.product_name FROM shop_orders o LEFT JOIN products p ON p.id=o.product_id ORDER BY o.id DESC LIMIT 100"); ?> <div class="panel"><h2>Porosite / kerkesat nga shop</h2><table><tr><th>Data</th><th>Produkt</th><th>Klient</th><th>Kontakt</th><th>Status</th></tr><?php foreach ($orders as $order) { ?><tr><td><?php echo h($order['created_at']); ?></td><td><?php echo h($order['product_name']); ?> x <?php echo (int)$order['quantity']; ?></td><td><?php echo h($order['customer_name']); ?></td><td><?php echo h($order['customer_email']); ?><br><?php echo h($order['customer_phone']); ?></td><td><form method="post"><input type="hidden" name="action" value="save_order"><input type="hidden" name="id" value="<?php echo (int)$order['id']; ?>"><select name="status"><option <?php echo $order['status'] === 'new' ? 'selected' : ''; ?>>new</option><option <?php echo $order['status'] === 'contacted' ? 'selected' : ''; ?>>contacted</option><option <?php echo $order['status'] === 'closed' ? 'selected' : ''; ?>>closed</option></select><button>Ruaj</button></form></td></tr><?php } ?></table></div> <?php } ?> <?php if ($tab === 'fair_leads') { $leads = db_all("SELECT * FROM fair_leads ORDER BY created_at DESC LIMIT 200"); ?> <div class="panel"> <h2>Regjistrime nga faqja kryesore</h2> <p>Personat qe plotesojne formen e panairit/ofertave ne homepage shfaqen ketu.</p> <table> <tr><th>Data</th><th>Emer</th><th>Telefon</th><th>Gjuha</th><th>Status</th></tr> <?php foreach ($leads as $lead) { ?> <tr> <td><?php echo h($lead['created_at']); ?></td> <td><?php echo h($lead['first_name'] . ' ' . $lead['last_name']); ?></td> <td><a href="tel:<?php echo h($lead['phone']); ?>"><?php echo h($lead['phone']); ?></a></td> <td><?php echo h(strtoupper($lead['lang'])); ?></td> <td> <form method="post"> <input type="hidden" name="action" value="save_fair_lead"> <input type="hidden" name="id" value="<?php echo (int)$lead['id']; ?>"> <select name="status"> <option value="new" <?php echo $lead['status'] === 'new' ? 'selected' : ''; ?>>new</option> <option value="contacted" <?php echo $lead['status'] === 'contacted' ? 'selected' : ''; ?>>contacted</option> <option value="interested" <?php echo $lead['status'] === 'interested' ? 'selected' : ''; ?>>interested</option> <option value="closed" <?php echo $lead['status'] === 'closed' ? 'selected' : ''; ?>>closed</option> </select> <button>Ruaj</button> </form> </td> </tr> <?php } ?> </table> </div> <?php } ?> </div> </body> </html>
💾 Simpan File
Batal
⬅ Naik ke CampusIEA
1 item
Nama
Tipe
Ukuran
Diubah
Aksi
🐘
index.php
php
47.3 KB
2026-05-17 03:01
✏️ Edit
👁️ View
🗑 Hapus