[PHP] REDIRECT_QUERY_STRING weirdness ... redirecting from one file to another
Hi, I would like any file under the root of a certain domain name to redirect to a PHP template file. For instance, I would like a request for /services/ to redirect to http://myhost/index.php?path=/services/ . This is similar to what PHP.Net does with their function lookup shortcut (where you can go to http://php.net/function-name instead of the longer equivalent.) I have it set up with mod_rewrite as follows: RewriteEngine on RewriteRule ^(.+) /path/to/index.php?path=$1 [L] The only problem is that Apache is considering this a redirect, and is thus overwriting my $1 with the name of the current file (index.php.) The only place I can find the original file is HTTP_SERVER_VARS[REDIRECT_QUERY_STRING]. Is there a way to pull out the name of the original file without going through extracting $HTTP_SERVER_VARS and the like? BTW, I know there was a post on how PHP.Net did the function shortcut a while back. If someone can post a link to that again, I'd be grateful. I can't seem to find it. Thanks! Erica -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sendmail
Do you have a specific reason for calling Sendmail directly? If not, try http://www.php.net/manual/en/function.mail.php Erica Uma Shankari T. [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Can anyone help me in solving this problem.. For sending mail using sendmail i have written the code like this but it is giving some error messages in the From address instead of address $TO=Me; $[EMAIL PROTECTED]; $fd = popen(/usr/sbin/sendmail -t,w); fputs($fd, To: $user\n); fputs($fd, From: $TO\n); fputs($fd, Subect: Feedback\n); $ver = phpversion(); fputs($fd, X-Mailer: PHP/FI $ver\n\n); fputs($fd, Hii $user,\n $body \n); pclose($fd); Can anyone tell the solution for this. -Uma -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Encrypted pages/email with PHP?
(posting again because it looks like the first one didn't go through) Hi, I've sniffed around on Google and PHPBuilder, but I can't seem to find any information on creatnig encrypted pages with PHP. Here is what I am looking for. I have a client who owns a retail store. Thus, he has a manual credit card swiper. He would like to have orders from his website listed on a special page with the customer's name, credit card number, etc. where he can go once a day and process the orders manually. I explained that he could also have the customer data sent in an encrypted email, and he is fine with that. Anyway, I'm looking for some solution that creates an encrypted page, passworded, where I can make sure that the information is not being passed down the wire in plain-text. I can't seem to find a good tutorial explaining exactly what I would need to create this. Will I need to buy a Thawte/Verisign ID just for this? (That seems unreasonable, as he would be the only one accessing the page.) How would I go about setting this up? I run my own server, so I can install programs to do this. Currently I'm running on a Cobalt RaQ (http://www.cobalt.com). Any links regarding setting this sort of site up would be helpful. Thanks, Erica P.S. After my experience, I'd be happy to create a tutorial regarding this if there isn't one already. Assuming I complete this successfully, I will post the results back to this list. -- 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] Paypal instant payment notification
Hello, I have a customer who wants to implement Paypal instant payment notification on his website. Basically, he wants a script that emails a custom message once a customer purchases an item. Instant Payment Notification has the ability to do this. However, I have a couple of questions: -- Is this really the best method? We're going to implement a shopping cart on the site, too, so Paypal might not be the best solution. -- Does anyone have sample code for Instant Payment Notification? If you'd like more information about Instant Payment Notification, you can go here: https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-info Note that this requires you to login with a Paypal account. Here's a brief synopsis taken from the above page: How It Works When a customer makes a payment to you, PayPal will post a notification to your server at a URL you specify. Included in this notification will be all of your customer's payment information (e.g. customer name, amount) as well as a piece of encrypted code. When your server receives a notification, it will then post the information, including the encrypted code, back to a secure PayPal URL. PayPal will authenticate the transaction and send confirmation of its validity back to your server. After you have activated Instant Payment Notification, your server will be sent a notification every time you receive a payment, this notification will be sent as a hidden FORM POST to the URL you specified, and will include all of the payment information. The FORM variables for the notification are listed below: To me, this seems kind of like a hack -- i.e. there should be a better way to do this, perhaps as part of a (free or low-cost) shopping cart and payment prcoessing system. Also, there seems to be no way to test this without sending the Paypal user money. (I am going to contact Paypal about that one.) Any experiences, good or bad, and advice would be appreciated. Thanks! Erica Remove SPAMFREE- to email me. -- 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 whole directories?
Sure. Use an array, as suggested in the example on the include manual page, but put all files in a specific directory in that array. To do that, use code like the following: # load files into array # assign $directory to your variable, or replace $directory in the below line with the directory you want. $handle=opendir($directory); while ($file = readdir($handle)) { # read all files in dir if ($file != .. $file != .) { $files_to_include[count($files_to_include)] = $file; # cram them files into array ;) }; }; #clean up and sort closedir($handle); if (is_array($files_to_include)) { while (list ($key, $val) = each ($files_to_include)) { include $files[$i]; }; }; I modified some previous code to work for what you want, so my apologies if there are missing curly braces or the like. Hope this helps, Erica andrew [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Is there any way to include whole directories? I have my function declarations in many small, easily maintainable files, but it's a pain to include/require them all individually...I would like to just split them into directories by common purpose, e.g functions/auth functions/content functions/modules and then include a directory at once - any ideas? cheers! andrew -- 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 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] Find and Replace script: Content Stripper; recursive subdirectories; ereg_replace, preg_replace
I have created a content stripper file that I am releasing to this newsgroup as freeware. The file takes a .html file that looks like this: _ HEADER _ CONTENT _ FOOTER _ and strips out the header and footer according to certain delimiters in the .html file. Although it was made for a very specific purpose, it can be modified to do a number of things. It recurses subdirectories, so it can be used as a general find/replace file with an HTML interface. It is freeware and can be freely modified. I'd appreciate it if you let me know where you are using this file, however. Please send any suggestions regarding this file to [EMAIL PROTECTED] Thanks to all who helped me write the regular expressions -- I sincerely appreciate your help. -- -- erica douglass -- -- [EMAIL PROTECTED] -- -- ?php #content_update.php #erica douglass, 4/2001. #suggestions are welcome... please mail them to [EMAIL PROTECTED] if ($action == strip) { strip_files($directory); find_subdirs($directory); } else { print_html(); }; function print_html() { ? html head titleContent Stripper/title body pfont face=Verdana, Arial, Helvetica, sans-serif Make sure all directories you are about to strip have write access for your web server user (usually user httpd.) To do this through the command line, get root access and type the following:br brchown -R httpd idirectory/i/b brwhere idirectory/i is the directory where your HTML files are located. The -R option means recursive, which changes all subdirectories of the directory you specify. Don't use -R unless you include the full path of the files, e.g. ichown -R /home/sites/home/web/test ./i brbrEnter the directory from which you would like to strip files (example: /home/sites/home/web/test):br /font/p pfont face=Verdana, Arial, Helvetica, sans-serif size=+1bSecurity Alert!/b If you change your files to be owned by your web server user, anyone with malicious intent can harm them from the web. Therefore, it is suggested that you immediately bchown -R root/b (or your username) ibdirectory/b/i from a command prompt after you run this script. Although the script itself cannot be hacked, we still strongly recommend making the above change./font/p form action=?php print $PHP_SELF; ? method=post input type=text size=30 name=directory input type=hidden name=action value=strip input type=submit name=submit value=Strip 'em! /form /body /html ?php }; function strip_files($directory) { $handle=opendir($directory); # open dir print font face=\Verdana, Arial, Helvetica, sans-serif\ size=\+1\Reading directory b$directory/b...br; while (false!==($file = readdir($handle))) { # read all files in dir if (eregi(.*\.html$, $file)) { # as long as it ends with .html (case insensitive) print Now stripping header and footer from i$directory/$file/i...br; $file = $directory . / . $file; #make sure file has the proper directory appended to it # get contents of a file into a string $fd = fopen ($file, r); $contents = fread ($fd, filesize ($file)); fclose ($fd); # replace header gif (any img tag with src=images/headers) $contents = preg_replace (/IMG.+SRC=\images\/headers.*/, , $contents); $contents = preg_replace (/IMG.+SRC=\\/forte\/images\/headers.*/, , $contents); # now, find occurrence of !-- MAIN CONTENT -- and delete everything before it. $contents = ereg_replace (.*\!-- MAIN CONTENT --, , $contents); # replace all occurrences of !-- -- $contents = ereg_replace (\!-- --, , $contents); # replace everything after !-- END OF MAIN CONTENT -- $contents = ereg_replace (\!-- END OF MAIN CONTENT --.*, , $contents); # rename old file to $file.old rename ($file, ${file}.old); # write new file ($contents) to $file $fp = fopen (strtolower($file), a+); fwrite ($fp, $contents); fclose ($fp); # print congratulations message print b$file/b has been stripped. Your original file is called i${file}.old./ibrbr; }; } print /font; closedir($handle); # close file }; # end function strip_files function find_subdirs($directory) { # load subdirectories into array $handle=opendir($directory); while ($file = readdir($handle)) { # read all files in dir if ($file != .. $file != .) { $file = $directory . / . $file; # ensure that is_dir picks the directories up properly if (is_dir($file)) { $subdirs[count($subdirs)] = $file; }; }; }; #clean up and sort closedir($handle); if (is_array($subdirs)) { sort($subdirs); while (list ($key, $val) = each ($subdirs)) { strip_files($val); find_subdirs($val); } }; }; # end function find_subdirs -- 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] Where is php.ini located by default?
If I'm not mistaken, the locate command uses a cache which is only updated every 24 hours or so. You can either recreate locate's cache by reading locate's man pages, or you can actually search the filesystem by using the following commands: cd / (go to the root directory) find . -name php.ini The last command actually searches the filesystem at the time the command is executed, instead of relying on a cached database like the locate command. Of course, if the file has been on your system for a while and has not recently changed location, you should probably use locate because the search will be faster. Also, another tip: To make sure you know where the configuration file is going to be, compile PHP with this option: ./configure --with-config-file-path=/etc/httpd (or wherever you would like to place your file.) Erica PHPBeginner.com [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... /usr/lib/php is the default configuration... if I am not worng... 'cause I have some memory leaks recently :-) have you tried : # locate php.ini # locate php.ini-dist while on windows it should be located in WINNT directory (on NT/2K). It will ask YOU to move them there during the installation. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Martin Skjoldebrand [mailto:[EMAIL PROTECTED]] Sent: Saturday, April 28, 2001 1:38 PM To: [EMAIL PROTECTED] Subject: [PHP] Where is php.ini located by default? I've built php from a tarball. Now I need to specify a special include path in the php.ini file. But I can't find it. There is a php.in-dist in the build catalog but I can't find a production php.ini anywhere. The docs says that it should be in the install catalogue (which is where?, /usr/local/lib/php doesn't have one) or the cwd. I've tried editing the sample file and putting it in either place but my app still gives me the following error: Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php') in FILENAME Martin S. -- 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 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 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] ereg_replace: Replacing only first occurrence
I want to only replace the first occurrence of a string in a file using ereg_replace. Should I use a loop to do this? Any suggestions? Please email me at [EMAIL PROTECTED] with suggestions. Thanks, Erica -- 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] ereg_replace: Help!
I have one ereg_replace problem that I cannot seem to fix. I need to delete an IMG tag. The only thing I know about this tag is that it will contain SRC=images/headers in the string. Here is an example: IMG ALT=Tools BORDER=0 HEIGHT=55 SRC=images/headers/tools.gif WIDTH=455 I tried this, but it didn't work: $contents = ereg_replace (IMG.*images/headers.*, , $contents); Can someone please help? Thanks, Erica -- 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] PHP 4.0.4 / phpMyAdmin
I posted this to the phpMyAdmin support forum and emailed Tobias Ratschiller, but have heard no response. I am posting to this forum to try and resolve this problem. I had phpMyAdmin running successfully on my server. I then upgraded to PHP 4.0.4, and phpMyAdmin appears to have broken. The error messages I receive are as follows: Warning: Variable passed to reset() is not an array or object in /path/to/phpMyAdmin/lib.inc.php on line 102 Warning: Variable passed to each() is not an array or object in /path/to/phpMyAdmin/lib.inc.php on line 103 The variable is $cfgServers, which is set in config.inc.php. There is probably something that was disabled in PHP 4.0.4, or else a new syntax, that broke this script. The syntax in config.inc.php looks like this: $cfgServers[1]['host'] = 'localhost; // MySQL hostname $cfgServers[1]['port'] = '';// MySQL port - leave blank for default port $cfgServers[1]['adv_auth'] = 'true'; // Use advanced authentication? $cfgServers[1]['stduser'] = 'root'; // MySQL standard user (only needed with advanced auth) $cfgServers[1]['stdpass'] = 'password'; // MySQL standard password (only needed with advanced auth) $cfgServers[1]['user'] = 'root';// MySQL user (only needed with basic auth) $cfgServers[1]['password'] = '';// MySQL password (only needed with basic auth) $cfgServers[1]['only_db'] = ''; // If set to a db-name, only this db is accessible $cfgServers[1]['verbose'] = ''; Any help would be greatly appreciated. Erica Douglass Server Appliance Business Unit Sun Microsystems (Cobalt Networks) -- 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] PHP 4.0.4 / phpMyAdmin
Clarification: A quotation mark got left out after ['host'] = 'localhost in my original email. It is in the config.inc.php file and makes no difference in the error messages. The fix is below. Erica ""Erica Douglass"" [EMAIL PROTECTED] wrote in message 93indu$enk$[EMAIL PROTECTED]">news:93indu$enk$[EMAIL PROTECTED]... I posted this to the phpMyAdmin support forum and emailed Tobias Ratschiller, but have heard no response. I am posting to this forum to try and resolve this problem. I had phpMyAdmin running successfully on my server. I then upgraded to PHP 4.0.4, and phpMyAdmin appears to have broken. The error messages I receive are as follows: Warning: Variable passed to reset() is not an array or object in /path/to/phpMyAdmin/lib.inc.php on line 102 Warning: Variable passed to each() is not an array or object in /path/to/phpMyAdmin/lib.inc.php on line 103 The variable is $cfgServers, which is set in config.inc.php. There is probably something that was disabled in PHP 4.0.4, or else a new syntax, that broke this script. The syntax in config.inc.php looks like this: $cfgServers[1]['host'] = 'localhost'; // MySQL hostname $cfgServers[1]['port'] = '';// MySQL port - leave blank for default port $cfgServers[1]['adv_auth'] = 'true'; // Use advanced authentication? $cfgServers[1]['stduser'] = 'root'; // MySQL standard user (only needed with advanced auth) $cfgServers[1]['stdpass'] = 'password'; // MySQL standard password (only needed with advanced auth) $cfgServers[1]['user'] = 'root';// MySQL user (only needed with basic auth) $cfgServers[1]['password'] = '';// MySQL password (only needed with basic auth) $cfgServers[1]['only_db'] = ''; // If set to a db-name, only this db is accessible $cfgServers[1]['verbose'] = ''; Any help would be greatly appreciated. Erica Douglass Server Appliance Business Unit Sun Microsystems (Cobalt Networks) -- 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 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]