[PHP] session management
hi! i need to maintain session state in my php application. i further need to be able to distinguish between admin levels and user levels and thus the session also needs to keep this info (ie, whether person has logged in as admin or user) any ideas how to do it. thanks -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session management
hi! well i do have a MySQL database. The scenario is this, i dont want to use cookies or do any URL rewriting. i'm looking for something that mirrors J2EE's Session object that contains information about the user, their security level(user/admin etc) and this information can then be verified before each request. There would ofcourse be an expiry on the object. Is there a prewritten framework/class to handle this? thanks regards -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session management
have a user bean, and then session.setAttribute("user", userBean); do session.getAttribute("user") and validate before processing every request. Quoting Raditha Dissanayake <[EMAIL PROTECTED]>: > Last time i read the j2ee api i didn't notice anything about storing > admin/user staus in the HttpSession object. > Anyway like i said if you read the manual and SFTA you would have found > the answers. > > ajay wrote: > > >hi! > > > >well i do have a MySQL database. The scenario is this, i dont want to use > >cookies or do any URL rewriting. > >i'm looking for something that mirrors J2EE's Session object that contains > >information about the user, their security level(user/admin etc) and this > >information can then be verified before each request. There would ofcourse > be an > >expiry on the object. Is there a prewritten framework/class to handle this? > > > >thanks > > > >regards > > > > > > > > > -- > Raditha Dissanayake. > > http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload > Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader > Graphical User Inteface. Just 150 KB | with progress bar. > > > -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP REDIRECT
hi! i'd like to redirect a person to another page but after a certain time interval has elapsed. this is because i have a generic error displaying page and i would like the person to go to this page, stay there for like 10 seconds and then be redirected to the index page. i was using header("url") to redirect the user. but how do i get that to happen after a certain time interval. thanks regards -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] error : session_start
hi! i have a login page that after validating the login and passwords does something like // initiate a session session_start(); // register some session variables session_register("SESSION"); // including the username session_register("SESSION_UNAME"); $SESSION_UNAME = $login; // redirect to protected page header("Location:manager.php"); when i try to run this at home with my apache 1.3.27 i get the following errors: Warning: session_start() [function.session-start]: open(/tmp\sess_d6abb1b84993ac7bca6eb7eb8f06481d, O_RDWR) failed: No such file or directory (2) in c:\program files\apache group\apache\htdocs\usydbasketball\login.php on line 16 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\program files\apache group\apache\htdocs\usydbasketball\login.php:16) in c:\program files\apache group\apache\htdocs\usydbasketball\login.php on line 16 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\program files\apache group\apache\htdocs\usydbasketball\login.php:16) in c:\program files\apache group\apache\htdocs\usydbasketball\login.php on line 16 Warning: Cannot modify header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\usydbasketball\login.php:16) in c:\program files\apache group\apache\htdocs\usydbasketball\login.php on line 26 Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 Warning: Unknown(): open(/tmp\sess_d6abb1b84993ac7bca6eb7eb8f06481d, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 can someone please help thanks regards -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] tmp_dir
hi! i suppose this is more of an apache question. i'm trying to build a php file upload utility. as part of writing it i need to know the upload_tmp_dir for my apache server (its 1.3.27) i did phpinfo() and the result i getis upload_tmp_dir no value no value how do i set this variable? thanks -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] redirecting
hi! after having trawled through many google articles, i've been told that the best way to redirect a person is using header("Location:url"); the problem is, i have form that is posted to another php script. This script then processes the form and then writes up a html page and includes in that page any warnings etc. i want the user to have say 5s to read that page and then be redirected to another page. so i have something like //process form //write page sleep(10); header("Location:blah.php"); the problem is i get an error when the script gets to the header part, the error being Warning: Cannot modify header information - headers already sent by (output started at c:\program files\apache group\apache\htdocs\usydbasketball\subscribe_mailing_list.php:6) in c:\program files\apache group\apache\htdocs\usydbasketball\subscribe_mailing_list.php on line 67 so how do i workaround that? thanks regards -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help please
hi! i have a class called DB that i include in a page as include(classes/DB.php); however when i run this page i get an error saying Warning: main(/home/bikkar/public_html/ajay/classes/DB.php): failed to open stream: No such file or directory in /home/bikkar/public_html/ajay/index.php on line 18 Warning: main(): Failed opening '/home/bikkar/public_html/ajay/classes/DB.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bikkar/public_html/ajay/index.php on line 18 but i have verified that DB.php is there, is full(non-corrupted) and there are a few other classes in that folder that upload fine. can someone please help thanks -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help please
hi! the code is print_header(); printf(""); $page->print_banner(); $page->print_menu(); $db = new DB("localhost", "usydbasketball", "", ""); $query = "SELECT * FROM updates ORDER BY ID DESC"; thanks ajay Quoting adwinwijaya <[EMAIL PROTECTED]>: > Hello ajay, > Sunday, February 22, 2004, 7:57:21 PM, you wrote: > > a> hi! > a> i have a class called DB that i include in a page as > include(classes/DB.php); > a> however when i run this page i get an error saying > a> Warning: main(/home/bikkar/public_html/ajay/classes/DB.php): failed to > open > a> stream: No such file or directory in > a> /home/bikkar/public_html/ajay/index.php > a> on line 18 > a> Warning: main(): Failed opening > a> '/home/bikkar/public_html/ajay/classes/DB.php' > a> for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') > a> in /home/bikkar/public_html/ajay/index.php on line 18 > a> but i have verified that DB.php is there, is > a> full(non-corrupted) and there are > a> a few other classes in that folder that upload fine. > a> can someone please help > a> thanks > a> -- > a> ajay > a> --- > > --> would you like to show us part of the code (especially on > --> index.php line 18) > > -- > Best regards, > adwinwijayamailto:[EMAIL PROTECTED] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- ajay --- Who Dares Wins - This mail sent through IMP: www-mail.usyd.edu.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Query
Can you please spend some time with my doubt... My query is that ... Is there any option or function in PHP to implement automatic updation of web pages with the latest contents from other sites. Like news from news sites etc. Or do you have any idea about doing it. Thank you for spending your valuable time for me Expecting your helpful reply Ajay Lal C M iPath India Pvt.Ltd G-358, Panampilly Nagar Cochin-36 www.ipathindia.com
[PHP] Multiple attachments in an email
Hi, Please guide how to send multiple attachments in one mail through php mail script. The following code is working for the one attachment: Thanks & regards, Ajay // Read POST request params into global vars $to = $_POST['to']; $from= $_POST['from']; $subject = $_POST['subject']; $message = $_POST['message']; // Obtain file upload vars $fileatt = $_FILES['fileatt']['tmp_name']; $fileatt_type = $_FILES['fileatt']['type']; $fileatt_name = $_FILES['fileatt']['name']; $headers = "From: $from"; if (is_uploaded_file($fileatt)) { // Read the file to be attached ('rb' = read binary) $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); // Generate a boundary string $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // Base64 encode the file data $data = chunk_split(base64_encode($data)); // Add file attachment to the message $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } // Send the message $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "Mail sent! "; } else { echo "Mail could not be sent. Sorry!"; } ?>
[PHP] Query regarding temporarily-uploaded files
Hi all. I have a requirement, wherein I need to allow vanilla uploads of files to a HTTPD server. Any client can upload any number of files (one at a time). Also, there is just one directory, where the files get stored "finally" (that is, after being copied from the temporary location, via "move_uploaded_file") Also, I have been able to get the simple file uploading running via PHP, by picking up one of the numerous "Hello World" examples available :) Now, I am facing the following use-case :: 1) User 1 starts uploading a large file, say "big_file.avi". 2) Meanwhile, user 2 also starts uploading a (different) file, but with the same name "big_file.avi". In an ideal scenario, user 2 should be prompted with a message, that a file of the same name is already being uploaded by someone else somewhere. Is there a way to do this? ( Note that, had the user 2 started uploading AFTER user 1 had finished with the upload, we could probably modify the PHP-script at the sever-side, to let user-2 know that a file of the same name already exits. But I am failing to find a solution, when the user 2 starts the upload WHILE the large file of user 1 is in the process of completing uploading). Any way the issue may be solved? I will be grateful for any pointers :) Regards, Ajay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Query regarding temporarily-uploaded files
Thanks Jim and Matijn for the quick replies. I will try to have a workaround. On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt wrote: > > > > On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg wrote: > >> Hi all. >> >> I have a requirement, wherein I need to allow vanilla uploads of files >> to a HTTPD server. >> >> Any client can upload any number of files (one at a time). >> Also, there is just one directory, where the files get stored >> "finally" (that is, after being copied from the temporary location, >> via "move_uploaded_file") >> >> Also, I have been able to get the simple file uploading running via >> PHP, by picking up one of the numerous "Hello World" examples >> available :) >> >> >> >> Now, I am facing the following use-case :: >> >> 1) >> User 1 starts uploading a large file, say "big_file.avi". >> >> 2) >> Meanwhile, user 2 also starts uploading a (different) file, but with >> the same name "big_file.avi". >> >> >> In an ideal scenario, user 2 should be prompted with a message, that a >> file of the same name is already being uploaded by someone else >> somewhere. >> Is there a way to do this? >> >> ( Note that, had the user 2 started uploading AFTER user 1 had >> finished with the upload, we could probably modify the PHP-script at >> the sever-side, to let user-2 know that a file of the same name >> already exits. But I am failing to find a solution, when the user 2 >> starts the upload WHILE the large file of user 1 is in the process of >> completing uploading). >> >> >> Any way the issue may be solved? >> >> I will be grateful for any pointers :) >> >> >> >> Regards, >> Ajay >> >> > > Hi, > > This is not possible with PHP, PHP will not know about the file until the > upload is completed. You can use HTML5 or flash(not recommended) for an > alternative way of uploading, and then you can check the file name in > advance. > > - Matijn > -- Regards, Ajay
Re: [PHP] Query regarding temporarily-uploaded files
Thanks Jim and Anthony. Jim, You are right, your solution is doable. But one thing I am a little skeptical about, is what would be the percentage of the people willing to suggest a new name "immediately", versus the percentage of people who would like to cancel the current upload, and come back "later" after walking and coming up with a new name. Anyhow, let me sleep over it :) Anthony, your solution is really a special case of Jim's solution :) Thanks guys for the quick replies; I am obliged, really. On Thu, Jul 11, 2013 at 12:59 AM, Anthony Wlodarski wrote: > Is there anything that would prevent you from somehow uniquely knowing who > the user is uploading the file. For example you mentioned "client'. If > you know > who the client is you can append that to the filename or prepend it, for > the > destination string (second parameter to the function call). That way it > is unique > to that client. > > -Anthony > > > On Wed, Jul 10, 2013 at 2:15 PM, Ajay Garg wrote: > >> Thanks Jim and Matijn for the quick replies. >> I will try to have a workaround. >> >> >> >> On Wed, Jul 10, 2013 at 11:09 PM, Matijn Woudt wrote: >> >> > >> > >> > >> > On Wed, Jul 10, 2013 at 7:21 PM, Ajay Garg >> wrote: >> > >> >> Hi all. >> >> >> >> I have a requirement, wherein I need to allow vanilla uploads of files >> >> to a HTTPD server. >> >> >> >> Any client can upload any number of files (one at a time). >> >> Also, there is just one directory, where the files get stored >> >> "finally" (that is, after being copied from the temporary location, >> >> via "move_uploaded_file") >> >> >> >> Also, I have been able to get the simple file uploading running via >> >> PHP, by picking up one of the numerous "Hello World" examples >> >> available :) >> >> >> >> >> >> >> >> Now, I am facing the following use-case :: >> >> >> >> 1) >> >> User 1 starts uploading a large file, say "big_file.avi". >> >> >> >> 2) >> >> Meanwhile, user 2 also starts uploading a (different) file, but with >> >> the same name "big_file.avi". >> >> >> >> >> >> In an ideal scenario, user 2 should be prompted with a message, that a >> >> file of the same name is already being uploaded by someone else >> >> somewhere. >> >> Is there a way to do this? >> >> >> >> ( Note that, had the user 2 started uploading AFTER user 1 had >> >> finished with the upload, we could probably modify the PHP-script at >> >> the sever-side, to let user-2 know that a file of the same name >> >> already exits. But I am failing to find a solution, when the user 2 >> >> starts the upload WHILE the large file of user 1 is in the process of >> >> completing uploading). >> >> >> >> >> >> Any way the issue may be solved? >> >> >> >> I will be grateful for any pointers :) >> >> >> >> >> >> >> >> Regards, >> >> Ajay >> >> >> >> >> > >> > Hi, >> > >> > This is not possible with PHP, PHP will not know about the file until >> the >> > upload is completed. You can use HTML5 or flash(not recommended) for an >> > alternative way of uploading, and then you can check the file name in >> > advance. >> > >> > - Matijn >> > >> >> >> >> -- >> Regards, >> Ajay >> > > > > -- > Anthony W. > ant92...@gmail.com > -- Regards, Ajay
[PHP] How to send "post"-variables in a "Location" header
Hi all. I have a scenario, wherein I need to do something like this :: ### $original_url = "/autologin.php"; $username = "ajay"; $password = "garg"; header('Location: ' . $original_url); ### As can be seen, I wish to redirect to the URL "autologin.php". Additionally, I wish to pass two POST key-value pairs :: "user=ajay" and "password=garg" (I understand that passing GET key-value pairs is trivial). Is it even possible? If yes, I will be grateful if someone could let me know how to redirect to a URL, passing the POST key-value pairs as necessary. Looking forward to a reply :) -- Regards, Ajay
[PHP] Re: How to "download" a multi-part file at the "server" side?
I just came across http://www.w3schools.com/php/php_file_upload.asp, and tested it.. It works fine, when the file is uploaded via a form. It does seem that the client-method might indeed play a role. Here is my Java code for uploading the file :: ### HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpPost httppost = new HttpPost(URL); File file = new File("/path/to/png/file.png"); // Send the image-file data as a Multipart-data. MultipartEntity mpEntity = new MultipartEntity(); ContentBody cbFile = new FileBody(file, "image/png"); mpEntity.addPart("userfile", cbFile); httppost.setEntity(mpEntity); HttpResponse response = httpclient.execute(httppost); ### Any ideas if making a change at the client (Java) OR/AND server (PHP) might do the trick? On Sat, Nov 2, 2013 at 6:06 PM, Ajay Garg wrote: > Hi all. > > I intend to implement a use-case, wherein the client uploads a file in > multi-part format, and the server then stores the file in a mysql database > (after "downloading it at the server side). > > I have been unable to find any immediate answers through googling; I will > be grateful if someone could start me in a direction to achieve the > "downloading at server via php" requirement. > > (Don't think it should matter, but I use Java to upload a file in > multi-part format). > > I will be grateful for some pointers. > > Thanks in advance > > > Thanks and Regards, > Ajay > -- Regards, Ajay
Re: [PHP] How to "download" a multi-part file at the "server" side?
Hi Aziz. Thanks for the reply. Unfortunately, making the change suggested by you does not make any difference :( Sorry, Thanks and Regards On Sat, Nov 2, 2013 at 10:51 PM, Aziz Saleh wrote: > > > > On Sat, Nov 2, 2013 at 1:03 PM, Ajay Garg wrote: > >> Hi all. >> >> 1. >> I could have the proper "$_FILES["userfile"]["name"]" been echoed back, by >> replacing >>ContentBody cbFile = new >> FileBody(file, "image/png"); >> >> with >>ContentBody cbFile = new >> FileBody(file); >> >> >> >> 2. >> However, now I am stuck with the following server-side code. >> No matter what I do, I always get a "no" echoed back (specifying that the >> file is not copied to its target place). >> >> >> >> >> ### >> > >> $headers = apache_request_headers(); >> >> foreach ($headers as $header => $value) >> { >> if($header == "active_window_title") >> { >> $active_window_title = $value; >> break; >> } >> } >> >> >> $target_path = "/home/ajay/success.png"; >> >> move_uploaded_file($_FILES["userfile"]["tmp_name"], $target_path); >> if(file_exists($target_path)) >> { >> echo "yes"; >> } >> else >> { >> echo "no"; >> } >> >> echo "\n" . $_FILES["userfile"]["name"]; # I always get the proper >> file-name echoed. >> >> ?> >> >> >> >> >> >> >> >> Any ideas what stupidity am I making in the PHP code? >> >> >> On Sat, Nov 2, 2013 at 7:13 PM, Ajay Garg wrote: >> >> > Does not work :( >> > >> > >> > As per the code-snippet I pasted, >> > $_FILES["userfile"]["name"] >> > >> > should be >> > >> /path/to/png/file.png >> > >> > >> > However, $_FILES["userfile"]["name"] is empty. >> > >> > >> > On Sat, Nov 2, 2013 at 6:59 PM, Shawn McKenzie > >wrote: >> > >> >> Fairly easy: >> >> http://www.php.net/manual/en/features.file-upload.post-method.php >> >> >> >> >> >> On Sat, Nov 2, 2013 at 7:36 AM, Ajay Garg >> wrote: >> >> >> >>> Hi all. >> >>> >> >>> I intend to implement a use-case, wherein the client uploads a file in >> >>> multi-part format, and the server then stores the file in a mysql >> >>> database >> >>> (after "downloading it at the server side). >> >>> >> >>> I have been unable to find any immediate answers through googling; I >> will >> >>> be grateful if someone could start me in a direction to achieve the >> >>> "downloading at server via php" requirement. >> >>> >> >>> (Don't think it should matter, but I use Java to upload a file in >> >>> multi-part format). >> >>> >> >>> I will be grateful for some pointers. >> >>> >> >>> Thanks in advance >> >>> >> >>> >> >>> Thanks and Regards, >> >>> Ajay >> >>> >> >> >> >> >> > >> > >> > -- >> > Regards, >> > Ajay >> > >> >> >> >> -- >> Regards, >> Ajay >> > > Ajay, try changing your mpEntity to: > > new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE) > > See if it makes a difference. > Ajay
[PHP] How to get text of Alert message
I am using Selenium IDE tool. facing the problem to get the text of alert message. Any help ...Please reply as soon as possible.. Thanks, -- View this message in context: http://www.nabble.com/How-to-get-text-of-Alert-message-tp18929888p18929888.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Here you have, ;o)
Hi: Check This! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]