[PHP] can you prompt for variables in command-line CGI?
for a SHELL SCRIPT using php binary: in bash I would do this: #!/bin/bash echo -n username: read username echo -n password: read password echo $username echo $password Run on the command-line, it would stop and ask me for the username and password, then continue the bash shell script. But in PHP, how would I prompt someone at the command-line for input? -- 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] use NEWLY-ASSIGNED SESSION id?
My PHP script (with --trans-sid enabled) assigns a session ID for people without cookies. No big deal, right? BUT THE BIG QUESTION IS: Can I immediately know what long string PHP assigned to the session, without having to click to a different page first? I want one single PHP page to #1 - assign a session #2 - then use header ("Location: http://someurl.php?PHPSESSID=" . $userid) immediately in that same page. ((The reason why would take too long to explain.)) So... HOW COULD I DO THIS? (without cookies enabled?) -- 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] sessions broken when redirected?
I had this same problem and it constantly broke our whole site. So I tried a different approach and this has been working great: Instead of ? header ("Location: sometoherpage.php"); ? Consider: ? include "someotherpage.php"; ? It works flawlessly, always, and maintains your session. Because my site ( a shopping cart/store ) is so dependent on sessions, I stopped using redirects and "Location: " functions entirely. We just use ? include "..." ? now and all sessions work wonderfully. Even without cookies, etc. -- 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] Classes and Object Oriented Programming
Is there a good tutorial on Classes? http://www.zend.com/zend/tut/class-intro.php That's a really good one. -- 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] Statistics function
the connection will close when you hit cancel but the PHP code can continue running if you choose. Really?!? How do you choose to have the PHP script continue even if a browser leaves/dumps? I've always wanted to do that. Didn't know it was possible. -- 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] normal for Apache to hang?
Does your Apache hang? Is that normal? To have commands sitting for 1-2 minutes? Using Apache 1.3.17 + PHP 4.0.4pl1 + newest MySQL on a Debian Linux box. I use PHP for pretty much everything. So I have Apache set to parse all files as PHP. But that's never been a problem before. (This is a new server, therefore new Apache, PHP, MySQL, etc.) Any ideas? Check out this "top" report: 53 processes: 52 sleeping, 1 running, 0 zombie, 0 stopped CPU states: 0.2% user, 0.7% system, 0.0% nice, 99.0% idle Mem: 512452K av, 503160K used, 9292K free, 0K shrd, 7260K buff Swap: 979956K av, 0K used, 979956K free372228K cached PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND [[ snip some other processes here ]] 12345 www9 0 4648 4648 2240 S 0 0.0 0.9 1:05 httpd 12346 www9 0 4792 4792 2244 S 0 0.0 0.9 1:12 httpd 12347 www9 0 4600 4600 2240 S 0 0.0 0.8 1:08 httpd 12348 www9 0 4964 4964 2240 S 0 0.0 0.9 1:08 httpd 12349 www 10 0 4912 4912 2292 S 0 0.0 0.9 1:08 httpd 12352 www9 0 4868 4868 2248 S 0 0.0 0.9 1:04 httpd 12358 www9 0 4736 4736 2248 S 0 0.0 0.9 1:05 httpd 12359 www9 0 4744 4744 2240 S 0 0.0 0.9 1:09 httpd 12360 www9 0 5036 5036 2428 S 0 0.0 0.9 1:10 httpd 12361 www9 0 4656 4656 2248 S 0 0.0 0.9 1:12 httpd 12377 mysql 9 0 6624 6624 2076 S 0 0.0 1.2 0:04 mysqld 12378 mysql 9 0 6624 6624 2076 S 0 0.0 1.2 0:05 mysqld Whaddya think? -- 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] Sending pretty email
At 07:49 AM 3/11/01 , Richard Scott Crawford wrote: The first thing to do is to take two aspirin and lie down until the temptation to do this passes. It may be cool, but those of us who use Eudora or Pine for our e-mail don't read HTML-encoded mail, don't *want* to read HTML-encoded mail, and get really annoyed when it shows up in our mailboxes. I generally agree, but there is... ONE GOOD USE FOR HTML EMAIL: AOL DUMMIES. REASON: When I would send my email list a URL I needed them to go to, I would do it in plain-text. ("Go to www.something.com and do something.") And because 90% of the email programs out there automatically make it a hyperlinked URL, there was no problem - *EXCEPT* the AOL people who would email back stupid things like, "Sounds interesting! What's the web address?" SOLUTION: When you're sending email using PHP, try this: if (strtolower(strstr($email, '@'))=="aol.com") { $link1 = 'a href="http://www.something.com/"www.something.com/a'; $link2 = 'a href="http://www.otherthing.com/"www.otherthing.com/a'; } else { $link1 = 'www.something.com'; $link2 = 'www.otherthing.com'; } $message = "Hey $firstname - Check out this link! " . $link1 . " and also this one... " . $link2 . " Enoy!"; mail ($email, $subject, $message, $headers); That way the AOL dummies get their hyperlinked HTML links, and all the cool people of the world get the regular simple version. -- 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] spidering dynamic pages
if I move everything to php and just use a different text file for each page for the main body of text and load each text file depending on what page the user wants, would the search engine search though those text files and just link to those and not to the php file? Would it even be spidered by the search enging properly? Many search engines will NOT spider pages that have "?" or "" in the URL. But they WILL spider PHP pages as if they were static content IF you hack Apache or PHP to let "/" be the variable separator instead of "?" There are different ways of doing this. Search the PHP list archives or check out some recent PHP books. But here's the effect you're shooting for: INSTEAD OF: http://www.yoursite.com/showarticle.php?id=3article=8language=en YOU CAN MAKE IT: http://www.yoursite.com/showarticle/id/3/article/8/language/en OR EVEN: http://www.yoursite.com/showarticle/3/8/en OR: http://www.yoursite.com/somepage/en/3/8.html ... and just have PHP ignore any ".*" URL extensions before deciding what to take as the variables in the URL. I do the last example at this site: http://www.cdbaby.org/ It's a totally dynamic site that has gotten very well-spidered using these methods. THE APACHE HACK: You can either use "mod_rewrite" or in your Apache "/conf/httpd.conf" file, set: DefaultType application/x-httpd-php --- not sure of exact spelling So that ALL files with no extension are parsed as PHP files. Which lets you rename "showarticle.php" to just "showarticle" in the examples above. Hope this made sense. I'd give concrete code examples but I'm offline right now. -- 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] How to protect my scripts ???
Can't the files be put into a directory that Apache has access to and the users don't, and just ask the users to include them? Or put them into a global prepend in a directory same as above? This isn't PERFECT, but I do this: #1 - make a user/group called "www" #2 - Set Apache to run as that user. #3 - chmod all web-directories to 700 permission (chown www:www -R *; chmod 700 -R *) - so that ONLY "www" can read/write them. #4 - log in as "www" user when you're uploading files to your webserver. -- 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] Sending pretty email
I often receive email from commercial sites (e.g. ZDnet) that looks like a Web page. How can I do that with Sendmail in PHP? The man page for "mail" gives an example of it. http://www.php.net/mail It's just one "$header" line, stating HTML, then the rest of your message should be in HTML: htmlbody h1Hello Todd!/h1 pThank you for your can of worms./p Of course I recommend spacing out your HTML so that people without HTML capabilities can still make good sense of it. -- 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] payment - the death of CyberCash
Everyone so far has been recommending ClearCommerce: http://www.clearcommerce.com/ Since my site is 100% PHP and depends on CyberCash for sales, I'll let everyone here know what I find out about getting PHP to work with ClearCommerce or anyone else. -- 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] include() require()
Which is the main difference between include() and require() functions? "include" is optional you can put it inside an "IF" like this: if (0) { /* THIS WILL NOT SHOW... */ include "optional_file.php"; } but "require" happens every time, even if it is inside an "IF" that does not happen. if (0) { /* THIS WILL SHOW ANYWAY... */ require "optional_file.php"; } Me personally, I use "require" to include functions, libraries, classes that I NEED to run the page. Then I use "include" for optional things, based on "if". ? require "functions.inc"; if ($sunny_day) { include "sunny_day_message.txt"; } ? -- 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] foo[bar] _or_ foo['bar'] ?
I'd really appreciate a clear statement whether to use better $foo = array('bar' = 'boing'); doWhatSoEver($foo[bar]); or $foo = array('bar' = 'boing'); doWhatSoEver($foo['bar']); I had heard someone on the list say that it's always best to use quotes, for the same reason as XHTML, where every value MUST have quotes. But honestly I've been using only NO-quotes all year and find it much easier to read. And NEVER any problem! Also makes it easier when you need to use an array variable inside a quoted string: print "Hello there $client[name]"; -- 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] PARANOID PERMISSIONS for apache?
Can anyone think of any downside to this idea? Set Apache to run as user/group "www:www" Set ownership of PHP files and folders to "www:www" And set permissions to 700 So that ONLY Apache can read them. Now - even if I give someone shell access to my box, or someone finds my personal login password, they still can't read my PHP passwords to MySQL. (Of course I'd have to be user "www" when uploading changes/files to the website.) Any other paranoid people tried this? Any downside to it? -- 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] HOWTO: Installation on Cobalt RaQ (RaQ3 or RaQ4)
I run about 8 Cobalt RaQ3 and RaQ4 boxes, and this is the installation procedure that always works for me. Don't use the Cobalt RPMs. They're bad out of date. - GET THE SOURCE TARBALLS for MySQL and PHP4 from the command line: lynx http://mysql.he.net/Downloads/MySQL-3.23/mysql-3.23.32.tar.gz Then D - download, and enter to save to disk. That's the newest source tarball from a fast mirror site. To untar it, do this: tar -xvfz mysql-3.23.32.tar.gz Do the same for the newest PHP at lynx http://www.php.net/do_download.php?download_file=php-4.0.4pl1.tar.gz HOW TO SET UP A NEW RAQ SERVER: TO MAKE MySQL: ## - FIRST: TO MAKE A USER NAME 'mysql' GROUP NAME 'mysql' TO SAFELY RUN MYSQL UNDER /usr/sbin/groupadd mysql /usr/sbin/useradd mysql -g mysql ./configure --prefix=/usr/local/mysql-3.23 --with-mysqld-user=mysql --with-lz make make install ## - MAKE A "SYMLINK" SO THAT NO MATTER WHAT VERSION OF MYSQL WE'RE ON, IT'LL ALWAYS BE AT /USR/LOCAL/MYSQL cd /usr/local ln -s mysql-3.23.28 mysql ## - SET THE DATA DIRECTORY TO BE /VAR/DB - MAKE A SYMLINK FOR IT HERE IN THE MYSQL FOLDER cd mysql ln -s /var/db var ## - INSTALL THE BASIC DATABASE NEEDED TO RUN bin/mysql_install_db ## - if there's a problem, do the next step then come back and do this step again. ## - GO SET PERMISSIONS FOR THE DATA DIRECTORY cd /var chown mysql:mysql -R db chmod 700 -R db ## - COPY THE STARTUP/INIT/CONFIG FILES TO THE RIGHT PLACE cd share/mysql cp mysql.server /etc/rc.d/init.d/ cp my-small.cnf /var/db/my.cnf ## - PUT STARTUP FILES IN EVERY STARTUP FOLDER - so if they reboot the server, MySQL starts! cd /etc/rc.d/init.d/ chmod 755 mysql.server cd ../rc3.d ln -s ../init.d/mysql.server S88mysql cd ../rc4.d ln -s ../init.d/mysql.server S88mysql cd ../rc6.d ln -s ../init.d/mysql.server K18mysql cd ../rc0.d ln -s ../init.d/mysql.server K18mysql ## - SYMLINK THE COMMANDS INTO THE PATH SO WE CAN JUST TYPE "mysql" FROM ANYWHERE cd /usr/bin ln -s /usr/local/mysql/bin/* ./ cd /usr/sbin ln -s /usr/local/mysql/bin/* ./ ## - START IT! safe_mysqld mysqladmin -u root -p password 'somesecretpassword' mysql -u root -p use mysql; delete from user where user=''; exit; from now on, connect to mysql with 'mysql -u root -p' then type the magic password afterwards. TO MAKE PHP4: ## - weird little bug workaround - was looking in wrong directory for Apache cd /usr/bin ln -s /usr/sbin/httpd httpd ## - GO BACK TO THE PHP4 INSTALLATION DIRECTORY (/home/sites/home/users/admin/software/php4.0.3/) ./configure --with-apxs=/usr/sbin/apxs --with-mysql=/usr/local/mysql --enable-track-vars --enable-trans-sid --enable-ftp make make install vi php.ini-dist ## - CHANGE THESE LINES: under [mail function] sendmail_path = /usr/sbin/sendmail -t -i ## COPY THE CONFIGURATION FILE TO WHERE PHP LOOKS FOR IT cp php.ini-dist /usr/local/lib/php.ini ## WE HAVE TO ADD MySQL TO THE LIBRARY PATH vi /etc/ld.so.conf ## - ADD THESE LINES AT THE END; /usr/local/mysql/lib/mysql /sbin/ldconfig ## MAKE APACHE PHP-READY: vi /etc/httpd/conf/srm.conf find this line: DirectoryIndex index.html index.htm etc and add the 2 more options: index.php index.php3 find the line talking about PHP: change it from "php3" to just: AddType application/x-httpd-php .php .php3 .htm .html ## READY TO RESTART APACHE: go into /etc/httpd/conf/httpd.conf and IF there is a line that reads this: LoadModule php4_modulelib/apache/libphp4.so amend it to read this: LoadModule php4_module/usr/lib/apache/libphp4.so then restart httpd: /etc/rc.d/init.d/httpd restart -- 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]