I am initially seeking guidance to make sure I go in the right direction. From there I will come back with the code and ask for further assistance. I realize it isn't cool to say "hey I dont know what I am doing so I want you to do it for me."
我最初寻求指导,以确保我的方向是正确的。从那里我将带着代码回来并请求进一步的帮助。我意识到说“嘿,我不知道我在做什么,所以我想让你帮我做。”
So, here is my situation. I would say my php skills are amateur, and I am looking to increase them by working on projects for myself so I can learn through practice and application. I have created a webpage which contains a form that is used to update a XML file (I am playing around with flatfile DBs at the moment). All works well, the file is updated and the users is brought back to the page and the updated file is displayed. What I would like to do is allow the user to receive an update while they are browsing the website that the XML file has been updated, as well as alert them to the file update if they are returning to the website after having left.
这是我的情况。我想说我的php技能是业余的,我希望通过自己的项目来增加这些技能,以便通过实践和应用来学习。我创建了一个网页,其中包含一个用于更新XML文件的表单(目前我正在使用flatfile DBs)。所有的工作都很好,文件被更新,用户被带回到页面并显示更新的文件。我想做的是,允许用户在浏览XML文件已更新的网站时接收更新,并在用户离开后返回网站时提醒他们文件更新。
My thoughts are that this would be done by using php session variables, one when they first access the website and another when the XML file is updated by a user. For the one when they access the site I thought a variable with a unique ID and timestamp as well as a timestamp of the files lastmodified value. I realize that this requires keeping storage of the session values since the value will have to be compared to something or else it will always appear as the most recent version, hence no changes.
我的想法是,这将通过使用php会话变量来完成,当用户第一次访问该网站时,以及当用户更新XML文件时,会使用另一个变量。当他们访问站点时,我认为一个变量具有唯一的ID和时间戳以及文件lastmodified值的时间戳。我意识到这需要保持会话值的存储,因为这个值必须与某个值进行比较,否则它将始终作为最新的版本出现,因此没有更改。
Now that I think about it I guess you wouldn't need a session variable created on file update since the comparison will be based on the lastmodified value.
现在我考虑了一下,我猜您不需要在文件更新时创建会话变量,因为比较将基于lastmodified值。
Just want to know if I am on the right track or completely off-base.
只是想知道我是在正确的轨道上还是完全偏离了目标。
Any input is greatly appreciated.
非常感谢您的投入。
1 个解决方案
#1
0
Storing the lastModfided value
For your specific case I hope i understood you right. You want to say "notify the user if he wasn't the last one to work on the file" right?
对于你的具体情况,我希望我理解对了。你想说"通知用户如果他不是最后一个处理文件的人"对吗?
That should be easily doable using the session as after writing you could store the last modified date of the file in the session and them compair that when the user comes back. I don't see any issues with that approach.
这应该很容易实现,因为在编写会话之后,您可以将文件的最后修改日期存储在会话中,并且当用户返回时,它们会压缩该日期。我不认为这种方法有什么问题。
If you have you users log in I'd much rather tie the notification to their accounts.
如果你有你的用户登录,我宁愿把通知绑定到他们的账户上。
Your session files will be deleted if the user is way for to long and a new one will be created if he uses a different browser. So it would be a really instable way of giving notice.
如果用户的会话文件太长,将被删除;如果用户使用不同的浏览器,将创建一个新的会话文件。这是一种非常不稳定的通知方式。
For the notifications no matter where he is on the site
If your database is updated in the background and you then could like to create a notification for the user I'd advice again using the php session for that.
如果你的数据库是在后台更新的,然后你可以为用户创建一个通知,我建议你再次使用php会话。
While you are able (using some rather ugly hacks) to edit the session files they are not a stable enough basis to implement a notification system.
虽然您可以(使用一些相当丑陋的技巧)编辑会话文件,但是它们并不是实现通知系统的足够稳定的基础。
If you just work of session cookies then I'd still just store a "notify this session id if the guy shows up again" somewhere and check those notifications on every page load.
如果你只处理会话cookie,那么我还是会在某个地方存储一个“如果那个家伙再次出现就通知这个会话id”,并在每个页面加载时检查这些通知。
I know this is not as performant/nice/cool but it shouldn't really matter and save you a lot time dealing with.
我知道这不是表演/好/酷,但它不应该真的重要,并为你节省很多时间处理。
Hope i understood you right and it makes sense to youu
希望我对你的理解是对的,这对你有意义
#1
0
Storing the lastModfided value
For your specific case I hope i understood you right. You want to say "notify the user if he wasn't the last one to work on the file" right?
对于你的具体情况,我希望我理解对了。你想说"通知用户如果他不是最后一个处理文件的人"对吗?
That should be easily doable using the session as after writing you could store the last modified date of the file in the session and them compair that when the user comes back. I don't see any issues with that approach.
这应该很容易实现,因为在编写会话之后,您可以将文件的最后修改日期存储在会话中,并且当用户返回时,它们会压缩该日期。我不认为这种方法有什么问题。
If you have you users log in I'd much rather tie the notification to their accounts.
如果你有你的用户登录,我宁愿把通知绑定到他们的账户上。
Your session files will be deleted if the user is way for to long and a new one will be created if he uses a different browser. So it would be a really instable way of giving notice.
如果用户的会话文件太长,将被删除;如果用户使用不同的浏览器,将创建一个新的会话文件。这是一种非常不稳定的通知方式。
For the notifications no matter where he is on the site
If your database is updated in the background and you then could like to create a notification for the user I'd advice again using the php session for that.
如果你的数据库是在后台更新的,然后你可以为用户创建一个通知,我建议你再次使用php会话。
While you are able (using some rather ugly hacks) to edit the session files they are not a stable enough basis to implement a notification system.
虽然您可以(使用一些相当丑陋的技巧)编辑会话文件,但是它们并不是实现通知系统的足够稳定的基础。
If you just work of session cookies then I'd still just store a "notify this session id if the guy shows up again" somewhere and check those notifications on every page load.
如果你只处理会话cookie,那么我还是会在某个地方存储一个“如果那个家伙再次出现就通知这个会话id”,并在每个页面加载时检查这些通知。
I know this is not as performant/nice/cool but it shouldn't really matter and save you a lot time dealing with.
我知道这不是表演/好/酷,但它不应该真的重要,并为你节省很多时间处理。
Hope i understood you right and it makes sense to youu
希望我对你的理解是对的,这对你有意义