当前位置: 首页 > news >正文

建网站 网站内容怎么做济南平台公司

建网站 网站内容怎么做,济南平台公司,网站设置仅某浏览器,东山县建设银行网站目录 1. 基础准备必备工具#xff1a; 2. 目录结构3. 用户登录#xff08;使用简单的文件系统管理#xff09;4. 富文本编辑器和展示5. 样式文件6. 配置 Web 服务器7. 运行和测试 构建一个简单的 Web 站点实现富文本写入和展示、用户登录以及文本目录划分需要结合多个技术 2. 目录结构3. 用户登录使用简单的文件系统管理4. 富文本编辑器和展示5. 样式文件6. 配置 Web 服务器7. 运行和测试 构建一个简单的 Web 站点实现富文本写入和展示、用户登录以及文本目录划分需要结合多个技术包括 C 语言的 CGICommon Gateway Interface、HTML、JavaScript 和 CSS 以及一个简单的文件系统管理。下面是一个基本的实现步骤和示例代码。 1. 基础准备 必备工具 一个 Web 服务器例如 Apache 或 Nginx支持 CGI。HTML、CSS 和 JavaScript 基础知识。C 语言编译器例如 gcc。 2. 目录结构 /var/www/cgi-bin/ # 放置 CGI 脚本 /var/www/html/ # 放置 HTML 文件 /var/www/html/css/ # 放置 CSS 文件 /var/www/html/js/ # 放置 JavaScript 文件3. 用户登录使用简单的文件系统管理 login.html放在 /var/www/html/ 中 !DOCTYPE html html langen headmeta charsetUTF-8titleUser Login/titlelink relstylesheet hrefcss/style.css /head bodyform action/cgi-bin/login.cgi methodpostlabel forusernameUsername:/labelinput typetext idusername nameusername requiredlabel forpasswordPassword:/labelinput typepassword idpassword namepassword requiredbutton typesubmitLogin/button/form /body /htmllogin.cgi放在 /var/www/cgi-bin/ 中 #include stdio.h #include stdlib.h #include string.hvoid get_post_data(char *data) {char *lenstr;long len;lenstr getenv(CONTENT_LENGTH);if(lenstr NULL || sscanf(lenstr,%ld,len)!1 || len1024) {printf(Content-type:text/html\n\n);printf(htmlbodyInvalid POST data/body/html);exit(1);}fgets(data, len1, stdin); }int main() {char data[1024];char username[100], password[100];get_post_data(data);sscanf(data, username%99[^]password%99s, username, password);// 简单的用户名密码验证 (应替换为更安全的方法)if(strcmp(username, admin) 0 strcmp(password, password) 0) {printf(Content-type:text/html\n\n);printf(htmlbodyLogin successful!bra href\editor.html\Go to Editor/a/body/html);} else {printf(Content-type:text/html\n\n);printf(htmlbodyInvalid credentials. a href\/login.html\Try again/a/body/html);}return 0; }4. 富文本编辑器和展示 editor.html放在 /var/www/html/ 中 !DOCTYPE html html langen headmeta charsetUTF-8titleRich Text Editor/titlelink relstylesheet hrefcss/style.cssscript srcjs/editor.js/script /head bodyform action/cgi-bin/save_text.cgi methodposttextarea ideditor nameeditor rows10 cols80/textareabutton typesubmitSave/button/formdivh2Text Directory/h2ul iddirectory/ul/div /body /htmleditor.js放在 /var/www/html/js/ 中 document.addEventListener(DOMContentLoaded, function() {const directory document.getElementById(directory);// Fetch directory contentsfetch(/cgi-bin/list_texts.cgi).then(response response.json()).then(data {data.forEach(file {let li document.createElement(li);let a document.createElement(a);a.href /cgi-bin/display_text.cgi?file${file};a.innerText file;li.appendChild(a);directory.appendChild(li);});}); });save_text.cgi放在 /var/www/cgi-bin/ 中 #include stdio.h #include stdlib.h #include string.hvoid get_post_data(char *data) {char *lenstr;long len;lenstr getenv(CONTENT_LENGTH);if(lenstr NULL || sscanf(lenstr,%ld,len)!1 || len8192) {printf(Content-type:text/html\n\n);printf(htmlbodyInvalid POST data/body/html);exit(1);}fgets(data, len1, stdin); }void save_to_file(const char *filename, const char *data) {FILE *file fopen(filename, w);if(file NULL) {printf(Content-type:text/html\n\n);printf(htmlbodyCould not save file./body/html);exit(1);}fprintf(file, %s, data);fclose(file); }int main() {char data[8192];get_post_data(data);// Saving the data to a file (simple naming, should be more secure)save_to_file(/var/www/texts/saved_text.html, data);printf(Content-type:text/html\n\n);printf(htmlbodyText saved! a href\editor.html\Back to Editor/a/body/html);return 0; }list_texts.cgi放在 /var/www/cgi-bin/ 中 #include stdio.h #include stdlib.h #include dirent.h #include string.hint main() {DIR *d;struct dirent *dir;char result[8192] [;d opendir(/var/www/texts/);if(d) {while((dir readdir(d)) ! NULL) {if(dir-d_type DT_REG) {strcat(result, \);strcat(result, dir-d_name);strcat(result, \,);}}closedir(d);if(result[strlen(result) - 1] ,) {result[strlen(result) - 1] \0;}}strcat(result, ]);printf(Content-type: application/json\n\n);printf(%s, result);return 0; }display_text.cgi放在 /var/www/cgi-bin/ 中 #include stdio.h #include stdlib.h #include string.hvoid display_file(const char *filename) {FILE *file fopen(filename, r);if(file NULL) {printf(Content-type:text/html\n\n);printf(htmlbodyCould not open file./body/html);exit(1);}printf(Content-type:text/html\n\n);printf(htmlbody);char ch;while((ch fgetc(file)) ! EOF) {putchar(ch);}printf(/body/html);fclose(file); }int main(int argc, char *argv[]) {char *query_string getenv(QUERY_STRING);char filename[256];if(query_string NULL || sscanf(query_string, file%255s, filename) ! 1) {printf(Content-type:text/html\n\n);printf(htmlbodyInvalid file request./body/html);exit(1);}char filepath[512];snprintf(filepath, sizeof(filepath), /var/www/texts/%s, filename);display_file(filepath);return 0; }5. 样式文件 style.css放在 /var/www/html/css/ 中 body {font-family: Arial, sans-serif;margin: 20px; }form {margin-bottom: 20px; }textarea {width: 100%;height: 200px; }button {padding: 10px 20px;background-color: #4CAF50;color: white;border: none;cursor: pointer; }button:hover {background-color: #45a049; }6. 配置 Web 服务器 确保你的 Web 服务器配置正确并支持 CGI 脚本。例如如果你使用 Apache确保 httpd.conf 中有如下配置 ScriptAlias /cgi-bin/ /var/www/cgi-bin/ Directory /var/www/cgi-binAllowOverride NoneOptions ExecCGIAddHandler cgi-script .cgi .pl .pyRequire all granted /Directory7. 运行和测试 将所有文件放在对应的目录中。访问 http://yourserver/login.html 进行用户登录。成功登录后访问富文本编辑器进行内容输入和保存。确保你有 /var/www /texts/ 目录用来保存文本文件并具有写权限。 这只是一个基础的示例实际应用中需要考虑更多安全性和功能性方面的细节。
http://www.zqtcl.cn/news/172053/

