update: 托管主机的主机名配置和接口

This commit is contained in:
Jackson Dou 2023-07-06 01:56:30 +08:00
parent da431fa5ca
commit 47cf5a7bfd
20 changed files with 309 additions and 170 deletions

View file

@ -0,0 +1,75 @@
<?php
require 'application.php';
@header('Content-Type: application/json; charset=UTF-8');
if (!checkRefererHost()) exit('{"code":403}');
$act = get('act');
switch ($act) {
case 'list':
$count = $DB->count('account_hostname');
$list = array();
if ($count > 0) {
$list = $DB->findAll('account_hostname', '*', array(), '`host_id` ASC');
}
exit(json_encode(['code' => 0, 'total' => $total, 'list' => $list]));
break;
case 'add':
$hostname = post('hostname');
if (!$hostname) {
exit(json_encode(['code' => -1, 'msg' => '主机名不能为空 ']));
}
$api_id = post('api_id');
if (!$api_id) {
exit(json_encode(['code' => -1, 'msg' => '托管服务提供商不能为空 ']));
}
$domain = strtolower($hostname);
if (substr($domain, 0, 1) != '.') {
$domain = '.' . $domain;
}
$data = array(
'api_id' => $api_id,
'host_name' => $domain,
);
$has = $DB->count('account_hostname', $data);
if ($has && $has > 0) {
exit(json_encode(['code' => -1, 'msg' => 'Hostname aleady exsist ']));
} else {
$result = $DB->insert('account_hostname', $data);
if ($result) {
exit(json_encode(['code' => 0, 'msg' => 'Hostname added successfully ']));
} else {
exit(json_encode(['code' => -1, 'msg' => 'Something went wrong ']));
}
}
break;
case 'delete':
$host_id = post('host_id');
if (!$host_id) {
exit(json_encode(['code' => -1, 'msg' => '主机ID不能为空 ']));
}
$data = array(
'host_id' => $host_id
);
$has = $DB->count('account_hostname', $data);
if (!$has > 0) {
exit(json_encode(['code' => -1, 'msg' => 'Hostname not found ']));
} else {
$result = $DB->delete('account_hostname', $data);
if ($result) {
exit(json_encode(['code' => 0, 'msg' => 'Hostname deleted successfully ']));
} else {
exit(json_encode(['code' => -1, 'msg' => 'Something went wrong ']));
}
}
default:
exit('{"code":-4,"msg":"No Act"}');
break;
}

View file

@ -1,37 +0,0 @@
<?php
require_once __DIR__ . '/../../application.php';
if (!isset($_POST['submit'])) {
exit('Method Not Allowed');
}
$domain = post('domain');
if (!$domain) {
redirect('admin/domain');
}
$domain = strtolower($domain);
if (substr($domain, 0, 1) != '.') {
$domain = '.' . $domain;
}
$data = array(
'extension_value' => $domain,
);
$has = $DB->count('account_domaintld', $data);
if ($has && $has > 0) {
setMessage('Extension aleady <b>exsist!</b>', 'danger');
} else {
$result = $DB->insert('account_domaintld', $data);
if ($result) {
setMessage('Extension added <b>successfully!</b>');
} else {
setMessage('Something went' . "'" . 's <b>wrong!</b>', 'danger');
}
}
redirect('admin/domain');

View file

@ -1,38 +0,0 @@
<?php
require_once __DIR__ . '/../../application.php';
if (!isset($_POST['submit'])) {
exit('Method Not Allowed');
}
$extension = post('extension');
if (!$extension) {
redirect('admin/domain');
}
$extension = strtolower($extension);
if (substr($extension, 0, 1) != '.') {
$extension = '.' . $extension;
}
$data = array(
'extension_value' => $extension,
);
$count = $DB->count('account_domaintld', $data);
if (!$count > 0) {
setMessage('Extension won' . "'" . 't <b>exsist!</b>', 'danger');
} else {
$result = $DB->delete('account_domaintld', $data);
if ($result) {
setMessage('Extension deleted <b>successfully!</b>');
} else {
setMessage('Something went' . "'" . 's <b>wrong!</b>', 'danger');
}
}
redirect('admin/domain');

View file

