You are here: Re: htpasswd problem « PHP Programming Language « IT news, forums, messages
Re: htpasswd problem

Posted by Jerry Stuckle on 10/28/06 12:28

PeacePipe wrote:
> Oops ‹ must change nick. I see there is another "Happy" already in here.
>
> Hello folks. My colleague and I are unable to figure out what is wrong
> with some code. We can't make it do what we want. Perhaps some kind
> person can help please.
>
> I run a particular pay-to-view web site. For credit card processing, we
> signed on with PayPal.
>
> The process is generally working ok. An interested person clicks the
> "join" button on the site and is transported to PayPal where he enters
> his card data and so on.
>
> PayPal generates access codes for the new member and emails them to
> him. PayPal also sends us an email announcing a new join.
>
> The problem is that, so far, I must update the .htpasswd file manually
> to liven up access to the member area.
>
> My colleague has good PHP skills and has written code to try to enable
> PayPal to update the file automatically but all attempts fail so far.
> The relevant section of the code is reproduced below. (This is not the
> entire file, only the reelvant lines.)
>
> We have proper permissions to write to the .htaccess file (777)
>
> ===============
>
> <?php
>
> $username = $_POST['username'];
> $password = $_POST['password'];
>
> $filename = '.htpasswd';
>
> $pass = crypt($password, substr($password, 0, 2));
>
> $pwf = $username.":".$pass;
>
> if ($pwf) {
>
> $fp = fopen($filename, 'a');
> $pwf = $pwf."\n";
> fputs($fp, $pwf, strlen($pwf));
> fclose($fp);
>
> $fp = fopen($filename, 'r');
> fpassthru($fp);
>
> }
>
> ?>

Rather than trying to keep your .htaccess and/or .htpasswd up to date,
use a database for authentication. Much easier. mod_auth_mysql (on
sourceforge.net) can do it for mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация