Mini Shell

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

<?php
include("../config.php");
$conn = dbconnect();
error_reporting(0);
session_start(); 
$admin_id = $_SESSION['admin_id'];
date_default_timezone_set('Asia/Kolkata'); 
$today = date( 'Y-m-d H:i:s');
$user_id = $_POST['user_id'];
$type = $_POST['type'];

 if($type== 'add'){
$course_name = mysqli_real_escape_string($conn,$_POST['course_name']);
$subject = mysqli_real_escape_string($conn,$_POST['subject']);
$content = mysqli_real_escape_string($conn,$_POST['content']);
$img = $_FILES['files']['name'];
$pdf_link = implode(",", $img);

$url_query  = "SELECT * FROM tb1_url WHERE url_title='notes'";
$res_url = mysqli_query($conn,$url_query);
$fetch_url = mysqli_fetch_object($res_url);
$url_path=$fetch_url->url_path;

// File upload configuration 
    $targetDir = '../../'.$url_path; 
    $allowTypes = array('jpg','png','jpeg','gif','pdf','PDF','txt','zip'); 
     
    $statusMsg = $errorMsg = $insertValuesSQL = $errorUpload = $errorUploadType = ''; 
    $fileNames = array_filter($_FILES['files']['name']); 
    if(!empty($fileNames)){ 
        foreach($_FILES['files']['name'] as $key=>$val){ 
            // File upload path 
            $fileName = basename($_FILES['files']['name'][$key]); 
            $targetFilePath = $targetDir . $fileName; 
             
            // Check whether file type is valid 
            $fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION); 
            if(in_array($fileType, $allowTypes)){ 
                // Upload file to server 
                if(move_uploaded_file($_FILES["files"]["tmp_name"][$key], $targetFilePath)){ 
                   
        } 
    }
        

}
}

$sql = "INSERT INTO tb1_notes(course_name,subject,content,file,status,crm_id,updated_log,created_log) VALUES ('$course_name','$subject','$content','$pdf_link','0','$admin_id','$today','$today')";
$content_res = mysqli_query($conn, $sql); 
$code = 'done';
}

else if($type== 'active')
{
$document_id = $_POST['document_id'];   

$sql = "UPDATE tb1_notes SET status='1',crm_id='$admin_id',updated_log='$today' WHERE notes_id='$document_id'";
$content_res = mysqli_query($conn, $sql); 
$code = 'done';

}
else if($type== 'inactive')
{
$document_id = $_POST['document_id'];   

$sql = "UPDATE tb1_notes SET status='0',crm_id='$admin_id',updated_log='$today' WHERE notes_id='$document_id'";
$content_res = mysqli_query($conn, $sql); 
$code = 'done';

}

echo $data = json_encode($code);
?>

Zerion Mini Shell 1.0