1 Star 0 Fork 104

qingke-project / VvvebJs

forked from Gitee 极速下载 / VvvebJs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
save.php 813 Bytes
一键复制 编辑 原始数据 按行查看 历史
<?php
define('MAX_FILE_LIMIT', 1024 * 1024 * 2);//2 Megabytes max html file size
function sanitizeFileName($fileName)
{
//sanitize, remove double dot .. and remove get parameters if any
$fileName = __DIR__ . '/' . preg_replace('@\?.*$@' , '', preg_replace('@\.{2,}@' , '', preg_replace('@[^\/\\a-zA-Z0-9\-\._]@', '', $fileName)));
return $fileName;
}
$html = "";
if (isset($_POST['startTemplateUrl']) && !empty($_POST['startTemplateUrl']))
{
$startTemplateUrl = sanitizeFileName($_POST['startTemplateUrl']);
$html = file_get_contents($startTemplateUrl);
} else if (isset($_POST['html']))
{
$html = substr($_POST['html'], 0, MAX_FILE_LIMIT);
}
$fileName = sanitizeFileName($_POST['file']);
if (file_put_contents($fileName, $html)) {
echo $fileName;
} else {
echo 'Error saving file ' . $fileName;
}
JavaScript
1
https://gitee.com/qingke-project/VvvebJs.git
git@gitee.com:qingke-project/VvvebJs.git
qingke-project
VvvebJs
VvvebJs
master

搜索帮助