|
@@ -16,9 +16,13 @@ function listFsDirs($username) {
|
|
function addSite($username, $siteDir, $domain, $domainType, $protocol) {
|
|
function addSite($username, $siteDir, $domain, $domainType, $protocol) {
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
|
|
- $op = $db->prepare("INSERT INTO sites(username, site_dir, domain, domain_type, protocol, creation_date) VALUES(:username, :site_dir, :domain, :domain_type, :protocol, :creation_date)");
|
|
|
|
|
|
+ $op = $db->prepare("INSERT INTO sites(username, site_dir, domain, domain_type, protocol, creation_date, le_enabled) VALUES(:username, :site_dir, :domain, :domain_type, :protocol, :creation_date, :le_enabled)");
|
|
|
|
|
|
$time = date("Y-m-d H:i:s");
|
|
$time = date("Y-m-d H:i:s");
|
|
|
|
+ if ($domainType === "dns" AND $protocol === "http")
|
|
|
|
+ $le_enabled = 0;
|
|
|
|
+ else
|
|
|
|
+ $le_enabled = NULL;
|
|
|
|
|
|
$op->bindParam(':username', $username);
|
|
$op->bindParam(':username', $username);
|
|
$op->bindParam(':site_dir', $siteDir);
|
|
$op->bindParam(':site_dir', $siteDir);
|
|
@@ -26,6 +30,7 @@ function addSite($username, $siteDir, $domain, $domainType, $protocol) {
|
|
$op->bindParam(':domain_type', $domainType);
|
|
$op->bindParam(':domain_type', $domainType);
|
|
$op->bindParam(':protocol', $protocol);
|
|
$op->bindParam(':protocol', $protocol);
|
|
$op->bindParam(':creation_date', $time);
|
|
$op->bindParam(':creation_date', $time);
|
|
|
|
+ $op->bindParam(':le_enabled', $le_enabled);
|
|
|
|
|
|
$op->execute();
|
|
$op->execute();
|
|
}
|
|
}
|
|
@@ -88,5 +93,34 @@ function enableSftp($username) {
|
|
$op->bindParam(':username', $username);
|
|
$op->bindParam(':username', $username);
|
|
|
|
|
|
$op->execute();
|
|
$op->execute();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function selectSites($username, $domainType, $protocol, $onlyLeAvailable) {
|
|
|
|
+ $db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
+ $usernameArray[0] = $username;
|
|
|
|
+
|
|
|
|
+ $query = "SELECT site_dir,domain FROM sites WHERE username = :username AND domain_type = :domain_type AND protocol = :protocol";
|
|
|
|
+
|
|
|
|
+ if ($onlyLeAvailable === true)
|
|
|
|
+ $query = $query . " AND le_enabled = 0";
|
|
|
|
+
|
|
|
|
+ $op = $db->prepare($query);
|
|
|
|
+ $op->bindParam(':username', $username);
|
|
|
|
+ $op->bindParam(':domain_type', $domainType);
|
|
|
|
+ $op->bindParam(':protocol', $protocol);
|
|
|
|
+ $op->execute();
|
|
|
|
|
|
|
|
+ $i = 0;
|
|
|
|
+ $entry = $op->fetch();
|
|
|
|
+ while (isset($entry['site_dir'])) {
|
|
|
|
+ $result[$i]["siteDir"] = $entry['site_dir'];
|
|
|
|
+ $result[$i]["domain"] = $entry['domain'];
|
|
|
|
+ $i++;
|
|
|
|
+ $entry = $op->fetch();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isset($result))
|
|
|
|
+ return $result;
|
|
|
|
+ else
|
|
|
|
+ return false;
|
|
}
|
|
}
|