hi,all
最近在做一个评论预发布功能,需求大概是说,我后台可以针对谋篇文章录入评论,但这些评论不会马上显示出来,需要按照设定的某个时间点出现在前台(这里指的是手机端的app)。
这里有几个背景:1、文章表有评论数量字段,2、评论的时候会有消息推送到app。
我之前的做法是在评论表里面分别加入effect_begin字段,然后在拉取评论列表的时候加多一个时间判断。但这样,就会无法更新评论数量字段和推送消息。
我想到的另外一种方法是,再做一个评论预备状态的表,然后写个定时脚本,定期把预备状态的数据写入评论表,这个时候再去触发更新评论数量和推送用户消息,只是不知道这样时候合适,感觉有点重...
不知道有没有更好的方案?
回复内容:
hi,all
最近在做一个评论预发布功能,需求大概是说,我后台可以针对谋篇文章录入评论,但这些评论不会马上显示出来,需要按照设定的某个时间点出现在前台(这里指的是手机端的app)。
这里有几个背景:1、文章表有评论数量字段,2、评论的时候会有消息推送到app。
我之前的做法是在评论表里面分别加入effect_begin字段,然后在拉取评论列表的时候加多一个时间判断。但这样,就会无法更新评论数量字段和推送消息。
我想到的另外一种方法是,再做一个评论预备状态的表,然后写个定时脚本,定期把预备状态的数据写入评论表,这个时候再去触发更新评论数量和推送用户消息,只是不知道这样时候合适,感觉有点重...
不知道有没有更好的方案?
看你的问题有点晕晕的,预发布不就直接设置评论的发布时间为将来时,显示评论的时候显示小于当前时间的评论不就可以了么?如果要做push的的话也很简单啊,设置一个定时任务将未push且评论时间小于当前时间的评论都push出来成功就修改push字段为真,失败则还是老样子。

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

Setting the httponly flag is crucial for session cookies because it can effectively prevent XSS attacks and protect user session information. Specifically, 1) the httponly flag prevents JavaScript from accessing cookies, 2) the flag can be set through setcookies and make_response in PHP and Flask, 3) Although it cannot be prevented from all attacks, it should be part of the overall security policy.

PHPsessionssolvetheproblemofmaintainingstateacrossmultipleHTTPrequestsbystoringdataontheserverandassociatingitwithauniquesessionID.1)Theystoredataserver-side,typicallyinfilesordatabases,anduseasessionIDstoredinacookietoretrievedata.2)Sessionsenhances

PHPsessionscanstorestrings,numbers,arrays,andobjects.1.Strings:textdatalikeusernames.2.Numbers:integersorfloatsforcounters.3.Arrays:listslikeshoppingcarts.4.Objects:complexstructuresthatareserialized.

TostartaPHPsession,usesession_start()atthescript'sbeginning.1)Placeitbeforeanyoutputtosetthesessioncookie.2)Usesessionsforuserdatalikeloginstatusorshoppingcarts.3)RegeneratesessionIDstopreventfixationattacks.4)Considerusingadatabaseforsessionstoragei

Session regeneration refers to generating a new session ID and invalidating the old ID when the user performs sensitive operations in case of session fixed attacks. The implementation steps include: 1. Detect sensitive operations, 2. Generate new session ID, 3. Destroy old session ID, 4. Update user-side session information.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)
