forked from zhouqicf/code-cola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codecola.php
executable file
·37 lines (32 loc) · 1.06 KB
/
codecola.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
<?php
/*
*@Author: [email protected]
*@Site: http://www.zhouqicf.com
*/
//Cross domain: http://www.w3.org/TR/cors/#access-control-allow-origin-response-hea
//It's very dangerous, anyone can send any content to your server, make sure only someone you trust have access to visit this action page.
header("Access-Control-Allow-Headers: Content-type, x-requested-with");
header("Access-Control-Allow-Origin: *");
header("Content-type: text/html; charset: utf-8");
//Users can visit modified pages through this address.
$path = "http://dev/save/";
//set filename
$fileName = time();
//create resulte
$fileName = $fileName.".html";
$html = $_POST["html"];
$encode = $_POST["charset"]?$_POST["charset"]:"UTF-8";
if($encode != "UTF-8"){
$html = iconv("UTF-8",$encode."//IGNORE",$html);
}
$url = $path.$fileName;
$success = '{"code":"200","url":"'.$url.'","message":"success"}';
$fail = '{"code":"900","message":"Server Error."}';
$fp=file_put_contents($fileName,$html);
if(!$fp){
$message = $fail;
}else{
$message = $success;
}
echo $message;
?>