Mini Shell
<?php
include("../config.php");
$conn = dbconnect();
error_reporting(0);
date_default_timezone_set('Asia/Kolkata');
session_start();
$admin_id = $_SESSION['admin_id'];
$today = date('Y-m-d H:i:s');
$type = $_POST['type'];
if ($type == 'active') {
$event_id = $_POST['news_id'];
$sql = "UPDATE tb1_event SET status=1,crm_id='$admin_id',updated_log='$today' WHERE event_id='$event_id'";
$content_res = mysqli_query($conn, $sql);
$code = 'done';
} else if ($type == 'inactive') {
$event_id = $_POST['news_id'];
$sql = "UPDATE tb1_event SET status=0,crm_id='$admin_id',updated_log='$today' WHERE event_id='$event_id'";
$content_res = mysqli_query($conn, $sql);
$code = 'done';
} else if ($type == 'delete') {
$event_id = $_POST['news_id'];
$sql = "UPDATE tb1_event SET delete_flag=1,crm_id='$admin_id',updated_log='$today' WHERE event_id='$event_id'";
$content_res = mysqli_query($conn, $sql);
$code = 'done';
} else if ($type == 'update') {
$title = mysqli_real_escape_string($conn, $_POST['title']);
$description = mysqli_real_escape_string($conn, $_POST['description']);
$event_date = mysqli_real_escape_string($conn, $_POST['event_date']);
$event_place = mysqli_real_escape_string($conn, $_POST['event_place']);
$event_time = mysqli_real_escape_string($conn, $_POST['event_time']);
if (isset($_FILES['video']) && $_FILES['video']['error'] === UPLOAD_ERR_OK) {
$file = $_FILES['video'];
$uploadDir = '../dynamic_image/events/'; // Directory to save the uploaded video
// Validate file type (allow only video files)
$allowedTypes = ['image/jpeg', 'image/png'];
if (!in_array($file['type'], $allowedTypes)) {
echo json_encode(['status' => '401', 'message' => 'Invalid file type.']);
exit;
}
// Remove spaces from the file name and add a timestamp
$originalFileName = $file['name'];
$fileExtension = pathinfo($originalFileName, PATHINFO_EXTENSION);
$fileName = uniqid() . '-' . time() . '.' . $fileExtension;
$filePath = $uploadDir . $fileName;
// Move the uploaded file to the desired directory
if (move_uploaded_file($file['tmp_name'], $filePath)) {
$sql = "INSERT INTO `tb1_event` (`event_id`, `title`, `image`, `event_content`, `event_date`, `event_time`, `event_place`, `status`, `crm_id`, `delete_flag`, `updated_log`, `created_log`) VALUES (NULL, '$title', '$fileName', '$description', '$event_date', '$event_time', '$event_place', '1', '$admin_id', '0', current_timestamp(), current_timestamp());";
//echo $sql;
$content_res = mysqli_query($conn, $sql);
$code = 'done';
} else {
echo json_encode(['status' => '500', 'message' => 'Failed to move uploaded file.']);
}
} else {
echo json_encode(['status' => '500', 'message' => 'No file uploaded or file upload error.']);
}
}
echo $data = json_encode($code);
Zerion Mini Shell 1.0