-
Notifications
You must be signed in to change notification settings - Fork 0
/
shipFicPost.php
executable file
·92 lines (83 loc) · 2.46 KB
/
shipFicPost.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
88
89
90
91
92
<?php
function taggify($attrs,$classes){
$tags = [];
if ($attrs){
$tags = array_merge($tags,array_map(function($n){
return preg_replace("~\s+~","_",trim($n));
},explode(",",$_POST["attrs"])));
}
if ($classes){
$classArray = explode(" ",$_POST["classes"]);
foreach($classArray as $cls){
$cls = substr($cls,1);
switch ($cls) {
case "pony":
case "start":
case "ship":
case "goal":
array_push($tags,$cls);
break;
case "female":
case "male":
case "maleFemale":
case "unicorn":
case "pegasus":
case "earthPony":
case "alicorn":
case "changeling":
case "time":
if(in_array(".pony",$classArray) || in_array(".start",$classArray)){
array_push($tags,$cls);
}
break;
case "s0":
case "s1":
case "s2":
case "s3":
case "s4":
if(in_array(".goal",$classArray)){
array_push($tags,$cls);
}
break;
}
}
}
return implode(" ",$tags);
}
function imageify(){
$b64 = $_POST["b64Img"];
$tmpName = tempnam("","");
$tmpFile = fopen($tmpName,"wb");
$data = explode(",",$b64);
fwrite($tmpFile,base64_decode($data[1]));
fclose($tmpFile);
chmod($tmpName,0744);
echo $tmpName;
return $tmpName;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST'){
$data = [
"upload" => "@".imageify(),
"source" => "",
"title" => $_POST["name"],
"tags" => taggify(true,true),
"rating" => "q",
"submit" => "Upload"
];
$destinationUrl = "http://secretshipfic.booru.org/index.php?page=post&s=add";
//$destinationUrl = "https://sucs.org/~ripp_/phpEcho.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$destinationUrl);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$result=curl_exec($ch);
var_dump($data);
var_dump($result);
} else {
die(json_encode(Array(
"error"=>"Not a valid method",
"details"=>"Only POST is valid"
)));
}
?>