-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.php
More file actions
39 lines (37 loc) · 726 Bytes
/
save.php
File metadata and controls
39 lines (37 loc) · 726 Bytes
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
<?php
function rndName($len){
$Rname=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
$mainName="";
for ($i=0; $i < $len; $i++) {
$mainName.=$Rname[rand(0,count($Rname)-1)];
}
return $mainName;
}
//echo rndName(10).".html";
$name=rndName(10).".html";
function save($data){
global $name;
$file=fopen($name,"w");
if(fwrite($file,$data)){
echo $name;
}
}
function del($file){
if(file_exists($file)){
unlink($file);
echo "finished";
}
else{
echo "file not found";
}
}
if($_SERVER["REQUEST_METHOD"]=="POST"){
$action=$_POST["action"];
$data=$_POST["data"];
if($action=="save"){
save($data);
}
else if($action=="del"){
del($data);
}
}