如何构建我的 Perl CGI 程序?

发布于 2024-08-09 00:39:07 字数 617 浏览 3 评论 0原文

我们刚刚在计算机科学课上完成了第一个主要的 Perl CGI 作业。我们的任务是创建一个 mp3 共享站点,允许用户创建帐户、登录、共享 mp3。必须显示当前用户的统计信息、可用的 mp3 等。所有操作都必须写入日志文件。我们的代码必须是安全的。

到目前为止,我已经将每个操作单独实现为它们自己的 CGI 脚本。例如,我有一个绘制登录表单、注册表单的脚本,一个允许 mp3 上传的脚本,以及另一个执行 mp3 服务的脚本。我还创建了一个模块,每当我调用它的实例时,它都会将相关信息发布到日志文件中。然而,每个脚本都是单独的,但登录屏幕除外,它绘制一个表单,然后发布到一个login.cgi。帐户生成的工作原理相同。但是,在大多数情况下,每个人都单独行动。

我的问题: 如何将其链接在一起,以便除非用户登录,否则不允许执行任何操作?我假设我应该使用登录脚本(接收后操作的脚本)来驱动所有内容,但我该怎么做呢?我在这里真的很茫然。我想让用户登录,绘制一个带有选项的主页(添加 mp3、收听 mp3、显示统计数据等)。我最好绘制某种形式并将操作设置为不同的脚本吗?我如何处理这些脚本的返回? cookie 会以某种方式提供帮助吗?

其他相关信息: 到目前为止,我已经使用该网站上的 ovid 教程和 Lincoln Stein 的书在 CGI.pm 上完成了大部分工作。

We just got our first major Perl CGI assignment in my CS class. Our task is to create an mp3 sharing site that allows users to create accounts, log in, share mp3's. Statistics must be shown of current users, mp3's available, etc. All actions must be written to a log file. Our code must be secure.

So far, I have implemented each of these actions separately as their own CGI scripts. For instance, I have a script that draws the login form, the registration form, a script that allows for mp3 uploads, and another that does the mp3 serving. I've also created a module that posts relevant information to a log file whenever I call an instance of it. However, each script is individual, with the exception of the Login screen, which draws a form and then posts to a login.cgi. The account generation works the same. But, for the most part, each acts on its own.

My question:
How do I link this together so that no action is allowed unless the user is logged in? I assume that I should use the login script (the one that receives the post action) to drive everything, but how do I do it? I'm really at a loss here. I would like to have a user log in, a homepage is drawn with options (add mp3, listen mp3, show staistics, etc.) Is it best that I draw some sort of form and with actions set to the different scripts? How do I handle the return from these scripts? Would cookies help in some way?

Other relevant information:
I've done most of my work so far in CGI.pm using the ovid tutorial found on this site and Lincoln Stein's book.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

叶落知秋 2024-08-16 00:39:07

您想要实现的通常称为“会话管理”。

请查看此处 (how-can-i-add-session-management-to-a-simple-perl-cgi-web-page)对于之前的SO问题

您可能还想查看这些页面以获取一些背景知识。

What you want to implement is gererally called "session management".

look here (how-can-i-add-session-management-to-a-simple-perl-cgi-web-page) for a previous SO question

You might want to also look at these pages to get some background.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文