[PHP] Re: Login should not allow users to login if the application is logged in with the same login credentials
Balasubramanyam A knowledge.wea...@gmail.com wrote in message news:893c34ce0908270424n2d81596dq8529f13818dc9...@mail.gmail.com... Hello, I've written a simple application, where users need to login to access the features of the application. I want to develop login system such that, if user is already logged in, the application should not allow the users to login with the same login credentials. How do I accomplish this? Regards, Balu Personally, I have a table for sessions - each time a user logs in, their session is stored in the table, along with the session_id generated by session_start(), the userID, the time the session was last active, and an active flag. I use these fields to keep track of the users activity. If at any point the active flag is changed to inactive, the user's session is destroyed, and they are required to log in again. What you would do in your case, to only allow the user to be logged in at one location at any given time would be to automatically change the flag to 'inactive' on all the sessions in the table, associated with that users ID. Thus, if there is an active session elsewhere, when a new session is started, all other sessions associated with that ID will be kicked out. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] starting session with AJAX
Ok, so I've got an authentication/login form that is powered by ajax. The user logs in, is authenticated, and the last step is to start a session and save the necessary information in the $_SESSION vars. For some reason, it appears (and almost of makes sense) that the session that is started via the AJAX is lost once the ajax is complete. AJAX calls the php, passing username and password Php executes all the necessary authentication, etc etc If, login is valid, it calls mySessionStart() (see below) Checks to make sure the session has been started using isLoggedIn() (below), which returns true AJAX closes, receiving a successfully logged in message. AJAX turns around and makes a second call, calling isLoggedIn() again, and the session is gone What I'm *guessing* is that because the PHP is not running on the active page, but in the background the session is not being set for the active page. Is there a way to pass the session back to the browser? - John Debugging code has been removed for readability: ** function mySessionStart($persist, $sessionID, $sessionKey, $debug=0){ session_start(); $_SESSION['sessDBID'] = $ sessionID; $_SESSION['sessKey'] = $ sessionKey; $_SESSION['persist'] = $persist; // if persist, set cookie if ($persist){ return myCreateCookie($persist, $ sessionID, $ sessionKey, $debug); }else{ return true; } } function isLoggedIn($debug = 0){ global $COOKIE_NAME; // if there is an active session. if (isset($_SESSION) $_SESSION['sessDBID'] != '' $_SESSION['sessKey'] != ){ //. check the contents return authenticate($_SESSION['sessDBID'], $_SESSION['sessKey']); // or, check for (persistent) cookie. }elseif (isset($_COOKIE[$COOKIE_NAME]) $_COOKIE[$COOKIE_NAME] != ){ $sessInfo = split('-', $_COOKIE[$COOKIE_NAME]); // . and check the contents if(authenticate($sessInfo[1], $sessInfo[0], $debug)){ // reset the cookie mySessionStart(true, $sessInfo[1], $sessInfo[0], $debug); }else{ // cookie authentication failed return false; } }else{ // there is no session or cookie return false; } }
RE: [PHP] user permissions
In this mechanism, does a role differ significantly from a group? I have to admin a CRM system that has both roles /and/ groups, and it always seems a bit excessive. But maybe there's some benefit to roles, as such, that I'm not seeing. Thanks, Ben [JP] As described, a role appears to act essentially the same as a group - a predefined set of permissions that can be assigned to multiple users (as opposed to a set of permissions unique to the user). Correct me if there's a better way, but I think individual permissions can be set similarly - except skip the role/group step and associate the binary permission string directly with the user. Thinking outloud: In your case where you're dealing with both individual permissions as well as groups, you could do both of the above, but have the individual permissions override the group. You'd have to figure out a third bit though, to act as a no change bit. Ie: 0 = deny, 1 = allow, 2 = NC. But, that wouldn't allow you to convert and store the bit string in decimal. So if group1 had a permission string of 1010, and user Joe was a member of group1, but you wanted to take away the first bit's permission, and grant the second bit, you could assign him the individual permission string of 0122 (deny, allow, NC, NC), resulting in his permissions being 0110. You'd check it by checking the individual permissions first, and if the bit (or digit in this case) were 2, then you would move on to checking the group permissions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] user permissions
As described, a role appears to act essentially the same as a group - a predefined set of permissions that can be assigned to multiple users (as opposed to a set of permissions unique to the user). [JP] I should say, the logic of a role is essentially the same as the logic behind a group. It just adds, as Phpster said, another layer of control -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: starting session with AJAX
I found two small errors in the isLoggedIn(), which are corrected below. They don't have any effect on the issue at hand though. ** function isLoggedIn($debug = 0){ global $COOKIE_NAME; // if there is an active session. if (isset($_SESSION) $_SESSION['sessDBID'] != '' $_SESSION['sessKey'] != ){ //. check the contents return authenticate($_SESSION['sessDBID'], $_SESSION['sessKey']); // or, check for (persistent) cookie. }elseif (isset($_COOKIE[$COOKIE_NAME]) $_COOKIE[$COOKIE_NAME] != ){ $sessInfo = split('-', $_COOKIE[$COOKIE_NAME]); // . and check the contents if(authenticate($sessInfo[0], $sessInfo[1], $debug)){ // reset the cookie return (mySessionStart(true, $sessInfo[0], $sessInfo[1], $debug)); }else{ // cookie authentication failed return false; } }else{ // there is no session or cookie return false; } }
[PHP] RE: starting session with AJAX
Nevermind. It was a simple mistake - I had session_start() on the page the ajax was calling from, but not at the beginning of the php script it was calling to.
Re: [PHP] checking local file size
I tried installing it like the documentation said... but I got the following errors. I contacted the hosting service (dreamhost) and they said they don't provide support for pecl, though they do support perl. Anyone? -- $ pecl install uploadprogress Failed to download pecl/uploadprogress within preferred state stable, latest release is version 0.9.1, stability beta, use channel://pecl.php.net/uploadprogress-0.9.1 to install Cannot initialize 'uploadprogress', invalid or missing package file Package uploadprogress is not valid install failed $ pecl install uploadprogress-beta Cannot install, php_dir for channel pecl.php.net is not writeable by the current user .com/ Um, sudo? Or be root when you install as the PEAR/PECL structure is usually owned by root. Just tried that - I don't have the permissions to sudo :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] custom php.ini
Daniel Brown danbr...@php.net wrote in message news:ab5568160812160954o338d0421jb133bdc17b4e3...@mail.gmail.com... I'm not certain about their configuration, but does DreamHost have AllowOverrides turned on in their httpd.conf? If so, just place a full php.ini file in your root web directory (not just the line for uploads_tmp_dir, but an entire copy of the file). If their Apache and PHP configuration allows it, you'll be able to change several of the settings in that file. Those settings that you can update will be PHP_INI_PERDIR[1] and higher. Thanks, that worked. KEY 1.) View the list in the appendix here: http://www.php.net/manual/en/ini.php#ini.list -- /Daniel P. Brown http://www.parasane.net/ daniel.br...@parasane.net || danbr...@php.net 50% Off Hosting! http://www.pilotpig.net/specials.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking local file size
Bojan Tesanovic btesano...@gmail.com wrote in message news:c4dac606-7711-49cd-9e03-5cdd5627f...@gmail.com... Well you need to know the TMP file name that has been in progress of upload, it is usually at /tmp folder I know how to get that... also you need to know the actual size of file uploading, there is an extension for PHP that will give you this info but you need to compile it , on my cars site for uploading images I am using this one http://blog.liip.ch/archive/2006/09/28/upload-progress-meter- extension-for-php-5-2.html I downloaded the uploadprogress zip from that site (their example looks like it provides what I'm looking for). At the expense of sounding ignorant... How do I add that extension to PHP? I looked through the example code, and I get the idea of what's happening, but I don't know how to add it to my server (I use shared hosting, though I have shell access). Does it need to be built into a *.so or *.dll and added to the PHP.ini file? If so, how do I build it? In short, what next? Thanks On Dec 16, 2008, at 9:20 PM, John P wrote: I know this isn't a php question (though I'm using PHP for the server side... does that count?). I'm hoping though that some of you guys are just as experienced in ajax as you are PHP, because I can't find any good ajax forums. you can respond to me personally if needed, to keep it off the php list my question: I know there are alot of ajax/php upload progress bars out there, but they're either complicated, unreliable, or just generally don't fit my needs. Thus, i'm making my own. One problem I'm running into though, is how to check the local file size as compared to the uploaded file size. I can check and display the total uploaded size (ie, 437kb uploaded so far...), but to get the percent, I have to know the total size - BEFORE it's fully uploaded. I would like to say 437kb of 932kb uploaded so far... but how do I get the 932 from the local file? It doesn't do too much good to say how much has been uploaded if they don't know how much is left... I know it's possible (most other meters do this) - I just can't figure out how. any hints? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Bojan Tesanovic http://classiccars.carster.us/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] checking local file size
Bojan Tesanovic btesano...@gmail.com wrote in message news:c4dac606-7711-49cd-9e03-5cdd5627f...@gmail.com... Well you need to know the TMP file name that has been in progress of upload, it is usually at /tmp folder I know how to get that... also you need to know the actual size of file uploading, there is an extension for PHP that will give you this info but you need to compile it , on my cars site for uploading images I am using this one http://blog.liip.ch/archive/2006/09/28/upload-progress-meter- extension-for-php-5-2.html I downloaded the uploadprogress zip from that site (their example looks like it provides what I'm looking for). At the expense of sounding ignorant... How do I add that extension to PHP? I looked through the example code, and I get the idea of what's happening, but I don't know how to add it to my server (I use shared hosting, though I have shell access). Does it need to be built into a *.so or *.dll and added to the PHP.ini file? If so, how do I build it? In short, what next? http://pecl.php.net/package/uploadprogress I already downloaded that, thanks. How do I apply it is my question. There's no documentation for the installation of it, that I see -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] checking local file size
I already downloaded that, thanks. How do I apply it is my question. There's no documentation for the installation of it, that I see 'Course it is :) http://www.php.net/manual/en/install.pecl.php Linked from here: http://pecl.php.net/doc/index.php I tried installing it like the documentation said... but I got the following errors. I contacted the hosting service (dreamhost) and they said they don't provide support for pecl, though they do support perl. Anyone? -- $ pecl install uploadprogress Failed to download pecl/uploadprogress within preferred state stable, latest release is version 0.9.1, stability beta, use channel://pecl.php.net/uploadprogress-0.9.1 to install Cannot initialize 'uploadprogress', invalid or missing package file Package uploadprogress is not valid install failed $ pecl install uploadprogress-beta Cannot install, php_dir for channel pecl.php.net is not writeable by the current user .com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] google books
Not a PHP question. but could someone point me in the direction of how to download/display only a portion of a PDF, much like google books does? For example, if you have a 200 page pdf, but the user wishes to see the portion that is on page 150. rather than downloading the entire PDF, only download/display page 150? I would like to avoid having to split them into 200 individual PDF's (whether manually or automatically). Any suggestions? - JP
[PHP] php/mysql - getting ID of query
This is as much a mysql question as it is php. What is the most reliable way to retrieve an auto_increment key/id for a query you just inserted? In other words, I compile all my data, insert it into a new row, and now I want to retrieve the ID it created for it in the ID/key field. Without turning around and searching for the values I just inserted, is there a way to get the ID? The ID is the only field that is guaranteed to be unique in each data set, which makes it questionable to search for the data you just inserted, unless you searched for the *whole* data set. Thanks John
[PHP] RE: php/mysql - getting ID of query
Thanks guys, that's exactly what I was looking for J -Original Message- From: M. Sokolewicz [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 21, 2007 4:51 PM To: John Pillion Cc: php-general@lists.php.net Subject: Re: php/mysql - getting ID of query John Pillion wrote: This is as much a mysql question as it is php. What is the most reliable way to retrieve an auto_increment key/id for a query you just inserted? In other words, I compile all my data, insert it into a new row, and now I want to retrieve the ID it created for it in the ID/key field. Without turning around and searching for the values I just inserted, is there a way to get the ID? The ID is the only field that is guaranteed to be unique in each data set, which makes it questionable to search for the data you just inserted, unless you searched for the *whole* data set. Thanks John mysql_insert_id() mysqli::insert_id PDO::lastInsertId() depending on the way you access it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] test for multi-dim array
I'm trying to recursively loop through a multi dimensional array with unknown keys and unknown values, and echo the keys/values to a sql statement, where the key is the field, and the value is the. value. What I want to do is test an array index to see if it has any children indices (which then need to be looped through again), or if it is the lowest level child. in which case, the data needs to be extracted. What is the easiest way to test an array index to see if it has one or more children? Just doing a count() isn't reliable, as their may only be a single parent on the highest level. John
[PHP] audio recorder
Not exactly a php question. but I'm doing the project in php, so does that count? ;-) A client of mine wants a simple audio recorder for users to record a short clip/message for other users. anyone recommend any simple audio recorder applets or similar that can easily be integrated with php? Thanks! J
RE: [PHP] audio recorder
-Original Message- From: Tijnema [mailto:[EMAIL PROTECTED] Sent: Monday, July 30, 2007 4:25 PM To: John Pillion Cc: php-general@lists.php.net Subject: Re: [PHP] audio recorder On 7/31/07, John Pillion [EMAIL PROTECTED] wrote: Not exactly a php question. but I'm doing the project in php, so does that count? ;-) A client of mine wants a simple audio recorder for users to record a short clip/message for other users. anyone recommend any simple audio recorder applets or similar that can easily be integrated with php? Thanks! J How do you want to implement it? Where is the microphone connected? Server? Client? or is it a Stand Alone app (CLI)? [JP] You guessed right... client side. If it's connected to the client PC (which I'm guessing), then you can't use PHP for recording it, it needs to be done in a client side language, and if you don't want the client to download an application, you have a few options, but there's only one I can recommend, and that is java. But really, you're not on the right list for that ;) [JP] I knew PHP couldn't do it... but I was hoping there was a better option than Java. If not, then so be it I guess. Agreed that this isn't the right list for that though ;-) If it's connected to the server, or if it's an Stand Alone app, then I would recommend you looking for some software that does record from the microphone, and use it through system, exec, ``, ... functions. [JP] Don't want a stand alone app, as I/they want it as simple and user friendly as possible. J Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sendmail loop
I have a sendmail script that loops through an array of email addresses. the problem is, the list can sometimes be fairly long, and the page does not finish loading until the loop has completed. Currently, I have the majority of the page loading, including text that says messages sending, please wait., with a completed message after the loop. Though that gives an appearance of working (and lets the patient user know what is going on), if the user leaves the page, or the page times out before the loop has finished, not all the emails will be sent. Is there a way to trigger a script to run on the server (in the background)? I had the thought to save the notice to the DB, and then have a cron check every few minutes to send it, but that could be too much load on the servers. Any other alternatives? Thanks! ~J Ps. No, this is not a spam application - it is a notice/announcement form for directors/administrators of an organization
RE: [PHP] Checking file existence
Very nifty Brad, One addition though, so she/you can work back from any point: MoreUntestedCode $i = 0; $start = strtotime(2006-10-05 12:05am); while(count($img_array) 5) { $year = date(Y, strtotime(-$i minutes, $start)); $month= date(m, strtotime(-$i minutes, $start)); $day = date(d, strtotime(-$i minutes, $start)); $hour = date(H, strtotime(-$i minutes, $start)); $hhmm = date(Hi, strtotime(-$i minutes, $start)); $filename = file.$hhmm.jpg; if(file_exists(/path/to/$year/$month/$day/$hour/$filename)) { $img_array[] = $filename; } $i++; } print_r($img_array); /MoreUntestedCode JP -Original Message- From: Brad Fuller [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 10:11 AM To: php-general@lists.php.net Subject: RE: [PHP] Checking file existence MoreUntestedCode $img_array = array(); $i = 0; while(count($img_array) 5) { $year = date(Y, strtotime(-$i minutes)); $month= date(m, strtotime(-$i minutes)); $day = date(d, strtotime(-$i minutes)); $hour = date(H, strtotime(-$i minutes)); $hhmm = date(Hi, strtotime(-$i minutes)); $filename = file.$hhmm.jpg; if(file_exists(/path/to/$year/$month/$day/$hour/$filename)) { $img_array[] = $filename; } $i++; } print_r($img_array); /MoreUntestedCode -Original Message- From: Brad Fuller [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 10:56 AM To: php-general@lists.php.net Subject: RE: [PHP] Checking file existence UntestedCode $img_array = array(); $i = 0; while(count($img_array) 5) { $hhmm = date(Hi, strtotime(-$i minutes)); $filename = file.$hhmm.jpg; if(file_exists(/path/to/$filename)) { $img_array[] = $filename; } $i++; } print_r($img_array); /UntestedCode -Original Message- From: Ashley M. Kirchner [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 15, 2006 10:19 AM To: PHP General List Subject: [PHP] Checking file existence I have files that are named in the following manner: file..jpg (where is an hhmm timestamp [hour and minutes]) What's the best way to take the current hhmm timestamp and run backwards finding the previous 5 files, and checking whether they actually exist? There's a possibility one or more might not exist and rather than returning a blank value, I want to continue further back till I find the next. So for example, say I have: file 1122.jpg file 1121.jpg file 1119.jpg file 1117.jpg file 1116.jpg file 1114.jpg Notice the gaps, 1120, 1118, and 1115 are missing. But I still want to return five, thus 1122, 1121, 1119, 1117, and 1116. I thought of taking the current timestamp and loop five times, subtracting from it every time, but that's assuming all five are there. If one's missing then I only have four images. -- W | It's not a bug - it's an undocumented feature. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / Websmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com . . .. Boulder, CO 80303, U.S.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php