|
@@ -2,7 +2,7 @@
|
|
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
|
|
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
|
|
$myhost = $_SERVER['HTTP_HOST'];
|
|
$myhost = $_SERVER['HTTP_HOST'];
|
|
//判断主机,不允许公网访问
|
|
//判断主机,不允许公网访问
|
|
- if(($myhost != 'localhost') && ($myhost != '127.0.0.1')) {
|
|
|
|
|
|
+ if(($myhost != 'localhost') && ($myhost != '127.0.0.1:88')) {
|
|
echo "不允许公网访问!";
|
|
echo "不允许公网访问!";
|
|
exit;
|
|
exit;
|
|
}
|
|
}
|
|
@@ -14,12 +14,6 @@
|
|
'database_type' => 'sqlite',
|
|
'database_type' => 'sqlite',
|
|
'database_file' => '../data/nssl.db3']);
|
|
'database_file' => '../data/nssl.db3']);
|
|
|
|
|
|
- //设置证书路径
|
|
|
|
- //$ssldir = "../ssl/";
|
|
|
|
- //设置配置文件路径
|
|
|
|
- //$confdir = "D:/wwwroot/nssl/conf/";
|
|
|
|
- //$confdir = "../vhost/";
|
|
|
|
-
|
|
|
|
//获取域名
|
|
//获取域名
|
|
$domain = $_POST['domain'];
|
|
$domain = $_POST['domain'];
|
|
//替换http and https
|
|
//替换http and https
|
|
@@ -29,9 +23,13 @@
|
|
$key = $_POST['key']; //获取证书私钥
|
|
$key = $_POST['key']; //获取证书私钥
|
|
$note = $_POST['note']; //获取证书备注
|
|
$note = $_POST['note']; //获取证书备注
|
|
$id = $_POST['id']; //获取ID
|
|
$id = $_POST['id']; //获取ID
|
|
|
|
+ $siteid = $_POST['siteid']; //获取站点ID
|
|
$cerid = $_GET['cerid']; //获取证书ID,更新证书时使用
|
|
$cerid = $_GET['cerid']; //获取证书ID,更新证书时使用
|
|
$sslid = $_POST['sslid']; //获取证书id,更新站点时使用
|
|
$sslid = $_POST['sslid']; //获取证书id,更新站点时使用
|
|
$https = $_POST['https']; //是否强制https
|
|
$https = $_POST['https']; //是否强制https
|
|
|
|
+
|
|
|
|
+ //当前时间
|
|
|
|
+ $time = date('Y-m-d',time());
|
|
//获取类型
|
|
//获取类型
|
|
$type = $_GET['type'];
|
|
$type = $_GET['type'];
|
|
|
|
|
|
@@ -51,7 +49,7 @@
|
|
echo "添加失败,域名已存在!";
|
|
echo "添加失败,域名已存在!";
|
|
exit;
|
|
exit;
|
|
}
|
|
}
|
|
- $time = date('Y-m-d',time());
|
|
|
|
|
|
+
|
|
$last_user_id = $database->insert("s_cert", [
|
|
$last_user_id = $database->insert("s_cert", [
|
|
"domain" => $domain,
|
|
"domain" => $domain,
|
|
"crt" => $crt,
|
|
"crt" => $crt,
|
|
@@ -76,7 +74,6 @@
|
|
check($key,"key");
|
|
check($key,"key");
|
|
check($note,"note");
|
|
check($note,"note");
|
|
|
|
|
|
- $time = date('Y-m-d',time());
|
|
|
|
$last_user_id = $database->update("s_cert", [
|
|
$last_user_id = $database->update("s_cert", [
|
|
"crt" => $crt,
|
|
"crt" => $crt,
|
|
"key" => $key,
|
|
"key" => $key,
|
|
@@ -159,7 +156,7 @@
|
|
echo "添加失败,域名已存在!";
|
|
echo "添加失败,域名已存在!";
|
|
exit;
|
|
exit;
|
|
}
|
|
}
|
|
- $time = date('Y-m-d',time());
|
|
|
|
|
|
+
|
|
$last_user_id = $database->insert("s_site", [
|
|
$last_user_id = $database->insert("s_site", [
|
|
"domain" => $domain,
|
|
"domain" => $domain,
|
|
"sslid" => $sslid,
|
|
"sslid" => $sslid,
|
|
@@ -171,10 +168,10 @@
|
|
$cert = $database->get("s_cert",["id","domain","note"],["id" => $sslid]);
|
|
$cert = $database->get("s_cert",["id","domain","note"],["id" => $sslid]);
|
|
$certdir = $ssldir.$cert['domain']; //设置证书路径
|
|
$certdir = $ssldir.$cert['domain']; //设置证书路径
|
|
$content = file_get_contents("../data/temp.conf");
|
|
$content = file_get_contents("../data/temp.conf");
|
|
- $ip = file_get_contents("https://api-ipv4.ip.sb/ip");
|
|
|
|
- $ip = str_replace("\n","",$ip);
|
|
|
|
|
|
+ //$ip = file_get_contents("https://api-ipv4.ip.sb/ip");
|
|
|
|
+ //$ip = str_replace("\n","",$ip);
|
|
//替换监听地址
|
|
//替换监听地址
|
|
- $content = str_replace("192.168.1.1",$ip,$content);
|
|
|
|
|
|
+ //$content = str_replace("192.168.1.1",$ip,$content);
|
|
//替换域名
|
|
//替换域名
|
|
$content = str_replace("domain.com",$domain,$content);
|
|
$content = str_replace("domain.com",$domain,$content);
|
|
//替换证书路径
|
|
//替换证书路径
|
|
@@ -189,6 +186,7 @@
|
|
fwrite($myconf, $content);
|
|
fwrite($myconf, $content);
|
|
fclose($myconf);
|
|
fclose($myconf);
|
|
echo '添加成功!';
|
|
echo '添加成功!';
|
|
|
|
+ //reload();
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
//显示站点
|
|
//显示站点
|
|
@@ -221,7 +219,7 @@
|
|
echo "<td>".$ressl."</td>";
|
|
echo "<td>".$ressl."</td>";
|
|
echo "<td>".$https."</td>";
|
|
echo "<td>".$https."</td>";
|
|
echo "<td>".$data['time']."</td>";
|
|
echo "<td>".$data['time']."</td>";
|
|
- echo "<td><a href = 'javascript:;' class='layui-btn layui-btn-danger layui-btn-xs' onclick = 'delsite(\"$id\")'>"."删除</a></td>";
|
|
|
|
|
|
+ echo "<td><a class='layui-btn layui-btn-normal layui-btn-xs' href = 'editsite.php?siteid=$id' title = '301设置'>设置</a> <a href = 'javascript:;' class='layui-btn layui-btn-danger layui-btn-xs' onclick = 'delsite(\"$id\")'>"."删除</a></td>";
|
|
echo "</tr>";
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -238,6 +236,30 @@
|
|
echo 'ok';
|
|
echo 'ok';
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ //更新站点
|
|
|
|
+ case 'update_site':
|
|
|
|
+ $upsite = $database->update("s_site",["https" => $https,"time" => $time],["id" => $siteid]);
|
|
|
|
+
|
|
|
|
+ //如果更新成功
|
|
|
|
+ if($upsite) {
|
|
|
|
+ $sitecontent = file_get_contents("$confdir".$domain.".conf");
|
|
|
|
+
|
|
|
|
+ if($https == 1) {
|
|
|
|
+ $sitecontent = str_replace("test301.com",$domain,$sitecontent);
|
|
|
|
+ }
|
|
|
|
+ if($https == 0) {
|
|
|
|
+ $sitecontent = str_replace($domain,"test301.com",$sitecontent);
|
|
|
|
+ }
|
|
|
|
+ $mysite = fopen($confdir.$domain.".conf", "w") or die("Unable to open file!");
|
|
|
|
+ fwrite($mysite, $sitecontent);
|
|
|
|
+ fclose($mysite);
|
|
|
|
+ echo '更新成功!';
|
|
|
|
+ //reload();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ echo '未知错误!';
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
;
|
|
;
|
|
break;
|
|
break;
|
|
@@ -245,6 +267,11 @@
|
|
|
|
|
|
?>
|
|
?>
|
|
<?php
|
|
<?php
|
|
|
|
+ //重载nginx
|
|
|
|
+ function reload(){
|
|
|
|
+ $re = system("D:\SOFT_PHP_PACKAGE\nssl\reload.bat");
|
|
|
|
+ var_dump($re);
|
|
|
|
+ }
|
|
function check($parameter,$category){
|
|
function check($parameter,$category){
|
|
switch ( $category )
|
|
switch ( $category )
|
|
{
|
|
{
|