-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodify_file.php
32 lines (26 loc) · 974 Bytes
/
modify_file.php
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
<?php
include_once 'connection.php';
session_start();
$_SESSION['sid'];
$studentid = $_SESSION['sid'];
$dir = $_POST['file'];
$new_file_name=$_POST['rename'];
list($part1, $part2) = explode('/', $dir);
$path='project_folders/'.$studentid.'/'.$dir;
$new_file_name1=$new_file_name.'.c';
$new_file='project_folders/'.$studentid.'/'.$part1.'/'.$new_file_name1;
//echo $new_file;
if(file_exists($path)===TRUE)
{
$fsrc = fopen($path,'r');
$fdest = fopen($new_file,'w+');
$len = stream_copy_to_stream($fsrc,$fdest);
fclose($fsrc);
fclose($fdest);
unlink($path);
mysqli_query($db_con,"update program set pname='$new_file_name1' where fname='$part1' and sid='$studentid' and pname='$part2'");
mysqli_query($db_con,"update program set ppath='$new_file' where pname='$new_file_name1' ");
mysqli_query($db_con,"update suggestion set ppath='$new_file' where ppath='$path' ");
header('Location:coding.php');
}
?>