burakboz / cyberlink
填充缺失的CyberPanel API。警告:它不是一个API或API服务。它使用ssh和sftp协议完成任务,需要服务器root权限。
v1.0.1
2023-08-31 08:42 UTC
Requires
- league/flysystem: ^1.0
- league/flysystem-sftp: ^1.0
- phpseclib/phpseclib: ^2.0
This package is auto-updated.
Last update: 2024-09-30 01:32:25 UTC
README
一个用于不使用API利用CyberPanel的PHP库。
查看CyberPanel API文档,是的,几乎没有。
Currently CyberPanel doesn't have API functions fully described and implemented.
So I wrote this library.
##Composer 安装 composer require burakboz/cyberlink:dev-master
##示例使用
// If you need public key auth on ssh connection provide private key string to $key parameter otherwise it should be null.
// $enableSecureFTP parameter should be true for using setCustomSSL method.
// If you don't need this don't set it true.
$ip = "127.0.0.1";
$user = "root"; // use only root user
$password = "TopSecretPassword"; // root password
$port = 22; // ssh port
$timeout = 20; // connection timeout
$enableSecureFTP = false; // set it true if you use $cyberlink->setCustomSSL() method.
$cyberlink = new \BurakBoz\CyberLink($ip, $user, $password, $key = null, $port = 22, $timeout = 10, $enableSecureFTP = false);
$phpVersion = "7.3";
$owner = "admin";
$package = "Default";
try
{
if($cyberlink->createWebsite("merhaba.com", "admin@siteowner.com", $package, $owner, $phpVersion))
{
echo "Host created.";
}
else
{
echo "Error: " . $cyberlink->getLastMessage();
}
}
catch (Exception $e)
{
echo "Error: " . $e->getMessage();
}
这个库的魔法是什么?
网站功能
createWebsite
/**
* @param $domainName
* @param $email
* @param string $package
* @param string $owner
* @param string $phpVersion
* @return bool
* @throws Exception
*/
$cyberlink->createWebsite($domainName, $email, $package = self::package, $owner = self::owner, $phpVersion = self::phpVersion);
deleteWebsite
/**
* @param $domainName
* @return bool
* @throws Exception
*/
$cyberlink->deleteWebsite($domainName);
createChild
/**
* @param $masterDomain
* @param $childDomain
* @param string $owner
* @param string $phpVersion
* @return bool
* @throws Exception
*/
$cyberlink->createChild($masterDomain, $childDomain, $owner = self::owner, $phpVersion = self::phpVersion);
deleteChild
/**
* @param $childDomain
* @return bool
* @throws Exception
*/
$cyberlink->deleteChild($childDomain);
listWebsites
/**
* @return mixed
*/
$cyberlink->listWebsites();
changePHP
/**
* @param $domainName
* @param string $phpVersion
* @return bool
* @throws Exception
*/
$cyberlink->changePHP($domainName, $phpVersion = self::phpVersion);
changePackage
/**
* @param $domainName
* @param string $packageName
* @return bool
* @throws Exception
*/
$cyberlink->changePackage($domainName, $packageName = self::package);
DNS功能
尚未实现。
备份功能
createBackup
/**
* @param $domainName
* @return bool
* @throws Exception
*/
$cyberlink->createBackup($domainName);
restoreBackup
/**
* @param $domainName
* @param $fileName
* @return bool
* @throws Exception
*/
$cyberlink->restoreBackup($domainName, $fileName);
包功能
createPackage
/**
* @param $packageName
* @param int $diskSpace
* @param int $bandwidth
* @param int $emailAccounts
* @param int $dataBases
* @param int $ftpAccounts
* @param int $allowedDomains
* @param string $owner
* @return bool
* @throws Exception
*/
$cyberlink->createPackage($packageName, $diskSpace = 1000, $bandwidth = 10000, $emailAccounts = 100, $dataBases = 100, $ftpAccounts = 100, $allowedDomains = 100, $owner = self::owner);
deletePackage
/**
* @param $packageName
* @return bool
* @throws Exception
*/
$cyberlink->deletePackage($packageName);
listPackages
/**
* @return mixed
*/
$cyberlink->listPackages();
数据库功能
createDatabase
/**
* @param $databaseWebsite
* @param $dbName
* @param $dbUsername
* @param $dbPassword
* @return bool
* @throws Exception
*/
$cyberlink->createDatabase($databaseWebsite, $dbName, $dbUsername, $dbPassword);
deleteDatabase
/**
* @param $dbName
* @return bool
* @throws Exception
*/
$cyberlink->deleteDatabase($dbName);
listDatabases
/**
* @param $databaseWebsite
* @return mixed
*/
$cyberlink->listDatabases($databaseWebsite);
邮件功能
尚未实现。
FTP功能
createFTPAccount
/**
* @param $domainName
* @param $userName
* @param $password
* @param string $owner
* @return bool
* @throws Exception
*/
$cyberlink->createFTPAccount($domainName, $userName, $password, $owner = self::owner);
deleteFTPAccount
/**
* @param $userName
* @return bool
* @throws Exception
*/
$cyberlink->deleteFTPAccount($userName);
changeFTPPassword
/**
* @param $userName
* @param $password
* @return bool
* @throws Exception
*/
$cyberlink->changeFTPPassword($userName, $password);
listFTP
/**
* @param $domainName
* @return mixed
*/
$cyberlink->listFTP($domainName);
SSL功能
issueSSL
/**
* @param $domainName
* @return bool
* @throws Exception
*/
$cyberlink->issueSSL($domainName);
hostNameSSL
/**
* @param $domainName
* @return bool
* @throws Exception
*/
$cyberlink->hostNameSSL($domainName);
mailServerSSL
/**
* @param $domainName
* @return bool
* @throws Exception
*/
$cyberlink->mailServerSSL($domainName);
其他功能
设置自定义SSL
/**
* Warning! This method shouldn't be trusted. In future versions of CyberPanel (Currently 1.9) and LiteSpeed may cause system failure. Use at your own risk.
* @param $domain
* @param $publicKey
* @param $privateKey
* @return bool
* @throws Exception
*/
$cyberlink->setCustomSSL($domain, $publicKey, $privateKey);
重置CyberPanel管理员密码
/**
* @param $password
* @return string
*/
$cyberlink->resetAdminPassword($password);
升级CyberPanel
/**
* @return string
*/
$cyberlink->upgradeCyberPanel();
重启LiteSpeed
/**
* @return string
*/
$cyberlink->restartLiteSpeed();
重启服务器
/**
* @return string
*/
$cyberlink->rebootServer();
服务器运行时间
/**
* @return string
*/
$cyberlink->uptime();