def pageInit(subHeading=None, formJS=0): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" if formJS: pmt_utils.generate_form_javascript(table_data, 'inventory', 'inv_admin', 0) else: pmt_utils.javaScript("inv_admin") pmt_utils.title("Inventory") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Inventory') if subHeading != None: pmt_utils.subHeading(subHeading) pmt_utils.formSetup("inv_admin", declarations.pmt_info['db_name'], "inv_admin", "return submitForm(document.inv_admin)") dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) if dbResult['status'] != 'success': db = None status = dbResult['message'] else: db = dbResult['result'] status = 'success' return status, table_data, db
def display_form(form, alerts): username = '' current_password = '' new_password = '' verify_password = '' if form.has_key('username'): username = form['username'].value if form.has_key('current_password'): current_password = form['current_password'].value if form.has_key('new_password'): new_password = form['new_password'].value if form.has_key('verify_password'): verify_password = form['verify_password'].value print '<html><head><title>Password Maintenance</title></head>' # print '<body bgcolor="#B7BAB7" TEXT="#000000"> print '<body background="/%s/icons/circ_bg.jpg">' % ( declarations.pmt_info['db_name']) # print '<H1>Password Maintenance</H1>' pmt_utils.mainHeading('Maintenance') pmt_utils.subHeading('Change Password') print '<form action="/%s-cgi-bin/passwd_admin.pyc" method="POST" enctype="application/x-www-form-urlencoded">' % ( declarations.pmt_info['db_name']) print '<TABLE BORDER=0>' print '<TR><TD><B>Username</B>:</TD><TD><input name="username" type="text" size="9" maxlength="9" value="%s"></TD></TR>' % ( username) print '<TR><TD><B>Current Password:</B></TD><TD><input name="current_password" type="password" size="8" maxlength="8" value="%s"></TD></TR>' % ( current_password) print '<TR><TD><B>New Password:</B></TD><TD><input name="new_password" type="password" size="8" maxlength="8" value="%s"></TD></TR>' % ( new_password) print '<TR><TD><B>Verify Password:</B></TD><TD><input name="verify_password" type="password" size="8" maxlength="8" value="%s"></TD></TR>' % ( verify_password) print '<TR><TD COLSPAN=2>' pmt_utils.alertsArea(form, alerts) print '</TD></TR>' print """</TABLE> <HR> <input name="submit" type="submit" value="Update Password"> <p align="right"><A HREF="mailto:[email protected]">Contact Support Team</a>""" print """</form>
def displayLogin(form,alert=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("cvsweb") pmt_utils.title("Development Library") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Development Library') pmt_utils.subHeading('Login') pmt_utils.formSetup("cvsweb", db_name, "cvsweb", "return submitForm(document.cvsweb)") pmt_utils.usernamePasswordDisplay() if alert!=None: pmt_utils.alertsArea(form, alert) print "<hr><INPUT TYPE='submit' NAME='submit' value='Submit' >"
def displayLogin(alert=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("upload") pmt_utils.title("Upload") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Upload') pmt_utils.subHeading('Login') pmt_utils.formSetup("upload",declarations.pmt_info['db_name'], "upload","return submitForm(document.upload)") pmt_utils.usernamePasswordDisplay() if alert!=None: pmt_utils.alertsArea(form,alert) print "<hr><INPUT TYPE='submit' NAME='submit' value='Submit' >" if form.has_key('dest'): print '<INPUT TYPE=hidden NAME=dest value="%s">' % form['dest'].value
def displayLogin(form, alert=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("list_docs") pmt_utils.title("Data Item Listing") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Data Item Listing') pmt_utils.subHeading('Login') java = "return submitForm(document.list_docs)" pmt_utils.formSetup("list_docs", db_name, "list_docs", java) pmt_utils.usernamePasswordDisplay() if alert != None: pmt_utils.alertsArea(form, alert) print "<hr><INPUT TYPE='submit' NAME='submit' value='Submit' >" if form.has_key('directory'): if string.find(form['directory'].value, '..') >= 0: sys.exit() print "<INPUT TYPE='hidden' NAME='directory' " print "value='%s'>" % form['directory'].value
def displayPriviledges(priv_data={},table_data={}): displayList=[] for key in table_data['priviledges'].keys(): if (not priv_data.has_key(key)) and (key!='member_username'): priv_data[key] = table_data['priviledges'][key]['default'] # Put everything in order by display_order field for i in xrange(0,len(table_data['priviledges'])): data={'key':'','label':'','priv':''} displayList.append(data) for key in priv_data.keys(): order=table_data['priviledges'][key]['display_order']-1 data={'key':key, 'label':table_data['priviledges'][key]['label'], 'priv':priv_data[key]} displayList[order]=data # List the provileges with Yes/No option menus print '<br><br>' pmt_utils.subHeading('User Priviledges') print "<br><table>" for i in xrange(0,len(displayList)): if displayList[i]['label']=='Username'\ or displayList[i]['label']=='': continue text=displayList[i]['label'] print '<tr><td ALIGN=LEFT NOWRAP>' print '<font FACE="Arial,Helvetica" COLOR=BLACK SIZE="-1">' print '%s:</font></td>' % text print '<td ALIGN=LEFT NOWRAP>' print '<font FACE="Arial,Helvetica" SIZE="-1">' print '<select NAME="%s" SIZE=1>' % displayList[i]['key'] if displayList[i]['priv']=='t': print '<option SELECTED>Yes' print '<option >No' else: print '<option >Yes' print '<option SELECTED>No' print '</select></font></td>' print "</table>"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------ pmt_utils.htmlContentType() form = pmt_utils.getFormData() db_name=declarations.pmt_info['db_name'] username,password=pmt_utils.getUserPass(form) print "<HTML>" print "<HEAD>" pmt_utils.title("Edit Project Options") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading("Project Option Manager") pmt_utils.subHeading("Add/Delete Options") if username!=None: dbResult=pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) if dbResult['status'] != 'success': message="Can not connect to database,\n" + dbResult['message'] pmt_utils.alertsArea(form,message) sys.exit() db=dbResult['result'] verifyUserPass(db)
def display_form(display_files=0,alerts=None): print "<HTML>" print "<HEAD>" pmt_utils.javaScript("doc_maintenance") pmt_utils.title("Documentation Maintenance") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Documentation Maintenance') pmt_utils.subHeading('Create and Delete Folders/Files') pmt_utils.formSetup("doc_maintenance",db_name,"doc_maintenance",None) dbResult=pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) if dbResult['status']!='success': exit(dbResult['message']) db=dbResult['result'] status,details = db_authentication.password_valid(db, crypt_salt=db_name, username=username, password=password) if status!='success': exit(details) if not pmt_utils.hasPriv(db,username,'folder_admin'): msg="User %s does not have folder maintenance priviledges" % username exit(msg) print '<hr><br><CENTER><B>Delete Folders/Files</B></CENTER>' stripped_db=string.lower(string.strip(db_name)) os.chdir(os.path.join('/home',stripped_db,'documents')) file_list = os_utils.walk_list_files( directory_name='.', list_only_files=0, exclude_list = [], include_file_type=1) if len(file_list) > 25: list_size = 25 else: list_size = len(file_list) print '<BLINK><B>WARNING:</B></BLINK><br>' print 'Any folders or files that you select for deletion are ' print 'permanently deleted. You should have a local backup of ' print 'any folders/files you delete in case you really did not mean ' print 'to delete. Backups are crucial. You have been warned.' print '<p>Selecting a folder will delete the folder and all files ' print 'under it including sub folders. ' print 'Select folder names with caution.' print '<p>Your deletes will not be confirmed. ' print 'When you press [Delete Folders/Files] your files are deleted.' print '<BR><CENTER><B>Select folders/files to delete</B>:<BR>' print '<SELECT NAME="files_to_remove" SIZE="8" MULTIPLE>' for curfile in file_list: print '<OPTION>%s' % (curfile) print "</SELECT><br>" java_call="return execute('delete_folder','1')" print '<input name="delete_folder" type="button" ' print 'value=" Delete Folders/Files " onClick="%s">' % java_call print '<input name ="website_name_hidden" ' print 'type="hidden" value="%s">' % (db_name) print "<hr><BR><BR>" print '<CENTER><B>Create Folder</B></CENTER><BR>' print '<B>Folder Name</B>: ' print '<input name="folder" type="text" size="50" maxlength="100"><BR>' java_call="return execute('create','1')" print '<input name="create" type="button" ' print 'value=" Create Folder " onClick="%s">' % java_call print '<input name ="website_name_hidden" ' print 'type="hidden" value="%s"><hr>' % (db_name) if alerts != None: pmt_utils.alertsArea(form,alerts) print '</CENTER>' pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'key_id', '1', '10', '10', None, None,'hidden') print '</form>' print '<p align="right">' print '<A HREF="mailto:[email protected]">Contact Support Team</a>' print "</body></html>"
def display_form(display_files=0, alerts=None): print "<HTML>" print "<HEAD>" pmt_utils.title("Site Maintenance (Clean)") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Site Maintenance') pmt_utils.subHeading('Clean') pmt_utils.formSetup("clean_site", declarations.pmt_info['db_name'], "clean_site", None) if not display_files: print '<TABLE BORDER=0><TR><TD><B>Username</B>:</TD><TD><input name="username" type="text" size="9" maxlength="9"></TD></TR><TR><TD><B>Password:</B></TD><TD><input name="password" type="password" size="8" maxlength="8"></TD></TR></TABLE>' if display_files: os.chdir( os.path.join( '/home', string.lower(string.strip(declarations.pmt_info['db_name'])), 'documents')) file_list = os_utils.walk_list_files(directory_name='.', list_only_files=0, exclude_list=[], include_file_type=1) if len(file_list) > 25: list_size = 25 else: list_size = len(file_list) print """ <CENTER> <TABLE BORDER=0> <CAPTION><BLINK><B>WARNING:<B></BLINK></CAPTION> <TR><TD WIDTH=300> Any files that you select for deletion are permanently deleted. You should have a local backup of any files you delete in case you really did not mean to delete. Backups are crucial. You have been warned. <p>Selecting a directory will delete the directory and all files under it including subdirectories. Select directory names with caution. <p>Your deletes will not be confirmed. When you press [Delete Selected Files] your files are deleted.</TD></TR></TABLE> """ print '<BR><CENTER><B>Select files to delete</B>:<BR><SELECT NAME="files_to_remove" SIZE="%d" MULTIPLE>' % ( list_size) for curfile in file_list: print '<OPTION>%s' % (curfile) print "</SELECT><BR>" if alerts != None: pmt_utils.alertsArea(form, alerts) print '</CENTER>' print """ <CENTER> <HR> """ if display_files: print '<input name="submit" type="submit" value="Delete Selected Files">' else: print '<input name="submit" type="submit" value="Login">' print '</CENTER>' if display_files: print '<input name ="website_name_hidden" type="hidden" value="%s">' % ( declarations.pmt_info['db_name']) print """
def edit_project_info(performDbQuery=0, onLoad=None, queryFields=None): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" pmt_utils.javaScript("project_admin") pmt_utils.title("Project Administration") print "</HEAD>" pmt_utils.bodySetup(onLoad) pmt_utils.mainHeading('Project Administration') pmt_utils.subHeading('Project Info') pmt_utils.formSetup("project_admin", db_name, "project_admin", "return submitForm(document.project_admin)") if username == None: pmt_utils.usernamePasswordDisplay() project_adminButtons(button_name='edit') pmt_utils.textbox(None, 'key_id', '1', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') print "</FORM>" try: pmt_utils.trailer(table_data, db) db.close() except NameError: pass print "</BODY>" print "</HTML>" return dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) # could not connect to db if dbResult['status'] != 'success': pmt_utils.alertsArea( form, "Can not connect to database,\n" + dbResult['message']) project_adminButtons() print "</FORM>" try: pmt_utils.trailer(table_data, db) db.close() except NameError: pass print "</BODY>" print "</HTML>" return db = dbResult['result'] status, details = db_authentication.password_valid(db, crypt_salt=db_name, username=username, password=password) if status != 'success': print '<form method=post action=/%s-cgi-bin/project_admin.pyc>' % db_name pmt_utils.usernamePasswordDisplay(username) pmt_utils.alertsArea(form, 'Can not verify you as a valid user') print '<hr><input name=reload type=submit value="Query">' print '<input name=action value=edit type=hidden>' print '</form>' sys.exit() if pmt_utils.hasPriv(db, username, 'project_data') != 1: print '<form method=post action=/%s-cgi-bin/project_admin.pyc>' % db_name pmt_utils.usernamePasswordDisplay(username) msg = 'User %s does not have project admin privileges>' % username pmt_utils.alertsArea(form, msg) print '<hr><input name=reload type=submit value="Query">' print '<input name=action value=edit type=hidden>' print '</form>' sys.exit() if form.has_key('key_id'): key_id = form['key_id'].value else: key_id = '1' sqlStatement = pmt_utils.selectAllColumnsSqlStatement( table_data, 'project_info', key_id) dbResult = pmt_utils.executeSQL(db, sqlStatement) if dbResult['status'] != 'success': msg = "Could not retrieve project information\n" + dbResult['message'] pmt_utils.alertsArea(form, msg) else: result = dbResult['result'] table_data = pmt_utils.dbToTableData(table_data, 'project_info', result[0]) table_data['project_info']['id']['value'] = '1' pmt_utils.display_form(table_data, 'project_info', 1, 'useValues', 1, db) pmt_utils.alertsArea(form, "Project Information retrieved successfully") project_adminButtons(button_name='save') pmt_utils.textbox(None, 'key_id', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') print "</FORM>" try: pmt_utils.trailer(table_data, db) db.close() except NameError: pass print "</BODY>" print "</HTML>"
def doEdit(): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" pmt_utils.generate_form_javascript(table_data, 'project_info', 'project_admin', 0) pmt_utils.title("Project Info Administration") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Project Info Administration') pmt_utils.subHeading('Edit Project Info') pmt_utils.formSetup("project_admin", db_name, "project_admin", "return submitForm(document.project_admin)") dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) if dbResult['status'] != 'success': msg = "Could not connect to the database\n" pmt_utils.alertsArea(form, msg + dbResult['message']) sys.exit() db = dbResult['result'] status, details = db_authentication.password_valid(db, crypt_salt=db_name, username=username, password=password) if status != 'success': print '<form method=post action=/%s-cgi-bin/project_admin.pyc>' % db_name pmt_utils.usernamePasswordDisplay(username) pmt_utils.alertsArea(form, 'Can not verify you as a valid user') print '<hr><input name=reload type=submit value="Query">' print '<input name=action value=edit type=hidden>' print '</form>' sys.exit() if pmt_utils.hasPriv(db, username, 'project_data') != 1: print '<form method=post action=/%s-cgi-bin/project_admin.pyc>' % db_name pmt_utils.usernamePasswordDisplay(username) msg = 'User %s does not have project admin privileges' % username pmt_utils.alertsArea(form, msg) print '<hr><input name=reload type=submit value="Query">' print '<input name=action value=edit type=hidden>' print '</form>' sys.exit() sqlStatement = pmt_utils.selectAllColumnsSqlStatement( table_data, 'project_info', '1') dbResult = pmt_utils.executeSQL(db, sqlStatement) if dbResult['status'] != 'success': msg = "Could not retrieve project info to edit\n" pmt_utils.alertsArea(form, msg + dbResult['message']) else: result = dbResult['result'] table_data = pmt_utils.dbToTableData(table_data, 'project_info', result[0]) table_data['project_info']['id']['value'] = '1' pmt_utils.display_form(table_data, 'project_info', 1, 'useValues', 1, db) pmt_utils.alertsArea(form, "Project Info retrieved successfully") project_adminButtons('save') pmt_utils.textbox(None, 'key_id', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') print "</FORM>" pmt_utils.trailer(table_data, db) db.close() print "</BODY>" print "</HTML>"
def doSave(): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" pmt_utils.generate_form_javascript(table_data, 'project_info', 'project_admin', 0) pmt_utils.title("Project Info Administration") print "</HEAD>" pmt_utils.bodySetup() pmt_utils.mainHeading('Project Info Administration') pmt_utils.subHeading('Edit Project Info') pmt_utils.formSetup("project_admin", db_name, "project_admin", "return submitForm(document.project_admin)") dbResult = pmt_utils.connectDB(declarations.pmt_info['browser_username'], declarations.pmt_info['browser_password'], declarations.pmt_info['db_name']) if dbResult['status'] != 'success': msg = "Project Info could not be saved, could not connect to db\n" pmt_utils.alertsArea(form, msg + dbResult['message']) # generate function button row project_adminButtons('save') # generate hidden fields for form pmt_utils.textbox(None, 'key_id', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') print "</FORM>" pmt_utils.trailer(table_data, db) db.close() print "</BODY>" print "</HTML>" return db = dbResult['result'] # save the Form dbResult = pmt_utils.saveForm(table_data, db, None, "project_info", " WHERE id = '1'", form) # if the form was not successfully saved if dbResult['status'] != 'success': msg = "Project Info could not be saved due to an error during save,\n" pmt_utils.alertsArea(form, msg + dbResult['message']) else: table_data = declarations.define_tables() table_data = pmt_utils.formToTableData(table_data, 'project_info', form) table_data['project_info']['id']['value'] = '1' pmt_utils.display_form(table_data, 'project_info', 1, 'useValues', 1, db) pmt_utils.alertsArea(form, "Project Info successfully saved") # generate function button row project_adminButtons('save') # generate hidden fields for form pmt_utils.textbox(None, 'key_id', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'action', '', '10', '10', None, None, 'hidden') pmt_utils.textbox(None, 'item_no', '', '8', '8', None, None, 'hidden') print "</FORM>" pmt_utils.trailer(table_data, db) db.close() print "</BODY>" print "</HTML>"
def display_form(): print "<html>" print "<head>" print "<title>Documentation Maintenance</title></head>" print '<body background="/%s/icons/circ_bg.jpg">' % (db_name) pmt_utils.mainHeading("Upload") pmt_utils.subHeading("Single File, Zip, or Tarfile upload:") print '<P><form action="/%s-cgi-bin/upload.pyc" method="POST" enctype="multipart/form-data">' % db_name print '<TABLE BORDER=0>' # display the name of the data item print "<TR><TD><B>Data Item Name</B>:</TD><TD>" pmt_utils.textbox(None, 'name', "", '40', '80', None, None) print "</TD></TR>" # display the version field print "<TR><TD><B>Version:</B></TD><TD>" pmt_utils.textbox(None, 'version', "", '40', '80', None, None) print "</TD></TR>" # display the description field print "<TR><TD><B>Description:</B></TD><TD>" pmt_utils.textarea(None, 'description', "", '5', '40', None, None) print "</TD></TR>" print '<TR><TD><B>Filename</B>:</TD>' print '<TD><input name="archive" type="file" size="40" maxlength="100"></TD></TR>' if form.has_key('dest'): dest=form['dest'].value else: dest='' print '<TR><TD><B>Destination Folder</B>:</TD><TD>' print '<input name="folder" type="text" size="40" maxlength="100" value="%s">' % dest print '</TD></TR></TABLE>' print '<input name="permissions" type="checkbox" value="permissions">' print 'Set file permissions after upload<BR>' print '<input name="extract" type="checkbox" value="extract">' print 'Extract archive on server<BR>' print '<input name="submit" type="submit" value="Upload File">' print '</form>' print '<HR>' print '<H3>Introduction</H3>' print '<P>This maintenance function will allow authorized users to upload a single file or file archive to their website. The tar file may be compressed with gzip. The archive file size when extracted should not' print 'exceed your maximum allowable disk space allotment for your site which is %d MB (%d bytes). If this happens all files that exceed the allotment will not be stored in your website. It is therefore suggested that you maintain a complete copy of your site locally and change your local copy to how you would like it on www.isrparc.org, create the archive of your local copy and upload the archive to www.isrparc.org. The archive filename should end with .zip, .tar.gz, or .tgz</P>' % (upload_ceiling/(1024*1024),upload_ceiling) print '<P>You may upgrade your disk space allotment via an e-mail request to the www.isrparc.org <A HREF="mailto:[email protected]">support team</A>.</P>' print '<H3>Directions for Uploading Archives</H3>' print '<P>You may upload a winzip, gzip, or tar file to your website.' # print 'The contents of the archive should match the following directory tree structure, in other words the directories listed below should be the top level directories when the archive is created.</P>' print '<P>All files including files in zip and tar archive should not have spaces in their name.</P>' print '<P>Filenames can have mixed case and are not governed by an 8.3 filename name specification.' # print '<P>If the file you are uploading is not a zip or tar archive, the file will be placed in the documents directory for the website you specify.' # print '<P>Allowable subdirectories in your archive file</P>' # print '<UL>' # print '<LI>documents' # print '</UL>' # print '<P>NOTE: Do <b>NOT</B> put a subdirectory called cgi-bin in your archive file. This can damage the Documentation Management engine at your website, if installed.</P>' # print '<P>Example (Windows 9x Systems at MS-DOS prompt):</p>' # print 'cd C:\<BR>' # print 'mkdir website<BR>' # print 'cd C:\website<BR>' # print 'mkdir documents<BR>' # print '<P>Put all of your document files: MS Word, Excel, Power Point, Adobe Acrobat, ASCII text under the documents directory' # print '<p>zip all files under c:\website directory but do not zip the directory c:\website</p>' # print '<P>If your archive has other directories in it besides the above mentioned names, these directories will not be accessed by the www.isrparc.org server and will be merely wasting your websites disk space allotment. This Site Maintenance Upload program does not check the integrity of your archive file so it is imperative that you specify your archive as mentioned above. Future updates will verify the contents of the archive file you are uploading.</P>' print '<p align="right"><A HREF="mailto:[email protected]">Contact Support Team</a>' print '</body>' print '</html>'