/
replication_Christ.php
87 lines (58 loc) · 1.39 KB
/
replication_Christ.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
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
<?php
//Team name to be replicated//
$Username=$_COOKIE["Username"];
$target_path = '../project/'.$Username.'/';
// echo $target_path;
// echo "<br>";
if (is_dir($target_path)) {
$files1 = scandir($target_path);
// print_r($files1);
}
for ($i=0; $i<sizeof($files1); $i++){
if(($files1[$i]!='.') && ($files1[$i]!='..')){
// echo "<strong>Image".$i."</strong><br>";
// echo $files1[$i];
// echo "<br>";
$target_path_feed=$target_path.$files1[$i];
// echo "<br>";
replicateFile($target_path_feed,$Username);
}
}
if($flag==1)
{
echo "Replication Success";
}
else
{
echo "Replication Failure";
}
// // replicate.php takes $path -> Complete path in the server after saving in server
// // $team->username which would be the file to be copied
function replicateFile($path,$team)
{
$target_url = 'http://christinajuliet.com/receiveFile.php';
$file_name_with_full_path = realpath($path);
$post = array('teamname'=>$team,'file_contents'=>'@'.$file_name_with_full_path);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$result=curl_exec ($ch);
curl_getinfo($ch);
curl_errno($ch);
curl_error($ch);
curl_close ($ch);
$result;
if($result)
{
$flag=1;
// echo "File sent";
}
else
{
$flag=0;
// echo "File not sent";
}
}
?>