#!/usr/bin/python2 import sys, cgi, cgitb, os cgitb.enable() import mm from mm import website form = cgi.FieldStorage() auth_dbh = website.get_dbh('auth') auth_username, auth_password = website.get_auth(auth_dbh, form) print "Content-type: text/html\n" website.print_header('Mirror Manager :: Edit Site') website.handle_auth(auth_username, auth_password, form, 'mm-edit-site.cgi', title='Mirror Manager :: Edit Site', require_auth=1) del auth_password mirror_dbh = website.get_dbh('mirrors') role_type = website.have_group(auth_dbh, auth_username, 'mirrors') if not role_type: print "You need to apply for membership in the 'mirrors' group." website.print_footer('Mirror Manager :: Edit Site', return_to='mm-console.cgi') sys.exit(0) dbc = mirror_dbh.cursor() dbc.execute("SELECT * FROM site WHERE host = %s", (form['host'].value, )) site_info = dbc.fetchhash() if not site_info: print "This mirror does not exist" website.print_footer('Mirror Manager :: Edit Site', return_to='mm-console.cgi') sys.exit(0) if role_type != 'administrator' and auth_username != site_info['maintainer']: print "To edit a mirror, you must be the mirror maintainer or a mirrors administrator." website.print_footer('Mirror Manager :: Edit Site', return_to='mm-console.cgi') sys.exit(0) print "
" print 'Site\'s main hostname: %s

' % (site_info['host'], site_info['host']) auth_dbc = auth_dbh.cursor() auth_dbc.execute("SELECT human_name, email FROM person WHERE username = %s", (site_info['maintainer'], )) if auth_dbc.rowcount: mm_name, mm_email = auth_dbc.fetchone() else: mm_name, mm_email = ("Unknown", "") print "Maintainer: " if role_type == 'administrator': print '' % site_info['maintainer'] else: print site_info['maintainer'] print " %s <%s>

" % (mm_name, mm_email) print "Location (main geo):

Location (subgeo, usually country name. For USA, use "USA East" or "USA West"):

""" % site_info['subgeo'] print '

Return to main menu' # Now we need to allow them to edit URLs, file repositories, and mirrors print """
' print """' print """' print "
These are the URLs that point to the top of the site's file tree. """ % form['host'].value mm.url_editor(form, 'site', site_info['id'], mirror_dbh) print '
These are the file repositories that this site is the master for. """ % form['host'].value mm.repo_editor(form, site_info['id'], mirror_dbh) print '
The selected file repositories are the ones this site mirrors.

""" % form['host'].value mm.mirror_editor(form, site_info['id'], mirror_dbh) print '

" website.print_footer('Mirror Manager :: Edit Site', return_to='mm-console.cgi')