ok
Direktori : /proc/self/root/home2/selectio/www/thedentalpark.com/admin/api/ |
Current File : //proc/self/root/home2/selectio/www/thedentalpark.com/admin/api/delete.php |
<?php include"../config/config.php"; // Banner Delete if($_POST['type']=="permanant_delete"){ $table_name = $_POST['table_name']; $deleted_id = $_POST['delete_id'] ; $total_id = count($deleted_id); $result = 0; for($delete_id=0;$delete_id<$total_id; $delete_id++){ $ids = $_POST['delete_id'][$delete_id]; $deleted_image = $pdo->prepare('SELECT * FROM tbl_pdf WHERE id='.$ids); $deleted_image->execute(); $query = $deleted_image->fetchAll(PDO::FETCH_ASSOC); $image = $query[0]['file']; if($query>0){ $result = 1; $statement = $pdo->prepare('DELETE FROM '.$table_name.' WHERE id='.$ids); $result=$statement->execute(); if($result==1){ unlink('../../'.$image); } } } if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="restore"){ $id=$_POST['delete_id']; $table_name=$_POST['table_name']; $deleted_image = $pdo->prepare('SELECT * FROM tbl_pdf WHERE id='.$id); $deleted_image->execute(); $query = $deleted_image->fetchAll(PDO::FETCH_ASSOC); $image=$query[0]['file']; $remove = 'naac/upload/trash/'; $image_name = str_replace($remove, '', $image); $source='../../'.$image; $destination = '../../naac/upload/'.$image_name; $path_store = 'naac/upload/'.$image_name; // Use the rename function to move the file if (rename($source, $destination)) { $image_upt = $pdo->prepare("UPDATE ".$table_name." SET delete_status=?,file=? WHERE id=?"); $result=$image_upt->execute([1,$path_store,$id]); } else { $message='Failed..'; } if($result==1) { // unlink($image); $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="delete_gallery"){ $id=$_POST['delete_id']; $image=$_POST['image']; $table_name = $_POST['table_name']; $statement = $pdo->prepare('DELETE FROM '.$table_name.' WHERE id='.$id); $result=$statement->execute(); if($result==1) { unlink($image); $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="multi_delete"){ $table_name = $_POST['table_name']; $deleted_id = $_POST['delete_id'] ; $total_id = count($deleted_id); for($delete_id=0;$delete_id<$total_id; $delete_id++){ $ids = $_POST['delete_id'][$delete_id]; // $statement = $pdo->prepare('DELETE FROM '.$table_name.' WHERE id='.$ids); // $result=$statement->execute(); $statement = $pdo->prepare("UPDATE ".$table_name." SET delete_status=0 WHERE id=$ids"); $result=$statement->execute(); // Image delete from path and DB start here if($result){ $deleted_image = $pdo->prepare('SELECT * FROM tbl_pdf WHERE id='.$ids); $deleted_image->execute(); $query = $deleted_image->fetchAll(PDO::FETCH_ASSOC); $image = $query[0]['file']; $remove = 'naac/upload/'; $image_name = str_replace($remove, '', $image); $source= '../../'.$image; $destination = '../../naac/upload/trash/'.$image_name; $path_store ='naac/upload/trash/'.$image_name; // Use the rename function to move the file if (rename($source, $destination)) { $image_upt = $pdo->prepare("UPDATE ".$table_name." SET file=? WHERE id=?"); $result=$image_upt->execute([$path_store,$ids]); } else { $message='Failed..'; } } // Image delete from path and DB end here } if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="hard_delete_banner"){ $id=$_POST['delete_id']; $statement = $pdo->prepare("delete from ".$_POST['table_name']." WHERE id=$id"); $result=$statement->execute(); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="events_delete"){ $id=$_POST['delete_id']; $statement = $pdo->prepare("delete from tbl_event WHERE id=$id"); $result=$statement->execute(); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="dynamic_in_active"){ $statement = $pdo->prepare("UPDATE ".$_POST['table']." SET status=? WHERE id=?"); $result=$statement->execute(array(0,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="dynamic_active"){ $statement = $pdo->prepare("UPDATE ".$_POST['table']." SET status=? WHERE id=?"); $result=$statement->execute(array(1,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="desgination_delete"){ $statement = $pdo->prepare("UPDATE tbl_desgination SET status=? WHERE id=?"); $result=$statement->execute(array(0,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="permission_delete"){ $statement = $pdo->prepare("UPDATE tbl_permision_request SET status=? WHERE id=?"); $result=$statement->execute(array(0,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="role_delete"){ $statement = $pdo->prepare("UPDATE tbl_role SET status=? WHERE id=?"); $result=$statement->execute(array(0,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="user_delete"){ $statement = $pdo->prepare("UPDATE tbl_user SET status=? WHERE id=?"); $result=$statement->execute(array(0,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="location_delete"){ $statement = $pdo->prepare("UPDATE tbl_exp_location SET status=? WHERE id=?"); $result=$statement->execute(array(0,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } if($_POST['type']=="category_delete"){ $statement = $pdo->prepare("UPDATE tbl_category SET status=? WHERE id=?"); $result=$statement->execute(array(0,$_POST['delete_id'])); if($result==1) { $message='Success..'; $error='1'; } else { $message='Failed..'; $error='0'; } $datas[] = array('message' => $message, 'error' => $error); echo $message; } ?>