Главная страница Случайная страница КАТЕГОРИИ: АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника |
Web Page EditorThis program is a variation on the simple text editor above, which allows you to edit HTML files (or any other text files) on your web server: ! Set a flag variable to determine if the user has entered FTP login info: flag = 0! Mark a point in the code to repeat back to later: start:! If this is the first time running the program loop, set some default! FTP values: if flag = 0 startsite$ = " ftp.site.com" startfolder$ = " /public_html/" startusername$ = " user" startpassword$ = " pass" endif! Request FTP value, using either the default values above, or the values! entered by the user on a previous loop through the code: input " FTP URL", site$, startsite$input " File Path", folder$, startfolder$input " User Name", username$, startusername$input " Password", password$, startpassword$! Set the flag variable to indicate that FTP values have been entered by! the user, and save those values for later: flag = 1startsite$ = site$startfolder$ = folder$startusername$ = username$startpassword$ = password$! Open the FTP connection, and download the names of the files in the! selected directory: ftp.open site$, 21, username$, password$ftp.dir filelist! Add a choice to the list of file names, to create a new file: list.add filelist, " New File..."! Allow the user to select a file: select indx, filelist, " Select a file: " list.get filelist, indx, file$! If the user selected " New File...", allow them to enter the name of the! new file to be created on the server, and then empty the contents of the! local temp file. If the user selected the name of an existing file,! save the contents of that file to the local temp file (" temp.txt"): if file$ = " New File..." input " File Name: ", file$, " file.html" Text.open w, tempfile, " temp.txt" Text.writeln tempfile, " " Text.close tempfileelse ftp.get file$, " temp.txt" endif! Read the contents of the temp file in the variable " unedited": grabfile unedited$, " temp.txt"! Allow the user to edit the above text, and save the edited text in the! variable " edited$": text.input edited$, unedited$! Save the edited text to the temp file: text.open w, filename, " temp.txt" text.writeln filename, edited$text.close filename! Upload to the contents of the temp file back to the web server, and! alert the user when done: ftp.put " temp.txt", file$ftp.closepopup " Saved", 0, 0, 1! Run the whole program again: goto startHere's the whole program, without comments: flag = 0start: if flag = 0 startsite$ = " ftp.site.com" startfolder$ = " /public_html/" startusername$ = " user" startpassword$ = " pass" endif input " FTP URL", site$, startsite$ input " File Path", folder$, startfolder$ input " User Name", username$, startusername$ input " Password", password$, startpassword$ flag = 1 startsite$ = site$ startfolder$ = folder$ startusername$ = username$ startpassword$ = password$ ftp.open site$, 21, username$, password$ ftp.dir filelist list.add filelist, " New File..." select indx, filelist, " Select a file: " list.get filelist, indx, file$ if file$ = " New File..." input " File Name: ", file$, " file.html" Text.open w, tempfile, " temp.txt" Text.writeln tempfile, " " Text.close tempfile else ftp.get file$, " temp.txt" endif grabfile unedited$, " temp.txt" text.input edited$, unedited$ text.open w, filename, " temp.txt" text.writeln filename, edited$ text.close filename ftp.put " temp.txt", file$ ftp.close popup " Saved", 0, 0, 1goto startДанная страница нарушает авторские права? |