i'm trying to write a php script that will password protect some
random directory by creating a .htaccess file, and a password file to
accompany the .htaccess file, and it isn't working... specifically, i
can't enter the newly created directory with a username of test, and a
password of test, which is what i am trying to do.
also, i'm testing this script out on a remote server, and... after
this script runs, i can't delete any of the files it produces...
specifically, i get this error:
rm: cannot unlink `.htaccess': Permission denied
i was told that the problem was that the owner of the file was
incorrect, but... i've made other scripts that create files, and
haven't had any problems deleting those files... so why would i have
a problem deleting these files?
any help would be appreciated! here's the script:
<?
$user = "test";
$pass = "test";
system("mkdir tester");
$filename = "./tester/.htaccess";
$fp = fopen($filename, "w");
fputs($fp,"AuthUserFile ./tester/.tester\n");
fputs($fp,"AuthGroupFile /dev/null\n");
fputs($fp,"AuthName EnterPassword\n");
fputs($fp,"AuthType Basic\n\n");
fputs($fp,"require user wsabstract");
fclose($fp);
$filename = "./tester/.tester";
$fp = fopen($filename, "w");
fputs($fp,$user . ":" . crypt($pass,substr($pass,0,2)));
fclose($fp);
?> 1 7674
yawnmoth wrote: i'm trying to write a php script that will password protect some random directory by creating a .htaccess file, and a password file to accompany the .htaccess file, and it isn't working... specifically, i can't enter the newly created directory with a username of test, and a password of test, which is what i am trying to do.
You've said:
fputs($fp,"require user wsabstract");
when I believe that should be:
fputs($fp,"require user test");
also, i'm testing this script out on a remote server, and... after this script runs, i can't delete any of the files it produces... specifically, i get this error:
rm: cannot unlink `.htaccess': Permission denied
i was told that the problem was that the owner of the file was incorrect, but... i've made other scripts that create files, and haven't had any problems deleting those files... so why would i have a problem deleting these files?
Don't know about this one. Try checking the permissions on the directory
in which the file is kept - maybe there is no write permission on that
(although then you wouldn't have been able to write the .htaccess file).
Try a system call:
system('rm ./tester/.htaccess -f');
(the -f is 'force', not sure if this will help).
MK.
any help would be appreciated! here's the script:
<? $user = "test"; $pass = "test";
system("mkdir tester");
$filename = "./tester/.htaccess";
$fp = fopen($filename, "w"); fputs($fp,"AuthUserFile ./tester/.tester\n"); fputs($fp,"AuthGroupFile /dev/null\n"); fputs($fp,"AuthName EnterPassword\n"); fputs($fp,"AuthType Basic\n\n"); fputs($fp,"require user wsabstract"); fclose($fp);
$filename = "./tester/.tester";
$fp = fopen($filename, "w"); fputs($fp,$user . ":" . crypt($pass,substr($pass,0,2))); fclose($fp); ?>
--
MeerKat This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Els |
last post by:
***newbie question***
Hi, I am trying to make my server (Apache) parse .html files
as .php.
I found this line of code:
ForceType application/x-httpd-php
placed it in an .htaccess file and...
|
by: Vinicius |
last post by:
Hi,
I have this script to list files in the same directory;
<?
$dir=opendir(".");
readdir($dir);
readdir($dir);
while ($conteudo = readdir($dir)) {
echo "<a...
|
by: Jack Hambabo |
last post by:
Hi,
I'm searching for a php script that can find out whether the current
user (I know _SERVER will give me the name for
non-cgi php) has the right to view a specific file.
My dream is that I...
|
by: Stefan Bellon |
last post by:
Hi all!
I want to parse the contents of an .htaccess file from within PHP. The
contents of the .htaccess file looks like this:
<Files foobar.tar.gz>
AuthType Basic
AuthUserFile /foobar...
|
by: nickyeng |
last post by:
I have checked this info from apache website, and i confused with it.
Procteing System files
it said:
To run a really tight ship, you'll want to stop users from setting up .htaccess files...
|
by: asherwolf |
last post by:
Hi,
I'm trying to do something I think is pretty neat, but I've just about pulled my hair out by the behavior of my server. I'm hosting on GoDaddy, using a subdomain (www.mywebpage.com maps to...
|
by: jaanus |
last post by:
Here we go...
What I have been trying to do is to forward all http requests containing /cms/ to http://cms.mydomain.com/
example1: http://host1.mydomain.com/cms/init.php would be parsed from...
|
by: Kurda Yon |
last post by:
Hi,
in the home directory I put .htaccess with "register_globals 0".
Obviously, all php-files from this directory will not take variables
from the address line. But, as far as I understand, the...
|
by: Geoff Cox |
last post by:
Hello,
Using .htaccess and a linux server is it possible to give group access
to a person so that he/she can access files in several different
folders?
If yes, how is this done?!
Cheers
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
| |