相关文章:

  • 旅游网站建设策划seo顾问多少钱
  • 个人网站注册平台要多少钱彩票网站开发 违法
  • 贵州城乡住房和建设厅网站易企秀网站开发语言
  • 返利网站做鹊桥推广免费的舆情网站入口在哪
  • 网站商城怎么做wordpress图片采集插件
  • 做美团网站代码swoole+wordpress
  • 百度免费资源网站搭建发卡网站要多少钱
  • ip网站怎么做酷家乐手机版
  • cnzz统计代码如何添加到网站上去照片网站源码
  • 我的世界电影怎么做的视频网站网页布局实训心得体会
  • 网站建设公司内部情况凡客诚品陈年
  • 浙江建设职业技术学院迎新网站商务网站建设体会
  • 做网站的目的与意义做家教去什么网站
  • 相城网站建设为什么网站建设价格不一
  • 网站icp备案手续我做的网站平台百度搜不到
  • 本溪网站设计公司ps转页面wordpress插件
  • 怎么做短链接网站搜索引擎优化的各种方法
  • 自己做网站怎么挣钱微网站建站系统源码
  • 湖北省网站备案最快几天网站建设存在的具体问题
  • 网站建设算固定资产吗做网站都需要什么软件
  • ui设计培训是什么seo外链网站源码
  • 网站开发浙里建系统平台
  • 建设电影网站的关键国内新闻最新消息2022
  • wordpress 卢晓松玉林做网站优化推广
  • 做户外运动的网站seo内部优化方案
  • 哪个行业必须做网站软件工程最好的出路
  • 安徽省质量提升工程建设网站深圳十大国际外贸公司
  • 县城做信息网站qq是哪个公司
  • 设计师作品展示网站做图软件官方网站
  • 企业网站网站建设价格seo短视频网页入口引流