Help with locking mechanism via web page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Help with locking mechanism via web page

Post by Nemesis »

Hello, I need a little help.

My Web Services system has an applet running in the background, but I cannot assume that everyone will have Java enabled.

I need a reliable way to implement a locking mechanism (which will consist of calling lock and unlock functions of my middleware layer).

I am not very experienced in PHP, and I need to do this on the page level. I cannot use sessions, because I need only to lock on certain specific pages, to allow maximum availability of the system from multiple users.

Can anyone suggest a way for me to accomplish this?

Thank you,
Nemesis.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

how are these pages built? Some architecture details would be quite helpful.
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Post by Nemesis »

They are built in a non-OO old-school PHP way.

Every PHP file represents one or a few web pages, depending on variables etc.

If this was a project that I had built myself, I would be ashamed :P
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

okay... and the lock needs to always be on with these specific pages? If so, then you can directly add the locks to those scripts, or based on the inputs passed.. simple if's for the latter.
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Post by Nemesis »

Yes, this is a solution that I had hoped would work.....sorry if I was not specific enough,

The problem is that I need to call an unlock function if the user navigated to an unlocked page.

So I need a way to call a function when the page is changed, when the page is closed, when the browser is closed, etc.

And this needs to be reliable, otherwise I will end up with eternally locked objects (until I unlock them manually :P)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

okay. database sessions are the direction to go. Is this lock system wide? It would appear so. If you can change it to a friendly session level lock or request based lock it would probably be easier and more reliable to implement. You'll need sessions to know if they have navigated away/closed the browser after a period of inactivity.

When the database session is removed, the last page they were on should be checked against the lock list and call unlock when needed.. or better yet just always call unlock.
Nemesis
Forum Newbie
Posts: 12
Joined: Tue Feb 08, 2005 10:43 am

Post by Nemesis »

Sorry, I dont know what a Database session is.

Furthermore, there are no databases accessible from the Web page. These are back end things, and the Web never has database connectivity.
Post Reply