[PHP] Drop in replacement for session_decode() ?
I was wondering if anyone knew of a drop-in replacement function for session_decode(). I am having problems with the session_decode() function populating the $_SESSION array with bogus or corrupt entries. I'm using PHP 4.3.0. Thanks in advance. Uchendu Nwachukwu www.unnndunn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 4.2 new GLOBALS question
Try simply changing '$HTTP_GET_VARS' to '$_GET'. so.. $start = isset($_GET['s']) ? $_GET['s'] : ''; -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "Jeff Lewis" <[EMAIL PROTECTED]> wrote in message 00b101c1ecaf$2f429850$0100a8c0@cr983033a">news:00b101c1ecaf$2f429850$0100a8c0@cr983033a... > Excuse me, you're right. I was using this include as a "preprocess" step as > I was using ; to seperate arguments in the query string like this > index.php?s=something;t=thing > > The preprocess step was breaking them apart and then I was doing this: > > $start = isset($HTTP_GET_VARS['s']) ? $HTTP_GET_VARS['s'] : ''; > > Then back in index I did a if ($start == "somevalue") > > However, with 4.2, the $start is no longer populated. > > If I add an echo $start; right after the include, in 4.1.2 and below, it > would echo the value of $start but now it keeps turning up empty. > > Jeff > - Original Message - > From: "John Holmes" <[EMAIL PROTECTED]> > To: "'Jeff Lewis'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Thursday, April 25, 2002 10:13 PM > Subject: RE: [PHP] 4.2 new GLOBALS question > > > > > I am working on an odler script which loads up in index.php and a URL > > is > > > passed usually like index.php?s=something > > > > > > Now, around line 10 of index.php I do an include that pulls the value > > of s > > > via HTTP_POST_VARS and then I dump it into $start. > > > > What do you mean you "dump it into $start"?? Where is $start coming > > from? Also, if you are using index.php?s=something, then 's' will be in > > HTTP_GET_VARS or _GET ...not POST. > > > > ---John Holmes... > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to use session data in other php scripts
Simply do the same thing in the other script. Create a session named 'testsess' and register the variable (under the same name) to it. That variable will auttomatically take up the it was set to previously. -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "Deval Parikh" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > I have one string variable in script a.php, I regester > this variable to session name testsess. > > this link redirects to another script b.php then how i > get that string var from session. > > basically I want to store var. serverside and use them > in to different scripts. > > If any one help me let me know. > > thanks, > > ~ deval > > __ > Do You Yahoo!? > Yahoo! Games - play chess, backgammon, pool and more > http://games.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Callin PHP gurus...figure this out
Easy as pie. Firstly, make sure your TEXTAREA tab has the 'wrap' attribute set to 'hard'. You can set the number of characters per line by using the 'cols' attribute. So if you want to do a hard wrap every 75 characters, use . Next, in your PHP script, run the text through nl2br() to add the tags, and run it through strtr("\"", "'") to change the double-quotes to single quotes. You'll also want to run the text through addslashes() before you submit it to the database - to prevent people from passing commands to the database through your form. Hope that helps! -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "R" <[EMAIL PROTECTED]> wrote in message 000b01c1ed6e$d21595e0$0a6da8c0@lgwezec83s94bn">news:000b01c1ed6e$d21595e0$0a6da8c0@lgwezec83s94bn... > Greetings All, > (Special greetings go out to Steve for excellient previous help - Thanks > again dude) > Calling all PHP gurus, have broked my head over this but cant seem to figure > this out in c,perl or java servlets. > Am new to PHP so dont even know the common functions leave alone the answer > to this problem. > Heres the setup: > I have a form with just one TEXTAREA > Data from this form is entered directly into the database > > BUT... > > everytime a user presses the ENTER or RETURN key on the keyboard, when the > PHP script validates the form > I want it to add it should also add a if the line is say75 > charactors long & if there is no or enter key pressed.. > If it finds any " it should convert it to ' > > Any ideas? > > Any help appreciated. > Have a great day. > -Ryan A. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to create, name and start PHP sessions
Make sure you aren't sending any HTML to the browser for any reason before the session_start(); call. Surefire way to prevent this error: place the following line as the first line of PHP script you execute on every page: ob_start(); Check out http://www.php.net/ob_start for details on what that does. -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "Phil Powell" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I am now getting the following errors on every page: > > Warning: Cannot send session cache limiter - headers already sent (output > started at c:\program files\apache > group\apache\htdocs\webmissions\picupload\miss_pic_upload.php:25) in > c:\program files\apache > group\apache\htdocs\webmissions\picupload\miss_pic_upload.php on line 81 > > This is when I use the following block of code to first SET the session for > the very first time: > > if (mysql_num_rows($results) == 0) { > // Could not find info in db redirect to login library with error msg > $errorHTML .= "We could not find your information "; > $errorHTML .= " in our database. Please try again."; > $hasLoggedIn = 0; > } else if (strcmp(session_name(), "hasLoggedIn") != 0) { > // Set up session variable with username and redirect to pic upload lib > session_name("hasLoggedIn"); > $name = session_name(); > session_start(); > $HTTP_SESSION_VARS["username"] = $username; > $HTTP_SESSION_VARS["ip"] = $REMOTE_ADDR; // To prevent session stealing > } > > I am completely confused! > > Phil > > "Michael Virnstein" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > you have to put this on top of every of your pages: > > - > > session_name("hasLoggedIn"); > > $stuff = session_name(); > > session_start(); > > - > > session_name first sets the name. then you call session_start which will > > look for the > > sessionid in ${session_name()}. that is why you have to call > session_name() > > BEFORE calling > > session_start(); > > > > Regards Michael > > > > > > "Phil Powell" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Thanx, however, I cannot retain the session_name when I go to the next > > URL. > > > How do I retain the session_name especially when I have to use a form > > > method=POST? > > > > > > I have a URL that will be the login > > > > > > Once you login you will have a session (that works now) > > > > > > That page with the session will have a form with five type > > form > > > elements > > > > > > Once submitted you will be at a "thank-you" page and files uploaded, but > > > then the session is gone (session_name is back to PHPSESSID again) > > > > > > What do I do to keep it? I cannot use cookies and putting it in the URL? > > > > > > Phil > > > "Michael Virnstein" <[EMAIL PROTECTED]> wrote in message > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > session_name will retur the previos name of the session, so in your > case > > > > $stuff will contain "PHPSESSID" > > > > and i think you have to call session_start(); before you do > > > > $HTTP_SESSION_VARS["username"] = $username; > > > > > > > > so perhaps this will work: > > > > > > > > session_name("hasLoggedIn"); > > > > $stuff = session_name(); > > > > session_start(); > > > > $HTTP_SESSION_VARS["username"] = $username; > > > > > > > > Regards, Michael > > > > > > > > "Phil Powell" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > > Will the following lines set up a session by the name of > "hasLoggedIn" > > > > with > > > > > HTTP_SESSION_VARS["username"]? > > > > > > > > > > $stuff = session_name("hasLoggedIn"); > > > > > $HTTP_SESSION_VARS["username"] = $username; > > > > > session_start(); > > > > > > > > > > I am trying to create a pa
[PHP] Re: How to create, name and start PHP sessions
In your example, simply place this line in your code (on *every* page you want the session to be on): session_name("HasLoggedIn"); session_register("username"); If your PHP was compiled with '--enable-trans-sid' you shouldn't have to worry about anything else. PHP will automatically store the session ID in a cookie, or it will pass the session ID in your HTML links. If it wasn't compiled with '--enable-trans-sid', you'll need to use the constant SID. Example: -- Welcome . Click here to continue. -- Hope that helps! Check out http://www.php.net/manual/en/ref.session.php for more info -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "Phil Powell" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Thanx, however, I cannot retain the session_name when I go to the next URL. > How do I retain the session_name especially when I have to use a form > method=POST? > > I have a URL that will be the login > > Once you login you will have a session (that works now) > > That page with the session will have a form with five type form > elements > > Once submitted you will be at a "thank-you" page and files uploaded, but > then the session is gone (session_name is back to PHPSESSID again) > > What do I do to keep it? I cannot use cookies and putting it in the URL? > > Phil > "Michael Virnstein" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > session_name will retur the previos name of the session, so in your case > > $stuff will contain "PHPSESSID" > > and i think you have to call session_start(); before you do > > $HTTP_SESSION_VARS["username"] = $username; > > > > so perhaps this will work: > > > > session_name("hasLoggedIn"); > > $stuff = session_name(); > > session_start(); > > $HTTP_SESSION_VARS["username"] = $username; > > > > Regards, Michael > > > > "Phil Powell" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Will the following lines set up a session by the name of "hasLoggedIn" > > with > > > HTTP_SESSION_VARS["username"]? > > > > > > $stuff = session_name("hasLoggedIn"); > > > $HTTP_SESSION_VARS["username"] = $username; > > > session_start(); > > > > > > I am trying to create a page that sets a session variable upon > successful > > > login, problem is, the session_name() never changes it always remains > the > > > default PHPSESSID what am I doing wrong now? > > > > > > I fixed the problem with multiple files, that was bizarre! > > > > > > Thanx > > > Phil > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: superglobal var names can't access object methods?
I may be wrong on this one, and someone please correct me if I am, but I believe you can't store objects in a session variable. That might be the problem. -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "Erik Price" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I am getting the following error message: > > Fatal error: Call to undefined function: add_folderfile() in > /home/eprice/public_html/filerequest.php on line 756 > > I have the following code, line 756 is the line with the "if" test: > > // add the $ff_instance to the Print Request Folder using method > add_folderfile() > if (!$_SESSION['prfolder']->add_folderfile(serialize($ff_instance))) { >die("Could not store \$ff_instance object in \$_SESSION['prfolder'] > object"); > } > > The add_folderfile() method of the $_SESSION['prfolder'] object looks > like this: > > // add a folderfile to the Print Request Folder > function add_folderfile($ff_obj) > { > $this->prf_folder[] = $ff_obj; > return true; > } > > And I have properly defined the class variable $this->prf_folder as an > array at the top of the class in the following fasion: > > var $prf_folder = array(); > > The add_folderfile() function is defined as part of a class in an > includefile called "classes.inc", which I know is being correctly > included because every page on my site is built with a template class in > that same file. > > > Now that you've heard my life story... > > Does anyone know of any reasons why I might be getting the "undefined > function" error? Am I unable to use a superglobal > ($_SESSION['prfolder']) as the name of an object when attempting to use > a method of that object (as in the code at the top of this email)? > > > TIA, > > Erik > > > > > > Erik Price > Web Developer Temp > Media Lab, H.H. Brown > [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Server-side imagemaps?
Is there anyway I can use server-side imagemaps with PHP? I want to build an application that lets people click on a picture, and have the coordinates of the click on the picture be stored in a database. I've searched www.php.net and it makes no mention of it. TIA. -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: what do i put in .htaccesss to achieve this
Try this: RewriteEngine On Options +FollowSymlinks RewriteBase / RewriteCond %{HTTP_HOST} whatever.yoursite.com RewriteCond %{REQUEST_URI} !path/to/desination/folder/ RewriteRule ^(.*)$ path/to/destination/folder/$1 [L] That should do it. -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "Adrian Murphy" <[EMAIL PROTECTED]> wrote in message 004b01c1e486$3c0cb1a0$02646464@ade">news:004b01c1e486$3c0cb1a0$02646464@ade... Hi, I use wildcard dns to point all requests at the root e.g whatever.mysite.com goes to root etc.however i'll like to redirect these requests to mysite.com/users/sites/whatever so what do i put in the .htacces file bearing in mind that i want requests just for mysite.com to be left alone. thanx adrian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I'm having trouble handling POST file uploads... HELP!
I am having a problem moving files uploaded using POST. What is supposed to happen is it takes two files, a picture and its associated thumbnail, both of which have been uploaded via HTTP POST, and moves them to two different folders, renaming them appropriately. Here's the code... --- BEGIN CODE FRAGMENT --- function upload($pid) { GLOBAL $siteroot, $HTTP_POST_FILES, $fileroot; // more manageable variable names to work with $picfile = $HTTP_POST_FILES['picfile']['tmp_name']; $thumbfile = $HTTP_POST_FILES['thumbfile']['tmp_name']; $pic = $HTTP_POST_FILES['picfile']['name']; $thumb = $HTTP_POST_FILES['thumbfile']['name']; // check if *pictures* were uploaded, as opposed to some other file type if(!$picsize = getimagesize($picfile) || !$thumbsize = getimagesize($thumbfile) ) { $error[] = "Either the picture was not uploaded properly, or ". "it was not a valid picture. Please hit 'back' and try ". "again."; } // get the file extension of the pictures $picext = strstr($pic, "."); $thumbext = strstr($thumb, "."); // create the filenames pictures will be stored under $picname = "pic" . $pid . $picext; $thumbname = "thumb" . $pid . $thumbext; // destination path for pictures and thumbnails $picdest = "$fileroot/pictures/$picname"; $thumbdest = "$fileroot/thumbs/$thumbname"; // debug info $message = "Picture Source: $picfile\n". "Picture Dest: $picdest\n\n". "Thumbnail Source: $thumbfile\n". "Thumbnail Dest: $thumbdest\n\n"; message($message); // security check then copy files to destination folder... if (!is_uploaded_file($picfile) || !is_uploaded_file($thumbfile) ) { $error[] = "Possible File Upload attack. File Upload aborted."; } elseif (!$movepic = copy($picfile, $picdest) || !$movethumb = copy($thumbfile, $thumbdest) ) { // ... or quit with error $error[] = "File could not be copied. Please retry.\n". "Picture Source: $picfile\n". "Picture Dest: $picdest\n\n". "Thumbnail Source: $thumbfile\n". "Thumbnail Dest: $thumbdest\n\n". "Picture: $movepic Thumbnail: $movethumb"; } // check for errors or write successful entry to dbase if(isset($error) ) { error($error); } else { $db = open_db(); $query = "UPDATE yb_pictures SET ". "thumburl='" . $thumbname . "', ". "picurl='" . $picname . "', ". "status='3' ". "WHERE id='" . $pid . "'"; $result = query($query, $db); // output for user $message = "Picture uploaded successfully. Please ". "go back to the Site ". "Manager."; message($message); } } --- END CODE FRAGMENT --- My problem is that the script completes successfully and reports "Picture uploaded successfully". But when I go to see if the files are there, the thumbnail file is missing. Only the picture file appears where it should. I have checked, re-checked and checked again for typos or other errors in the file or directory names, and I am sure there are none. I have no idea what could be the problem. Go to http://www.unndunn.com/guestbook.php?action=showVersionInfo for info about the version of PHP the server is running. Thanks in advance! -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com -- 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]
Re: [PHP] Getting the filesize of an image?
Not the dimensions. Of course I knew that. I want the file size, as in 'how many bytes'. GetImageSize() doesn't do that. -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com "Kurt Lieber" <[EMAIL PROTECTED]> wrote in message E169xrH-0001ED-00@z8">news:E169xrH-0001ED-00@z8... > Yes -- RTFM. > > http://php.net/getimagesize > > --kurt > > On Friday 30 November 2001 04:04 pm, Uchendu Nwachukwu wrote: > > Is there any easy way to get the filesize of an image on a remote server? > > > > Please tell me there is! TIA -- 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]
[PHP] Getting the filesize of an image?
Is there any easy way to get the filesize of an image on a remote server? Please tell me there is! TIA -- Uchendu Nwachukwu newsreply AT unndunn DOT com - www.unndunn.com -- 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]
[PHP] 'Undefined Variable' help...
OK, I have a problem calling a function using default variables. In 'gallery.inc': - function gallery ($filename, $first = 1, $tablewidth = 4, $total = 20) { echo "Filename: $filename, First image: $first, Table Width: $tablewidth, Total: $total"; } - In 'gallery.php': - include('/path/to/gallery.inc'); ... gallery('test.txt',$first,$width,$images); - $first, $width and $images are variables that are defined by the URL, as if they were submitted through a form using HTTP GET, and they are designed to be used like that. My problem is, if I don't define those variables in the URL when I run gallery.php, PHP will come back with 'Undefined Variable' errors. Is there any way I can prevent that from happening? TIA! -- Uchendu Nwachukwu unndunn AT yahoo DOT com - www.unndunn.com -- 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]