I´m currently working on a big project with is based on php and its connected to a mysql database. I wanna track the actions the clients are doing in a file. If they login I wanna log who is logging in. I wanna log when someone is adding data with a submit button to the db and who is adding the data.
Does someone of you have a example how he did it, or have an idea how to do that?
I hope you understand what I mean :)
Best regards
There are already libraries that can do it for you. One of them is Monolog. Follow doc in README in order to set it up in your project.
Related
I’m using CI 2.1.4 and I set
$config['sess_expiration'] = 0;
but sometime when I’m in my dashboard I’m unlogged automaticaly by the site…
The context is the following :
I’m using 2 applications for 1 system, but both applications use the same encryption key, session table and the same timeout.
This problem appear when I submit a form then after I pick up session data to add it in the database.
Anyone has an idea ?
Thanks.
I think you have 2 ways to fix it.
First, you should download latest code from github and replace session library folder with downloaded code.
Second, you can extends the session library and check for AJAX request, then update the session as you can see this following discussion about this problem in CodeIgniter Official Forum, it explains to get rid of the problem: http://ellislab.com/forums/viewthread/138823/
Note: The forum location has changed http://ellislab.com/forums/ to http://forum.codeigniter.com and it is hard to find the topic there. You can search if you like or you can follow the #1.
Hope it will helps you.
I have a complicate question which I can't find answers from online, or maybe I just don't know the best word to describe it,but hopefully you all and help out little bit, thanks you so much.
I want to create a user account system in php
I know how to store user date when they registra an account in form, but next time when people log in how do you know whether they has an account already or not, other words how do you validate their username and password when they come to your side.
You must store the users data they provide on sign up, using a database such as MySQL or a flat-file system such as this class.
May I suggest you search up tutorials etc. using Google or Bing, if you look hard enough you can find anything on the internet ;)
You can always try this out - PHP Login
Dom.
Ps- check out PHPSquad, Tizag and w3schools they helped me massively when first learning PHP!
It is better if you use SQL database to store the users so you have to create a register page to insert the user data into the SQL database then a login page to read the user data from the database and you can make a profile page with the data you asked to the user on the register form you can do this with ASP and PHP I recomend you PHP cause is easier.
Here is a link that shows how to make a simple user registration system with PHP and MySQL but you have to add some security to your system.
I am helping develop a web application for one of the departments in the company I work for.
I was asked to look into a way to log off every user that might be on the application at once, so that if updates to the Web App are pushed out, people aren't working with an old version of it.
My problem is that as I am not very savvy with PHP, JQuery, AJAX, etc. which is what we're using, I have not known exactly what to look for.
We have a timer script running every couple seconds in the background, so I was thinking that I could add an admin button that updated a field in the database which this script could check every so often, and if the field was set, the logoff script could be executed. But this seems like a hack to work around the issue.
The guy I'm working with suggested I look into custom SESSION handlers.
What do you guys think? Any ideas?
Any help would be appreciated. Even if it's an idea on what to start searching for.
Thanks in advance!
EDIT: I should mention that this is a one-page web app. The user is not following any links or leaving the page.
Make an entry for logged in users in your database of choice, maybe memcached if performance is a criteria.
Use a custom Session save handler which stores the sessions in database or file. When you want to destroy all sessions, you can clear the storage (be it database, or file).
Start from - http://php.net/manual/en/function.session-set-save-handler.php
What I ended up doing was the following:
I added a field into one of out database tables and checked its value every time our browser tick came through (about every minute or so). If the field is set when the tick comes through, their page is refreshed, thus logging them off the application and destroying their session (We destroy the session when someone leaves the page).
The users cannot log back in until that field has been reverted to '0'
The admin account can change that field with the click of a button. Therefore their field in the database remains as a '0'
It might be kind of a hack, but it's what I could come up with even after everyone's help. The only issue is that it takes a bit to log everyone off. Problems of pulling vs pushing I guess.
And yes, an email will be sent out some time before logging everyone off so they don't lose work.
Thank you all for your help!
dealing with php/html/javascript.
i'm trying to figure out a good/best approach to allowing a user to download a file. i can have the traditional href link, that interfaces with the back end php app to download the file.
however, i want to have the app display some sort of dialog/alert if the user isn't able (basedon acl/permissions) to download the file... does this have to ba an ajax thing, as i don't want to do a page refresh...
thoughts/comments/pointers to code samples are appreciated.
thanks.
-tom
hi... more data/information.
in my test, i send the userID/fileID via the query to the backend php.
the app then confirms the user is the user for the file, and that the user has the rights to access the file. the query data is matched against data in the db for the user/file combination.
so the last/critical check occurs on the back end.
hope this gives a bit more insight into what i'm looking to do/accomplish.
thanks
-tom
AJAX could be a good technology to use if your looking for a work-around for the page not refreshing but it doesn't have to be your only option.
Another option without requiring AJAX, which might be cumbersome depending on how your project is design, is to enable or disable features depending on the user's authentication level.
As a simple example, enable features only related to Administrators and disable Administrator features for normal users.
You don't necessarily have to enable/disable features, you could also decide before the user clicks on links whether or not he/she has rights to do-so.
With more information on how your project is laid out, we can provide more concise answers.
The easiest method would be to return a HTTP response code of 401 ("Unauthorized"). This will cause your web server to display the 401 error page, which you can modify to fit your design.
Or, if you are using AJAX, then you can check for a 401 response code and pop up a nice alert for them without taking them to a different page.
I was just exploring Phorum for my website. I already have a separate log in system associated with the main website, which I was hoping to be able to carry over to Phorum, so people don't have to sign up twice.
I saw the way to hook in a SQL database through include/db/config.php, but there seems to be no good documentation on what's going to be carried in the table I set it to. Will is just be username/password?
Assuming it is, is there a way I can have it so if you signed in on my site, you don't have to re sign in for phorum? Even just a link pointing in the right direction would be outstanding. Thanks!
You could modify your site to use the Phorum database and user registration system. This would be the best way to do it. You could write a small SQL import script for your existing users and then just link to the phorum rego page from your site.
If you are not keen on taking this approach, you'd need to update both user tables (yours and phorums) when data was changed / inserted. Also you'd both need to use the same cookie.
Does that help?