Quick fix
This commit is contained in:
parent
f39ca9c997
commit
890dfea5ab
16
ddns.py
16
ddns.py
@ -185,14 +185,14 @@ def remove_subdomain(domain):
|
||||
else:
|
||||
sub = parts[0]
|
||||
top = parts[1] + '.' + parts[2]
|
||||
|
||||
longtop=sub+'.'+top
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ?',(top,))
|
||||
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ? or name like ?',(top,longtop,))
|
||||
count = cursor.fetchone()[0]
|
||||
if count == 0:
|
||||
print('[red]Error:[/red] Top domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (top))
|
||||
else:
|
||||
cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,))
|
||||
cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like ?)',(sub,top,longtop,))
|
||||
count = cursor.fetchone()[0]
|
||||
if count == 0:
|
||||
print('[red]Error:[/red] Domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (domain))
|
||||
@ -201,7 +201,7 @@ def remove_subdomain(domain):
|
||||
if apikey == None:
|
||||
print("[red]Error:[/red] Missing APIkey. Please add one!")
|
||||
else:
|
||||
cursor.execute('SELECT id FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,))
|
||||
cursor.execute('SELECT id FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like ?)',(sub,top,longtop,))
|
||||
subdomain_id = str(cursor.fetchone()[0])
|
||||
headers = {'Authorization': 'Bearer ' + apikey, "Content-Type": "application/json"}
|
||||
response = requests.delete('https://api.digitalocean.com/v2/domains/'+top+'/records/' + subdomain_id, headers=headers)
|
||||
@ -225,13 +225,14 @@ def edit_subdomain(domain):
|
||||
else:
|
||||
sub = parts[0]
|
||||
top = parts[1] + '.' + parts[2]
|
||||
longtop=sub+'.'+top
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ?',(top,))
|
||||
cursor.execute('SELECT COUNT(*) FROM domains WHERE name like ? or name like ?',(top,longtop,))
|
||||
count = cursor.fetchone()[0]
|
||||
if count == 0:
|
||||
print('[red]Error:[/red] Top domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (top))
|
||||
else:
|
||||
cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,))
|
||||
cursor.execute('SELECT COUNT(*) FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like)',(sub,top,longtop))
|
||||
count = cursor.fetchone()[0]
|
||||
if count == 0:
|
||||
print('[red]Error:[/red] Domain [bold]%s[/bold] does not exist in the DB. So I\'m giving up!.' % (domain))
|
||||
@ -240,7 +241,7 @@ def edit_subdomain(domain):
|
||||
if apikey == None:
|
||||
print("[red]Error:[/red] Missing APIkey. Please add one!")
|
||||
else:
|
||||
cursor.execute('SELECT id,active FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name=?)',(sub,top,))
|
||||
cursor.execute('SELECT id,active FROM subdomains WHERE name like ? and main_id=(SELECT id from domains WHERE name like ? or name like ?)',(sub,top,longtop))
|
||||
domain_info = cursor.fetchone()
|
||||
subdomain_id = str(domain_info[0])
|
||||
status = domain_info[1]
|
||||
@ -491,7 +492,6 @@ def local_add_subdomain(domain,domainid):
|
||||
else:
|
||||
parts = domain.split('.')
|
||||
if len(parts) > 3:
|
||||
# longtop = parts[2] + '.' + parts[2] + '.' + parts[3]
|
||||
top = parts[1] + '.' + parts[2] + '.' + parts[3]
|
||||
sub = parts[0]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user