1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
<?php include 'config.php';
// Check if the user is logged in
if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1')) { header("Location: login.php"); exit; } require("configure.php");
$index = $_POST["index"]; $parentid = $_POST["parentid"]; $companyid = $_POST["companyid"]; $nowdate = date("Y-m-d H:i:s"); //print_r($_POST); //exit;
//Get Category function function getAllfolderid($folderid){ $rtnString = ""; $sql = "SELECT folderid FROM file_folder WHERE parentid=:parentid"; $sth = Db::getDbh()->prepare($sql); $sth->execute(array(":parentid" => $folderid)); if( $error = $sth->getError(array(":parentid" => $folderid)) ){ var_dump($error); } $folder_count = $sth->rowCount(); if ($folder_count > 0){ while($row = $sth->fetch(PDO::FETCH_ASSOC)){ $rtnString .= $row{'folderid'} .",". getAllfolderid($row{'folderid'}); } } return $rtnString; }
$folderid = $_POST["folderid"]; if (is_array($folderid)){ foreach ($folderid as $x => $v) { $tfolderid = $folderid[$x]; //Delete Folder File & DB $sql = "select * from file_content Where folderid=:folderid"; $sth = Db::getDbh()->prepare($sql); $sth->execute(array(":folderid" => $tfolderid)); if( $error = $sth->getError(array(":folderid" => $tfolderid)) ){ var_dump($error); } while ($row = $sth->fetch(PDO::FETCH_ASSOC)){ //Move File if($row{'filename'}){ $source_path = "../file_manager/file/".$row{'filename'}; $move_check = rename($source_path,"../file_manager/deleted_file/".date("Y-m-d_H-i-s")."_".$row{'filename'}); if ($move_check === false){ if (file_exists($source_path)) { die ("Could not Move the file to the path"); } } } //Soft Delete File Content $sql = "update file_content set status='0', deleted='1', lastupby=:lastupby, lastupdate=:lastupdate where fileid=:fileid"; $sth = Db::getDbh()->prepare($sql); $sql_param = array(); $sql_param[':lastupby'] = $_SESSION['loginid']; $sql_param[':lastupdate'] = $nowdate; $sql_param[':fileid'] = $row{'fileid'}; $sth->execute($sql_param); if( $error = $sth->getError($sql_param) ){ var_dump($error); } } //Soft Delete File Content $sql = "update file_folder set status='0', deleted='1', lastupby=:lastupby, lastupdate=:lastupdate where folderid in (".substr($tfolderid.",".getAllfolderid($tfolderid),0, -1).")"; $sth = Db::getDbh()->prepare($sql); $sql_param = array(); $sql_param[':lastupby'] = $_SESSION['loginid']; $sql_param[':lastupdate'] = $nowdate; $sth->execute($sql_param); if( $error = $sth->getError($sql_param) ){ var_dump($error); } } }
$fileid = $_POST["fileid"]; if (is_array($fileid)){ foreach ($fileid as $x => $v) { $tfileid = $fileid[$x]; //Delete File & DB //Move File $sql = "select * from file_content Where fileid='$tfileid'"; $sth = Db::getDbh()->prepare($sql); $sth->execute(array(":fileid" => $tfileid)); if( $error = $sth->getError(array(":fileid" => $tfileid)) ){ var_dump($error); } $row = $sth->fetch(PDO::FETCH_ASSOC); if($row{'filename'}){ $source_path = "../file_manager/file/".$row{'filename'}; $move_check = rename($source_path,"../file_manager/deleted_file/".date("Y-m-d_H-i-s")."_".$row{'filename'}); if ($move_check === false){ if (file_exists($source_path)) { //die ("Could not Move the file to the path"); } } } //Soft Delete File Content $sql = "update file_content set status='0', deleted='1', lastupby=:lastupby, lastupdate=:lastupdate where fileid=:fileid"; $sth = Db::getDbh()->prepare($sql); $sql_param = array(); $sql_param[':lastupby'] = $_SESSION['loginid']; $sql_param[':lastupdate'] = $nowdate; $sql_param[':fileid'] = $row{'fileid'}; $sth->execute($sql_param); if( $error = $sth->getError($sql_param) ){ var_dump($error); } } }
if(!is_array($fileid) && !is_array($folderid)){ echo"<script language='javascript'> alert('Please Select A File.'); history.back(); </script>"; exit; }
header("Location: index.php?index=$index&companyid=$companyid&pid=$parentid"); ?>
|