-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.php
More file actions
71 lines (54 loc) · 2.11 KB
/
Copy pathsave.php
File metadata and controls
71 lines (54 loc) · 2.11 KB
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
<?php
//echo "test <br>";
require_once ("hidden/escape.php");
$n = $_REQUEST["n"]; //security key
$fp = fopen('/var/www/html/text_image_generator/test.txt', 'w');
fwrite($fp, "https://167.99.146.165/text_image_generator/savedimages/image".$n.".png");
fclose($fp);
//if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
//{
// Get the data
//$imageData=$_POST['image'];
//$imageData=$GLOBALS['HTTP_RAW_POST_DATA'];
$imageData=file_get_contents('php://input');
//$imageData=$n;
$n = escape($n);
$imageData = escape($imageData);
if ($n === FALSE || $imageData === FALSE) {
$fp = fopen('/var/www/html/text_image_generator/test.txt', 'w');
fwrite($fp, $n." ".$imageData." Escape Attack");
fclose($fp);
die();
}
if ($n === '' || $imageData === '') {
$fp = fopen('/var/www/html/text_image_generator/test.txt', 'w');
fwrite($fp, $n." ".$imageData." Access Attempt");
fclose($fp);
die();
}
// Remove the headers (data:,) part.
// A real application should use them according to needs such as to check image type
// $filteredData=substr($imageData, strpos($imageData, ",")+1);
/*
$fp = fopen('/var/www/html/text_image_generator/test.txt', 'w');
//fwrite($fp, file_get_contents('php://input')); //var_dump($_POST)
fwrite($fp, gettype(file_get_contents('php://input')));
fclose($fp);
*/
// Need to decode before saving since the data we received is already base64 encoded
// $unencodedData=base64_decode($filteredData);
$unencodedData=base64_decode($imageData);
/*
$fp = fopen('/var/www/html/text_image_generator/test.txt', 'w');
fwrite($fp, $unencodedData);
fclose($fp);
*/
//echo "unencodedData".$unencodedData;
// Save file. This example uses a hard coded filename for testing,
// but a real application can specify filename in POST variable
// $fp = fopen('/var/www/html/text_image_generator/test.png', 'wb');
$fp = fopen('/var/www/html/text_image_generator/savedimages/image'.$n.'.png', 'wb');
fwrite($fp, $unencodedData);
fclose($fp);
//}
?>