-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudio404_ajax.php
More file actions
51 lines (46 loc) · 1.12 KB
/
studio404_ajax.php
File metadata and controls
51 lines (46 loc) · 1.12 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
<?php if(!defined("DIR")){ exit(); }
class studio404_ajax{
public $ip;
public function receiver(){
if(
$this->method("GET","ajax") &&
$this->method("GET","qid") &&
$this->method("GET","aid") &&
$this->method("GET","p")
){
$this->ip = $_SERVER["REMOTE_ADDR"];
$folder = sprintf("%squestion%s", $this->method("GET","p"), $this->method("GET","qid"));
if(!is_dir($folder)){
mkdir($folder);
}
$mask = array(
$folder."/".$this->ip.".*"
);
$this->rem($mask);
$file = sprintf("%s/%s.json", $folder, $this->ip);
$fp = fopen($file, "w");
$array = array("answer_id"=>$this->method("GET","aid"));
fwrite($fp, json_encode($array));
fclose($fp);
}
}
public static function method($type,$item){
if($type=="POST" && isset($_POST[$item])){
return filter_input(INPUT_POST, $item);
}else if($type=="GET" && isset($_GET[$item])){
return filter_input(INPUT_GET, $item);
}else{
return '';
}
}
private function rem($mask){
if(is_array($mask)){
foreach ($mask as $v) {
array_map('unlink', glob($v));
}
}else{
array_map('unlink', glob($mask));
}
}
}
?>