@ -1,9 +0,0 @@
<?php
$PageInfo['title'] = 'Domain Extensions';
$count = $DB->count('account_domaintld');
if ($count > 0) {
$rows = $DB->findAll('account_domaintld', '*', array(), '`extension_id` ASC');
}

View file

@ -0,0 +1,17 @@
<?php
$PageInfo['title'] = $lang->I18N('Hosting Hostname');
$api_id = get('id');
$where = array();
if ($api_id > 0) {
$has = $DB->find('account_api', 'api_id', array('api_id' => $api_id), null, 1);
if ($has) {
$where = array('api_id' => $api_id);
}
}
$count = $DB->count('account_hostname', $where);
if ($count > 0) {
$rows = $DB->findAll('account_hostname', '*', $where, '`host_id` ASC');
}

View file

@ -4,15 +4,14 @@ require_once __DIR__ . '/application.php';
$action = get('action', 'list');
if (!in_array($action, array('list', 'add', 'edit', 'view'))) {
if (!in_array($action, array('list', 'add', 'edit', 'details'))) {
$action = 'list';
}
$PageInfo['title'] = 'Domain Provider ' . ucfirst($action);
require __DIR__ . '/controllers/domain/' . $action . '.php';
// require __DIR__ . '/controllers/domain-provider/' . $action . '.php';
require __DIR__ . '/views/header.php';
require __DIR__ . '/views/navbar.php';
// require __DIR__ . '/views/sidebar.php';
require __DIR__ . '/views/domain/' . $action . '.php';
require __DIR__ . '/views/domain-provider/' . $action . '.php';
require __DIR__ . '/views/footer.php';

17
src/admin/hosting-hostname.php Executable file
View file

@ -0,0 +1,17 @@
<?php
require_once __DIR__ . '/application.php';
$action = get('action', 'list');
if (!in_array($action, array('list'))) {
$action = 'list';
}
$PageInfo['title'] = 'Hosting Hostname ' . ucfirst($action);
require __DIR__ . '/controllers/hosting-hostname/' . $action . '.php';
require __DIR__ . '/views/header.php';
require __DIR__ . '/views/navbar.php';
require __DIR__ . '/views/hosting-hostname/' . $action . '.php';
require __DIR__ . '/views/footer.php';

View file

@ -0,0 +1,27 @@
<?php
if (!defined('IN_CRONLITE')) {
exit('Access Denied');
}
?>
<div class="content-wrapper">
<div class="container">
<ol class="breadcrumb page-breadcrumb">
<li><a href="index.php"><?php echo $lang->I18N('Dashboard'); ?></a></li>
<li class="active"><?php echo $lang->I18N('Domain Provider'); ?></li>
</ol>
<div class="panel panel-default">
<div class="panel-heading">
<div class="pull-right">
<a href="domain-provider.php?action=add" class="btn btn-primary btn-xs">
<i class="fa fa-plus"></i> <?php echo $lang->I18N('add'); ?>
</a>
</div>
<span class="panel-title"><?php echo $PageInfo['title']; ?></span>
</div>
<div class="panel-body">
</div>
<div class="panel-footer"></div>
</div>
</div>
</div>

View file

@ -1,60 +0,0 @@
<div class="content-wrapper">
<div class="container-fluid">
<div class="card py-0">
<div class="d-flex justify-content-between align-items-center pt-15">
<h5 class="m-0"><?php echo $PageInfo['title']; ?></h5>
<a href="index.php" class="btn btn-danger btn-sm">
<i class="fa fa-backward"></i> <?php echo $lang->I18N('Return');?>
</a>
</div>
<hr />
<form class="card-body" action="controllers/domain/add.php" method="post">
<div class="row">
<div class="col-md-6">
<label class="form-label required">Add Domain Extension</label>
<input type="text" name="domain" id="cudomain" class="form-control" placeholder="eg .example.com">
</div>
<div class="col-md-6">
<label class="form-label required">Add Domain Extension</label>
<button name="submit" class="btn btn-primary">Register</button>
</div>
</div>
</form>
<div class="card-body table-responsive">
<h4 class="mb-5">Registered Extensions</h4>
<table class="table table-stripped table-bordered table-hover">
<thead>
<th width="10%">ID</th>
<th width="75%">Domain</th>
<th width="15%">Action</th>
</thead>
<tbody>
<?php if ($count > 0): ?>
<?php foreach ($rows as $value): ?>
<tr>
<td># <?php echo $value['extension_id']; ?></td>
<td><?php echo $value['extension_value']; ?></td>
<td>
<form action="controllers/domain/delete.php" method="post">
<input hidden type="text" name="extension" value="<?php echo $value['extension_value']; ?>" />
<button name="submit" class="btn btn-sm btn-secondary btn-rounded"><i class="fa fa-trash"></i></button>
</form>
</td>
</tr>
<?php endforeach;?>
<?php else: ?>
<tr>
<td colspan="3" class="text-center">No domain found</td>
</tr>
<?php endif;?>
</tbody>
</table>
</div>
<hr />
<div class="card-footer">
<p class="pb-10"><?php echo $count; ?> Records Found</p>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,143 @@
<?php
if (!defined('IN_CRONLITE')) {
exit('Access Denied');
}
?>
<div class="content-wrapper">
<div class="container">
<input type="hidden" value="<?php echo $api_id; ?>" name="api_id" />
<ol class="breadcrumb page-breadcrumb">
<li><a href="index.php"><?php echo $lang->I18N('Dashboard'); ?></a></li>
<li><a href="hosting-provider.php"><?php echo $lang->I18N('Hosting Provider'); ?></a></li>
<li><a href="<?php echo setURL('admin/hosting-provider', '', array('action' => 'details', 'id' => $api_id)); ?>"><?php echo $lang->I18N('details'); ?></a></li>
<li class="active"><?php echo $lang->I18N('Hostname'); ?></li>
</ol>
<div class="panel panel-default">
<div class="panel-heading">
<div class="pull-right">
<a class="btn btn-primary btn-xs" onclick="add_hostname();">
<i class="fa fa-plus"></i> <?php echo $lang->I18N('add'); ?>
</a>
</div>
<span class="panel-title"><?php echo $PageInfo['title']; ?></span>
</div>
<div class="table-responsive">
<table class="table table-stripped table-bordered table-hover">
<thead>
<th>ID</th>
<th><?php echo $lang->I18N('Hosting Provider'); ?></th>
<th><?php echo $lang->I18N('Hostname'); ?></th>
<th><?php echo $lang->I18N('Action'); ?></th>
</thead>
<tbody>
<?php if ($count > 0): ?>
<?php foreach ($rows as $value): ?>
<tr>
<td><?php echo $value['host_id']; ?></td>
<td><?php echo $value['api_id']; ?></td>
<td><?php echo $value['host_name']; ?></td>
<td>
<button class="btn btn-danger btn-xs" onclick="delete_hostname('<?php echo $value['host_id']; ?>');"><i class="fa fa-trash"></i></button>
</td>
</tr>
<?php endforeach;?>
<?php else: ?>
<tr>
<td colspan="4" class="text-center">No Data Found</td>
</tr>
<?php endif;?>
</tbody>
</table>
</div>
<div class="panel-footer">
<p class="pb-10"><?php echo $count; ?> Records Found</p>
</div>
</div>
</div>
</div>
<script>
function delete_hostname(host_id) {
layer.confirm('确定删除 ', {
icon: 3,
btn: ['确定', '取消']
}, function() {
var ii = layer.load(2);
$.ajax({
type: 'POST',
url: 'api/hosting-hostname.php?act=delete',
data: {
host_id: host_id
},
dataType: 'json',
success: function(data) {
layer.close(ii);
if (data.code == 0) {
layer.msg('删除成功');
setTimeout(function() {
window.location.href = window.location.href;
}, 1000);
} else {
layer.alert(data.msg, {
icon: 2
});
}
},
error: function(data) {
layer.close(ii);
layer.msg('服务器错误');
}
});
});
}
function add_hostname() {
layer.open({
type: 1,
area: ['350px'],
closeBtn: 2,
title: '<?php echo $lang->I18N('Add Hostname'); ?>',
content: '<div style="padding:15px 15px 0 15px"><p>请输入主机名。</p><div class="form-group"><input class="form-control" type="text" name="content" value="" autocomplete="off" placeholder="请输入主机名 eg .example.com"></div></div>',
btn: ['<?php echo $lang->I18N('Save'); ?>', '<?php echo $lang->I18N('Cancel'); ?>'],
yes: function() {
var content = $("input[name='content']").val();
if (content == '') {
$("input[name='content']").focus();
return;
}
var ii = layer.load(2, {
shade: [0.1, '#fff']
});
var api_id = $("input[name='api_id']").val();
$.ajax({
type: 'POST',
url: 'api/hosting-hostname.php?act=add',
data: {
api_id: api_id,
hostname: content
},
dataType: 'json',
success: function(data) {
layer.close(ii);
if (data.code == 0) {
layer.alert(data.msg, {
icon: 1
}, function() {
layer.closeAll();
window.location.href = window.location.href;
});
} else {
layer.alert(data.msg, {
icon: 0
});
}
},
error: function(data) {
layer.close(ii);
layer.msg('服务器错误');
}
});
}
});
}
</script>

View file

@ -13,6 +13,7 @@ if (!defined('IN_CRONLITE')) {
<div class="panel panel-default">
<div class="panel-heading">
<div class="pull-right">
<a href="hosting-hostname.php?id=<?php echo $data['api_id']; ?>" class="btn btn-primary btn-xs"><i class="fa fa-info-circle"></i> <?php echo $lang->I18N('Hostname'); ?></a>
<a href="<?php echo setURL('admin/hosting-provider', '', array('action' => 'edit', 'id' => $data['api_id'])); ?>" class="btn btn-success btn-xs">
<i class="fa fa-edit"></i> <?php echo $lang->I18N('edit'); ?>
</a>

View file

@ -22,10 +22,10 @@ if (!defined('IN_CRONLITE')) {
<table class="table table-stripped table-bordered table-hover">
<thead>
<th>Key</th>
<th>Type</th>
<th><?php echo $lang->I18N('Type'); ?></th>
<th>Panel URL</th>
<th>Package</th>
<th width="160">Action</th>
<th><?php echo $lang->I18N('Package'); ?></th>
<th><?php echo $lang->I18N('Action'); ?></th>
</thead>
<tbody>
<?php if ($count > 0): ?>
@ -38,6 +38,7 @@ if (!defined('IN_CRONLITE')) {
<td>
<a href="hosting-provider.php?action=edit&id=<?php echo $value['api_id']; ?>" class="btn btn-success btn-xs"><i class="fa fa-edit"></i> <?php echo $lang->I18N('edit'); ?></a>
<a href="hosting-provider.php?action=details&id=<?php echo $value['api_id']; ?>" class="btn btn-primary btn-xs"><i class="fa fa-info-circle"></i> <?php echo $lang->I18N('details'); ?></a>
<a href="hosting-hostname.php?id=<?php echo $value['api_id']; ?>" class="btn btn-primary btn-xs"><i class="fa fa-info-circle"></i> <?php echo $lang->I18N('Hostname'); ?></a>
</td>
</tr>
<?php endforeach;?>

View file

@ -35,7 +35,7 @@
<li><a href="news.php"><i class="fa fa-newspaper fa-fw" aria-hidden="true"></i> <?php echo $lang->I18N('News List'); ?></a></li>
<li><a href="hosting-provider.php"><i class="fa fa-server fa-fw" aria-hidden="true"></i> <?php echo $lang->I18N('Hosting Provider'); ?></a></li>
<li><a href="ssl-provider.php"><i class="fa fa-server fa-fw" aria-hidden="true"></i> <?php echo $lang->I18N('SSL Provider'); ?></a></li>
<li><a href="domain.php"><i class="fa fa-globe fa-fw" aria-hidden="true"></i> <?php echo $lang->I18N('Domain Provider'); ?></a></li>
<li><a href="domain-provider.php"><i class="fa fa-globe fa-fw" aria-hidden="true"></i> <?php echo $lang->I18N('Domain Provider'); ?></a></li>
<li><a href="settings.php"><i class="fa fa-cog fa-fw" aria-hidden="true"></i> <?php echo $lang->I18N('System Settings'); ?></a></li>
</ul>
</li>

View file

@ -49,7 +49,7 @@ $avatar_path = $AdminInfo['admin_email'] ? md5($AdminInfo['admin_email']) : 'def
<span class="sidebar-icon bg-transparent"><i class="fa fa-server" aria-hidden="true"></i></span>
<?php echo $lang->I18N('Hosting Provider'); ?>
</a>
<a href="domain.php" class="sidebar-link sidebar-link-with-icon">
<a href="hosting-provider.php" class="sidebar-link sidebar-link-with-icon">
<span class="sidebar-icon bg-transparent"><i class="fa fa-globe" aria-hidden="true"></i></span>
<?php echo $lang->I18N('Domain Provider'); ?>
</a>

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -110,16 +110,16 @@ if (isset($_POST['submit'])) {
setMessage('api_key cannot be <b>empty</b> !', 'danger');
redirect('clientarea/accounts');
}
$ExtensionInfo = $DB->findAll('account_domaintld', '*', array(), 'extension_id');
$HostnameInfo = $DB->findAll('account_hostname', '*', array(), 'host_id');
$AccountApi = $DB->find('account_api', '*', array('api_key' => get('api_key')), null, 1);
$AccountApiConfig = array(
'apiUsername' => $AccountApi['api_username'],
'apiPassword' => $AccountApi['api_password'],
'plan' => $AccountApi['api_package'],
);
if (empty($ExtensionInfo)) {
$ExtensionInfo = array(
'extension_value' => '.html-5.me',
if (empty($HostnameInfo)) {
$HostnameInfo = array(
'host_name' => '.html-5.me',
);
}
}

View file

@ -61,9 +61,9 @@
<div class="input-group">
<input type="text" id="sudomain" class="form-control" placeholder="Search domain name here...">
<div class="input-group-append">
<select class="form-control" style="border-radius: 0" id="extension" name="extension">
<?php foreach ($ExtensionInfo as $value): ?>
<option><?php echo $value['extension_value']; ?></option>
<select class="form-control" style="border-radius: 0" id="host_name" name="host_name">
<?php foreach ($HostnameInfo as $value): ?>
<option><?php echo $value['host_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
@ -140,8 +140,8 @@
function check_sub_domain() {
$('#hidden-area').html('');
var domain = $('#sudomain').val();
var extensions = $('#extension').val();
var validomain = domain + extensions;
var host_names = $('#host_name').val();
var validomain = domain + host_names;
$.post('controllers/accounts/validate_domain.php', {domain : validomain, submit: ""}, function(data){
if (validomain != data) {
$('#hidden-area').html('<div class="alert alert-danger" role="alert"><button class="close" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+data+'</div>');
@ -166,8 +166,8 @@
function create_account() {
$('#hidden-area').html('');
var domain = $('#sudomain').val();
var extensions = $('#extension').val();
var validomain = domain + extensions;
var host_names = $('#host_name').val();
var validomain = domain + host_names;
$.post('controllers/accounts/add.php', {
domain: validomain,
api_key: 'ttkl.cf',

View file

@ -177,5 +177,7 @@ return array(
'Page Author' => '网页著作人',
'Admin Area' => '管理中心',
'Hosting Provider' => '托管提供商',
'Domain Provider' => '域名提供商'
'Domain Provider' => '域名提供商',
'Hosting Hostname' => '托管主机名',
'Hostname' => '主机名',
);

View file

@ -99,10 +99,11 @@ $sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_clients` (
PRIMARY KEY (`client_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;');
$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account_domaintld` (
`extension_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
`extension_value` VARCHAR(70) NOT NULL,
PRIMARY KEY (`extension_id`)
$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_account_hostname` (
`host_id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
`api_id` INT(11) NOT NULL,
`host_name` VARCHAR(70) NOT NULL,
PRIMARY KEY (`host_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;');
$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_smtp` (
@ -193,7 +194,7 @@ $sql = mysqli_query($connect, "INSERT INTO `uiisc_ssl_api`(`api_key`, `api_usern
$sql = mysqli_query($connect, "INSERT INTO `uiisc_builder_api`(`builder_id`, `builder_username`, `builder_password`) VALUES ('SITEPRO','apikey0','API Password')");
$sql = mysqli_query($connect, "INSERT INTO `uiisc_account_domaintld`(`extension_value`) VALUES ('.example.com')");
$sql = mysqli_query($connect, "INSERT INTO `uiisc_account_hostname`(`host_name`) VALUES ('.example.com')");
$sql = mysqli_query($connect, 'CREATE TABLE IF NOT EXISTS `uiisc_news`(
`news_id` INT(11) NOT NULL AUTO_INCREMENT,