Студопедия

Главная страница Случайная страница

КАТЕГОРИИ:

АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника






Blogger




This program is another FTP example that allows users to create and add entries to an online blog page. The user enters a title, blog text, and a daily URL link of interest. The program determines the current date and time. All of those pieces of text are concatenated together, along with the necessary HTML layout code, and appended to a downloaded copy of the previous blog content. That code is then uploaded back to the user's web server to be viewed publicly. Be sure to edit the FTP and HTML URL variables so they represent actual user account information.

! Store the FTP account address, folder/filename, username and password! in variables (for easy configuration): input " FTP URL", site$, " ftpsite.com" input " Folder", folder$, "./public_html/" input " Filename", page$, " blog.html" input " User Name", username$, " user" input " Password", password$, " pass" input " HTTP URL", url$, " https://site.com/blog.html"! This portion of code checks to see if the page$ file already exists! on the server: ftp.open site$, 21, username$, password$ftp.cd folder$exists = 0ftp.dir fileslist.size files, sfor i = 1 to s list.get files, i, file$ if file$ = page$ then exists = 1next i! If the file doesn't exist, create it: if exists = 0 console.save " temp.txt" ftp.put " temp.txt", page$ popup " New file created", 0, 0, 0endif! Get a blog title, URL, and some blog text from the user. Store that! text in the variables blogtitle$ and blogtext$: input " Blog Title: ", blogtitle$, " Title" input " URL: ", blogurl$, " https://site.com" text.input blogtext$, " Check out today's link! "! Get the current date and time: time y$, m$, d$, h$, n$, s$! Concatenate the text entered above, and the date/time, with the HTML! code required to display the blog entry. Save the constructed HTML! in the variable newblog$. Notice the use of the underscore! character to continue the string concatenation onto multiple lines: newblog$ = " < h1> " + blogtitle$ + " < /h1> " + " Blog entry created: " + ~ m$ + " -" + d$ + " -" + y$ + " & nbsp; & nbsp; " + h$ + ": " + n$ + ~ ": " + s$ + " < br> < br> < a href=\" " + blogurl$ + " \" > " + blogurl$ + ~ " < /a> < br> < br> " + " < center> < table width=80%> < tr> < td> < pre> < strong> " + ~ blogtext$ + " < /strong> < /pre> < /td> < /tr> < /table> < /center> < br> < hr> "! Download the existing full HTML blog. Save it in the file temp.txt: ftp.get page$, " temp.txt"! Load the downloaded blog text into the variable previousblog$: grabfile previousblog$, " temp.txt"! Write the concatenated new and old blog text to the file temp.txt: text.open w, filename, " temp.txt" text.writeln filename, newblog$ + previousblog$text.close filename! Upload the updated blog file to the web server: ftp.put " temp.txt", page$ftp.close! Alert the user with a message, then open the blog in the browser: popup " Saved", 0, 0, 1browse url$

Here's the full program without comments:

input " FTP URL", site$, " ftpsite.com" input " Folder", folder$, "./public_html/" input " Filename", page$, " blog.html" input " User Name", username$, " user" input " Password", password$, " pass" input " HTTP URL", url$, " https://site.com/blog.html" ftp.open site$, 21, username$, password$ftp.cd folder$exists = 0ftp.dir fileslist.size files, sfor i = 1 to s list.get files, i, file$ if file$ = page$ then exists = 1next iif exists = 0 console.save " temp.txt" ftp.put " temp.txt", page$ popup " New file created", 0, 0, 0endifinput " Blog Title: ", blogtitle$, " Title" input " URL: ", blogurl$, " https://site.com" text.input blogtext$, " Check out today's link! " time y$, m$, d$, h$, n$, s$newblog$ = " < h1> " + blogtitle$ + " < /h1> " + " Blog entry created: " + ~ m$ + " -" + d$ + " -" + y$ + " & nbsp; & nbsp; " + h$ + ": " + n$ + ~ ": " + s$ + " < br> < br> < a href=\" " + blogurl$ + " \" > " + blogurl$ + ~ " < /a> < br> < br> " + " < center> < table width=80%> < tr> < td> < pre> < strong> " + ~ blogtext$ + " < /strong> < /pre> < /td> < /tr> < /table> < /center> < br> < hr> " ftp.get page$, " temp.txt" grabfile previousblog$, " temp.txt" text.open w, filename, " temp.txt" text.writeln filename, newblog$ + previousblog$text.close filenameftp.put " temp.txt", page$ftp.closepopup " Saved", 0, 0, 1browse url$

Данная страница нарушает авторские права?


mylektsii.su - Мои Лекции - 2015-2024 год. (0.007 сек.)Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав Пожаловаться на материал