Mini Shell

Direktori : /home2/aravindar/public_html/admin/ajax/
Upload File :
Current File : /home2/aravindar/public_html/admin/ajax/testmonial_action.php

<?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']);
    if (isset($_FILES['video']) && $_FILES['video']['error'] === UPLOAD_ERR_OK) {
        $file = $_FILES['video'];
        $uploadDir = '../dynamic_image/testimonial/'; // 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_testimonial` (`id`, `name`, `description`, `image`, `status`, `crm_id`, `created_log`, `updated_log`) VALUES (NULL, '$title', '$description', '$fileName', '1', '$admin_id', 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