-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.php
47 lines (39 loc) · 1.09 KB
/
client.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
<?php
$namafile = "abc.pdf";
$kunci="1"; //bisa generate trus disimpen didatabase diperbarui dalam bbrp kurun waktu
$tokenku = hash('ripemd160', $namafile.$kunci ); // yang gampang dihash sama nama file
/*
echo $tokenku;
exit();*/
echo $tokenku.PHP_EOL;
$source = "http://localhost:81/server.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('token' => $tokenku,'file'=>$namafile))
);
$data = curl_exec ($ch);
$error = curl_error($ch);
//echo curl_errno($ch);
if($error)
{
echo "$error";
exit();
}
$info = curl_getinfo($ch);
if (empty($info['http_code'])) {
die("No HTTP code was returned");
} else {
if($info['http_code']==404){
echo PHP_EOL.$info['http_code'];
exit();
}
}
curl_close ($ch);
$namabaru = date('ymdhis').$namafile;
$destination = "./".$namabaru;
file_put_contents($destination, $data);
?>