HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/content-sp/work-sp/nqb_user_add_remove_access.php
<?php 
include_once('config.php');
session_start();

$curDateTime = date('Y-m-d H:i:s');

if (!empty($_SESSION['editor'])) {
    $editorArray = json_decode($_SESSION['editor']);
    $editor_id = $editorArray->eId;
}

$SP_TEAM_ACCESS = 'csp_team_user_access';

$typ = $_REQUEST["typ"];
$work_id = $_REQUEST["work_id"];
$edtr = $_REQUEST["editor_id"];

$status=0;
$message = "--";

if($typ!='' && $work_id!='' && $edtr!=''){
	
	if($typ=='addA'){
		$getExistData = $conn->query("select work_id from $SP_TEAM_ACCESS where editor_id='$edtr' and work_id='$work_id'");
		$exst = $getExistData->fetch_assoc();
		if($exst['work_id']!=''){
			$status=1;
			$message = "Success : Already exist";
		} else {
			$conn->query("insert into $SP_TEAM_ACCESS set editor_id ='$edtr', team_id='3', work_id='$work_id', status='1', add_by='$editor_id', added_date='$curDateTime'");
			$status=1;
			$message = "Success : Updated";
		}
	} else if($typ=='rmA'){
		$getExistDataR = $conn->query("select work_id from $SP_TEAM_ACCESS where editor_id='$edtr' and work_id='$work_id'");
		$exstR = $getExistDataR->fetch_assoc();
		if($exstR['work_id']!=''){
			$conn->query("delete from $SP_TEAM_ACCESS where editor_id='$edtr' and work_id='$work_id' ");
			$status=1;
			$message = "Success : Updated";
		} else {
			$status=1;
			$message = "Success : Already removed";
		}
	}
	
} else {
	$status=0;
	$message = "Error : Network error try again!";
}

$planArray = array();
$plans["status"] = $status;
$plans["message"] = $message;
$planArray[]=$plans;

echo json_encode($planArray);

?>